[tune] Component notification on node failure + Tests (#3414)

Changes include:
 - Notify Components on Requeue
 - Slight refactoring of Node Failure handling
 - Better tests
This commit is contained in:
Richard Liaw
2018-12-04 14:47:31 -08:00
committed by GitHub
parent ce355d13d4
commit 9d0bd50e78
8 changed files with 180 additions and 114 deletions
+11 -7
View File
@@ -216,17 +216,19 @@ class Trial(object):
return False
def should_checkpoint(self, result):
def should_checkpoint(self):
"""Whether this trial is due for checkpointing."""
result = self.last_result or {}
if result.get(DONE) and self.checkpoint_at_end:
return True
if not self.checkpoint_freq:
if self.checkpoint_freq:
return result.get(TRAINING_ITERATION,
0) % self.checkpoint_freq == 0
else:
return False
return self.last_result[TRAINING_ITERATION] % self.checkpoint_freq == 0
def progress_string(self):
"""Returns a progress message for printing out to the console."""
@@ -281,10 +283,12 @@ class Trial(object):
def should_recover(self):
"""Returns whether the trial qualifies for restoring.
This is if a checkpoint frequency is set, which includes settings
where there may not yet be a checkpoint.
This is if a checkpoint frequency is set and has not failed more than
max_failures. This may return true even when there may not yet
be a checkpoint.
"""
return self.checkpoint_freq > 0
return (self.checkpoint_freq > 0
and self.num_failures < self.max_failures)
def update_last_result(self, result, terminate=False):
if terminate: