[tune] Ensure Cleanup (#7967)

This commit is contained in:
Richard Liaw
2020-04-11 16:28:03 -07:00
committed by GitHub
parent dd63178e91
commit 87e3c39b48
5 changed files with 85 additions and 5 deletions
+19
View File
@@ -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}}}}