[tune] Reporter crash fix (#5426)

Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
This commit is contained in:
Neil Lugovoy
2019-08-13 14:10:22 -07:00
committed by Richard Liaw
parent b7d0733362
commit 1376f1ae60
4 changed files with 12 additions and 3 deletions
@@ -459,6 +459,15 @@ class TrainableFunctionApiTest(unittest.TestCase):
self.assertEqual(trial.status, Trial.TERMINATED)
self.assertEqual(trial.last_result[TIMESTEPS_TOTAL], 100)
def testReporterNoUsage(self):
def run_task(config, reporter):
print("hello")
experiment = Experiment(run=run_task, name="ray_crash_repro")
[trial] = ray.tune.run(experiment).trials
print(trial.last_result)
self.assertEqual(trial.last_result[DONE], True)
def testErrorReturn(self):
def train(config, reporter):
raise Exception("uh oh")
+1 -1
View File
@@ -321,7 +321,7 @@ class Trial(object):
location_string(
self.last_result.get(HOSTNAME),
self.last_result.get(PID))), "{} s".format(
int(self.last_result.get(TIME_TOTAL_S)))
int(self.last_result.get(TIME_TOTAL_S, 0)))
]
if self.last_result.get(TRAINING_ITERATION) is not None:
+1 -1
View File
@@ -506,7 +506,7 @@ class TrialRunner(object):
result = trial.last_result
result.update(done=True)
self._total_time += result[TIME_THIS_ITER_S]
self._total_time += result.get(TIME_THIS_ITER_S, 0)
flat_result = flatten_dict(result)
if trial.should_stop(flat_result):