mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-12 00:50:40 +00:00
Reviewed Job Package
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
from flask import (abort, current_app, jsonify)
|
||||
from flask import abort, current_app, jsonify
|
||||
from flask_login import current_user, login_required
|
||||
from threading import Thread
|
||||
import os
|
||||
from app import db
|
||||
from app.decorators import admin_required, content_negotiation
|
||||
from app.models import Job, JobInput, JobResult, JobStatus
|
||||
from app.models import Job, JobStatus
|
||||
from . import bp
|
||||
|
||||
@bp.route('/<hashid:job_id>', methods=['DELETE'])
|
||||
@ -36,6 +36,7 @@ def delete_job(job_id):
|
||||
@bp.route('/<hashid:job_id>/log')
|
||||
@login_required
|
||||
@admin_required
|
||||
@content_negotiation(produces='application/json')
|
||||
def job_log(job_id):
|
||||
job = Job.query.get_or_404(job_id)
|
||||
if job.status not in [JobStatus.COMPLETED, JobStatus.FAILED]:
|
||||
@ -43,11 +44,18 @@ def job_log(job_id):
|
||||
return response, 409
|
||||
with open(os.path.join(job.path, 'pipeline_data', 'logs', 'pyflow_log.txt')) as log_file:
|
||||
log = log_file.read()
|
||||
return log, 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
||||
response_data = {
|
||||
'message': '',
|
||||
'jobLog': log
|
||||
}
|
||||
response = jsonify(response_data)
|
||||
response.status_code = 200
|
||||
return response
|
||||
|
||||
|
||||
@bp.route('/<hashid:job_id>/restart', methods=['POST'])
|
||||
@login_required
|
||||
@content_negotiation(produces='application/json')
|
||||
def restart_job(job_id):
|
||||
def _restart_job(app, job_id):
|
||||
with app.app_context():
|
||||
@ -66,4 +74,10 @@ def restart_job(job_id):
|
||||
args=(current_app._get_current_object(), job_id)
|
||||
)
|
||||
thread.start()
|
||||
return {}, 202
|
||||
response_data = {
|
||||
'message': \
|
||||
f'Job "{job.title}" marked for restarting'
|
||||
}
|
||||
response = jsonify(response_data)
|
||||
response.status_code = 202
|
||||
return response
|
||||
|
Reference in New Issue
Block a user