[tune] Added timeout parameter to tune.run(), (#10642)

This commit is contained in:
Kai Fricke
2020-09-08 15:38:28 -07:00
committed by GitHub
parent 415be78cc0
commit 87c4f36f02
4 changed files with 106 additions and 1 deletions
+10 -1
View File
@@ -8,7 +8,8 @@ from ray.tune.error import TuneError
from ray.tune.registry import register_trainable, get_trainable_cls
from ray.tune.result import DEFAULT_RESULTS_DIR
from ray.tune.sample import Domain
from ray.tune.stopper import FunctionStopper, Stopper
from ray.tune.stopper import CombinedStopper, FunctionStopper, Stopper, \
TimeoutStopper
from ray.tune.utils import detect_checkpoint_function
logger = logging.getLogger(__name__)
@@ -102,6 +103,7 @@ class Experiment:
name,
run,
stop=None,
time_budget_s=None,
config=None,
resources_per_trial=None,
num_samples=1,
@@ -159,6 +161,13 @@ class Experiment:
raise ValueError("Invalid stop criteria: {}. Must be a "
"callable or dict".format(stop))
if time_budget_s:
if self._stopper:
self._stopper = CombinedStopper(self._stopper,
TimeoutStopper(time_budget_s))
else:
self._stopper = TimeoutStopper(time_budget_s)
_raise_on_durable(self._run_identifier, sync_to_driver, upload_dir)
stdout_file, stderr_file = _validate_log_to_file(log_to_file)