[tune] Initial Commit for Tune CLI (#3983)

This introduces a light CLI for Tune.
This commit is contained in:
Richard Liaw
2019-03-08 16:46:05 -08:00
committed by GitHub
parent 3064fad96b
commit 6630a35353
18 changed files with 492 additions and 69 deletions
+16 -1
View File
@@ -61,7 +61,7 @@ def deep_update(original, new_dict, new_keys_allowed, whitelist):
if k not in original:
if not new_keys_allowed:
raise Exception("Unknown config parameter `{}` ".format(k))
if type(original.get(k)) is dict:
if isinstance(original.get(k), dict):
if k in whitelist:
deep_update(original[k], value, True, [])
else:
@@ -71,6 +71,21 @@ def deep_update(original, new_dict, new_keys_allowed, whitelist):
return original
def flatten_dict(dt):
while any(isinstance(v, dict) for v in dt.values()):
remove = []
add = {}
for key, value in dt.items():
if isinstance(value, dict):
for subkey, v in value.items():
add[":".join([key, subkey])] = v
remove.append(key)
dt.update(add)
for k in remove:
del dt[k]
return dt
def _to_pinnable(obj):
"""Converts obj to a form that can be pinned in object store memory.