mirror of
https://github.com/wassname/ray.git
synced 2026-08-10 12:30:14 +08:00
[tune] Split Search from Scheduling (#2452)
Introduces SearchAlgorithm concept, separate from schedulers in Tune. Moves HyperOpt under this concept.
This commit is contained in:
@@ -79,3 +79,41 @@ class Experiment(object):
|
||||
exp.name = name
|
||||
exp.spec = spec
|
||||
return exp
|
||||
|
||||
|
||||
def convert_to_experiment_list(experiments):
|
||||
"""Produces a list of Experiment objects.
|
||||
|
||||
Converts input from dict, single experiment, or list of
|
||||
experiments to list of experiments. If input is None,
|
||||
will return an empty list.
|
||||
|
||||
Arguments:
|
||||
experiments (Experiment | list | dict): Experiments to run.
|
||||
|
||||
Returns:
|
||||
List of experiments.
|
||||
"""
|
||||
exp_list = experiments
|
||||
|
||||
# Transform list if necessary
|
||||
if experiments is None:
|
||||
exp_list = []
|
||||
elif isinstance(experiments, Experiment):
|
||||
exp_list = [experiments]
|
||||
elif type(experiments) is dict:
|
||||
exp_list = [
|
||||
Experiment.from_json(name, spec)
|
||||
for name, spec in experiments.items()
|
||||
]
|
||||
|
||||
# Validate exp_list
|
||||
if (type(exp_list) is list
|
||||
and all(isinstance(exp, Experiment) for exp in exp_list)):
|
||||
if len(exp_list) > 1:
|
||||
print("Warning: All experiments will be"
|
||||
" using the same Search Algorithm.")
|
||||
else:
|
||||
raise TuneError("Invalid argument: {}".format(experiments))
|
||||
|
||||
return exp_list
|
||||
|
||||
Reference in New Issue
Block a user