[tune] Split Search from Scheduling (#2452)

Introduces SearchAlgorithm concept, separate from schedulers in Tune. Moves HyperOpt under this concept.
This commit is contained in:
Richard Liaw
2018-08-04 21:27:39 -07:00
committed by GitHub
parent 9449d07eca
commit 914a433e3f
28 changed files with 920 additions and 415 deletions
+38
View File
@@ -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