[tune][minor] Move helper function (#1722)

This commit is contained in:
Richard Liaw
2018-03-15 18:41:02 -07:00
committed by GitHub
parent 882a649f0c
commit 459fd5e152
+11 -11
View File
@@ -10,6 +10,17 @@ from ray.tune.trial import Trial
from ray.tune.config_parser import make_parser, json_to_resources
def to_argv(config):
argv = []
for k, v in config.items():
argv.append("--{}".format(k.replace("_", "-")))
if isinstance(v, str):
argv.append(v)
else:
argv.append(json.dumps(v))
return argv
def generate_trials(unresolved_spec, output_path=''):
"""Wraps `generate_variants()` to return a Trial object for each variant.
@@ -23,17 +34,6 @@ def generate_trials(unresolved_spec, output_path=''):
if "run" not in unresolved_spec:
raise TuneError("Must specify `run` in {}".format(unresolved_spec))
def to_argv(config):
argv = []
for k, v in config.items():
argv.append("--{}".format(k.replace("_", "-")))
if isinstance(v, str):
argv.append(v)
else:
argv.append(json.dumps(v))
return argv
parser = make_parser()
i = 0
for _ in range(unresolved_spec.get("repeat", 1)):