mirror of
https://github.com/wassname/ray.git
synced 2026-08-12 12:20:11 +08:00
[tune] Reporter crash fix (#5426)
Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
This commit is contained in:
committed by
Richard Liaw
co-authored 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):
|
||||
|
||||
@@ -28,7 +28,7 @@ def compute_advantages(rollout, last_r, gamma=0.9, lambda_=1.0, use_gae=True):
|
||||
last_r (float): Value estimation for last observation
|
||||
gamma (float): Discount factor.
|
||||
lambda_ (float): Parameter for GAE
|
||||
use_gae (bool): Using Generalized Advantage Estamation
|
||||
use_gae (bool): Using Generalized Advantage Estimation
|
||||
|
||||
Returns:
|
||||
SampleBatch (SampleBatch): Object with experience from rollout and
|
||||
|
||||
Reference in New Issue
Block a user