mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Add job delete function.
This commit is contained in:
parent
2991082f1f
commit
b2e2484725
@ -7,6 +7,7 @@ from .. import db
|
|||||||
from ..models import Corpus, Job
|
from ..models import Corpus, Job
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
@main.route('/')
|
@main.route('/')
|
||||||
@ -144,7 +145,17 @@ def job_download(job_id):
|
|||||||
@login_required
|
@login_required
|
||||||
def delete_job(job_id):
|
def delete_job(job_id):
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
logger.warning(job_id)
|
||||||
job = Job.query.filter_by(id=job_id).first()
|
job = Job.query.filter_by(id=job_id).first()
|
||||||
|
logger.warning('Job status: {}'.format(job.status))
|
||||||
job.flag_for_stop()
|
job.flag_for_stop()
|
||||||
logger.warning('Job status: {}'.format(job.status))
|
logger.warning('Job status: {}'.format(job.status))
|
||||||
|
deleted = False
|
||||||
|
while deleted is False:
|
||||||
|
db.session.refresh(job)
|
||||||
|
if job.status == 'deleted':
|
||||||
|
logger.warning('Job status is deleted.')
|
||||||
|
time.sleep(5)
|
||||||
|
job.delete_job()
|
||||||
|
deleted = True
|
||||||
return redirect(url_for('main.dashboard'))
|
return redirect(url_for('main.dashboard'))
|
||||||
|
@ -5,6 +5,9 @@ from werkzeug.security import generate_password_hash, check_password_hash
|
|||||||
from . import db
|
from . import db
|
||||||
from . import login_manager
|
from . import login_manager
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class Permission:
|
class Permission:
|
||||||
@ -293,13 +296,19 @@ class Job(db.Model):
|
|||||||
self.status = 'stopping'
|
self.status = 'stopping'
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
def delete_job(self, job_id):
|
def delete_job(self):
|
||||||
"""
|
"""
|
||||||
Delete job with given job id from database. Also delete associated job
|
Delete job with given job id from database. Also delete associated job
|
||||||
files
|
files
|
||||||
"""
|
"""
|
||||||
# TODO
|
logger = logging.getLogger(__name__)
|
||||||
pass
|
delete_path = os.path.join('/mnt/opaque/', str(self.user_id), 'jobs',
|
||||||
|
str(self.id))
|
||||||
|
logger.warning('Delete path is: {}'.format(delete_path))
|
||||||
|
if os.path.exists(delete_path):
|
||||||
|
shutil.rmtree(delete_path)
|
||||||
|
db.session.delete(self)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
class Corpus(db.Model):
|
class Corpus(db.Model):
|
||||||
|
@ -36,6 +36,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./logs:/home/opaque_daemon/logs
|
- ./logs:/home/opaque_daemon/logs
|
||||||
- $HOME/.docker/config.json:/home/opaque_daemon/.docker/config.json
|
- $HOME/.docker/config.json:/home/opaque_daemon/.docker/config.json
|
||||||
|
- /home/stephan/Repos/own/opaque_daemon/opaque_daemon.py:/home/opaque_daemon/opaque_daemon.py
|
||||||
db:
|
db:
|
||||||
deploy:
|
deploy:
|
||||||
placement:
|
placement:
|
||||||
|
Loading…
Reference in New Issue
Block a user