Skip to content
Snippets Groups Projects
Commit f2a5fe31 authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

Make Jobs restartable when they are "complete"

parent f4233093
No related branches found
No related tags found
No related merge requests found
......@@ -47,8 +47,8 @@ def download_job_input(job_id, job_input_id):
@admin_required
def restart(job_id):
job = Job.query.get_or_404(job_id)
if job.status != 'failed':
flash('Can not restart job "{}": Status is not "failed"'.format(job.title), 'error') # noqa
if job.status not in ['complete', 'failed']:
flash('Can not restart job "{}": Status is not "complete/failed"'.format(job.title), 'error') # noqa
else:
tasks.restart_job(job_id)
flash('Job "{}" has been marked to get restarted!'.format(job.title), 'job') # noqa
......
......@@ -410,11 +410,11 @@ class Job(db.Model):
def restart(self):
'''
Restart a job - only if the status is failed
Restart a job - only if the status is complete or failed
'''
if self.status != 'failed':
raise Exception('Could not restart job: status is not "failed"')
if self.status not in ['complete', 'failed']:
raise Exception('Could not restart job: status is not "complete/failed"') # noqa
shutil.rmtree(os.path.join(self.path, 'output'), ignore_errors=True)
shutil.rmtree(os.path.join(self.path, 'pyflow.data'), ignore_errors=True) # noqa
self.end_date = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment