mirror of
https://github.com/wassname/ray.git
synced 2026-08-15 12:45:23 +08:00
[tune] Support Configuration Merging (#3584)
* merge configs * deep merge * lint * add resolve * test
This commit is contained in:
@@ -93,6 +93,21 @@ _STANDARD_IMPORTS = {
|
||||
_MAX_RESOLUTION_PASSES = 20
|
||||
|
||||
|
||||
def resolve_nested_dict(nested_dict):
|
||||
"""Flattens a nested dict by joining keys into tuple of paths.
|
||||
|
||||
Can then be passed into `format_vars`.
|
||||
"""
|
||||
res = {}
|
||||
for k, v in nested_dict.items():
|
||||
if isinstance(v, dict):
|
||||
for k_, v_ in resolve_nested_dict(v).items():
|
||||
res[(k, ) + k_] = v_
|
||||
else:
|
||||
res[(k, )] = v
|
||||
return res
|
||||
|
||||
|
||||
def format_vars(resolved_vars):
|
||||
out = []
|
||||
for path, value in sorted(resolved_vars.items()):
|
||||
|
||||
Reference in New Issue
Block a user