mirror of
https://github.com/wassname/ray.git
synced 2026-08-10 12:30:14 +08:00
[tune] Added timeout parameter to tune.run(), (#10642)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user