From f2a5fe314388a3eb100d0ec36ddfcbaecbfa4474 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch <p.jentsch@uni-bielefeld.de> Date: Mon, 3 May 2021 11:12:40 +0200 Subject: [PATCH] Make Jobs restartable when they are "complete" --- web/app/jobs/views.py | 4 ++-- web/app/models.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/app/jobs/views.py b/web/app/jobs/views.py index ffb5df15..4101c7ae 100644 --- a/web/app/jobs/views.py +++ b/web/app/jobs/views.py @@ -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 diff --git a/web/app/models.py b/web/app/models.py index 6cd94698..ba139e91 100644 --- a/web/app/models.py +++ b/web/app/models.py @@ -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 -- GitLab