Fix job result duplication after job restart

This commit is contained in:
Patrick Jentsch 2021-08-23 16:31:06 +02:00
parent a5782f932c
commit 280c544297

View File

@ -39,7 +39,7 @@ class Role(db.Model):
# Relationships # Relationships
users = db.relationship('User', backref='role', lazy='dynamic') users = db.relationship('User', backref='role', lazy='dynamic')
def to_dict(self): def to_dict(self, include_relationships=True):
return {'id': self.id, return {'id': self.id,
'default': self.default, 'default': self.default,
'name': self.name, 'name': self.name,
@ -423,6 +423,8 @@ class Job(db.Model):
raise Exception('Could not restart job: status is not "complete/failed"') # noqa 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
for result in self.results:
db.session.delete(result)
self.end_date = None self.end_date = None
self.status = 'submitted' self.status = 'submitted'