mirror of
https://github.com/wassname/ray.git
synced 2026-07-16 11:21:10 +08:00
[tune] Ensure Cleanup (#7967)
This commit is contained in:
@@ -614,6 +614,25 @@ class TrainableFunctionApiTest(unittest.TestCase):
|
||||
self.assertEqual(trial.last_result.get("name"), str(trial))
|
||||
self.assertEqual(trial.last_result.get("trial_id"), trial.trial_id)
|
||||
|
||||
@patch("ray.tune.ray_trial_executor.TRIAL_CLEANUP_THRESHOLD", 3)
|
||||
def testLotsOfStops(self):
|
||||
class TestTrainable(Trainable):
|
||||
def _train(self):
|
||||
result = {"name": self.trial_name, "trial_id": self.trial_id}
|
||||
return result
|
||||
|
||||
def _stop(self):
|
||||
time.sleep(2)
|
||||
open(os.path.join(self.logdir, "marker"), "a").close()
|
||||
return 1
|
||||
|
||||
analysis = tune.run(
|
||||
TestTrainable, num_samples=10, stop={TRAINING_ITERATION: 1})
|
||||
ray.shutdown()
|
||||
for trial in analysis.trials:
|
||||
path = os.path.join(trial.logdir, "marker")
|
||||
assert os.path.exists(path)
|
||||
|
||||
def testNestedResults(self):
|
||||
def create_result(i):
|
||||
return {"test": {"1": {"2": {"3": i, "4": False}}}}
|
||||
|
||||
Reference in New Issue
Block a user