Make Jobs restartable when they are "complete"

This commit is contained in:
Patrick Jentsch 2021-05-03 11:12:40 +02:00
parent f4233093c0
commit f2a5fe3143
2 changed files with 5 additions and 5 deletions

View File

@ -47,8 +47,8 @@ def download_job_input(job_id, job_input_id):
@admin_required @admin_required
def restart(job_id): def restart(job_id):
job = Job.query.get_or_404(job_id) job = Job.query.get_or_404(job_id)
if job.status != 'failed': if job.status not in ['complete', 'failed']:
flash('Can not restart job "{}": Status is not "failed"'.format(job.title), 'error') # noqa flash('Can not restart job "{}": Status is not "complete/failed"'.format(job.title), 'error') # noqa
else: else:
tasks.restart_job(job_id) tasks.restart_job(job_id)
flash('Job "{}" has been marked to get restarted!'.format(job.title), 'job') # noqa flash('Job "{}" has been marked to get restarted!'.format(job.title), 'job') # noqa

View File

@ -410,11 +410,11 @@ class Job(db.Model):
def restart(self): 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': if self.status not in ['complete', 'failed']:
raise Exception('Could not restart job: status is not "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, 'output'), ignore_errors=True)
shutil.rmtree(os.path.join(self.path, 'pyflow.data'), ignore_errors=True) # noqa shutil.rmtree(os.path.join(self.path, 'pyflow.data'), ignore_errors=True) # noqa
self.end_date = None self.end_date = None