mirror of
https://github.com/wassname/ray.git
synced 2026-07-09 19:41:37 +08:00
[tune] Reporter crash fix (#5426)
Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
This commit is contained in:
committed by
Richard Liaw
parent
b7d0733362
commit
1376f1ae60
@@ -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")
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user