Skip to content
Snippets Groups Projects
Commit 67f34f27 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[experiments] Re-use is_done() method from experiments

parent e0be6886
No related branches found
No related tags found
1 merge request!194Scheduler
...@@ -674,7 +674,7 @@ class Experiment(Shareable): ...@@ -674,7 +674,7 @@ class Experiment(Shareable):
def reset(self): def reset(self):
"""Resets an experiment so it can be run again""" """Resets an experiment so it can be run again"""
if not self.done(): return #can only reset experiments which are done if not self.is_done(): return #can only reset experiments which are done
self.blocks.update( self.blocks.update(
status=Block.NOT_CACHED, status=Block.NOT_CACHED,
...@@ -732,16 +732,10 @@ class Experiment(Shareable): ...@@ -732,16 +732,10 @@ class Experiment(Shareable):
return storage.get_file_content(self, 'declaration_file') return storage.get_file_content(self, 'declaration_file')
def done(self):
'''Says whether the experiment has finished or not'''
return self.status in (Experiment.DONE, Experiment.FAILED)
def update_state(self): def update_state(self):
'''Update self state based on associated block states''' '''Update self state based on associated block states'''
if self.done(): return if self.is_done(): return
block_statuses = self.blocks.values_list('status', flat=True) block_statuses = self.blocks.values_list('status', flat=True)
...@@ -811,6 +805,17 @@ class Experiment(Shareable): ...@@ -811,6 +805,17 @@ class Experiment(Shareable):
for b in self.blocks.all(): b._cancel() for b in self.blocks.all(): b._cancel()
def fork(self, username=None, name=None):
'''Forks this experiment under a new username or name'''
author = username or self.author
name = name or self.name
xp, _, __ = Experiment.objects.create_experiment(author,
self.toolchain, name, self.get_declaration(),
self.short_description, self.description)
return xp
#---------------------------------------------------------- #----------------------------------------------------------
......
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