MCPcopy
hub / github.com/e-p-armstrong/augmentoolkit / flatten_config

Function flatten_config

run_augmentoolkit.py:24–46  ·  view source on GitHub ↗

Flatten config while preserving specified nested structures

(config, no_flatten_keys=None)

Source from the content-addressed store, hash-verified

22
23
24def flatten_config(config, no_flatten_keys=None):
25 """Flatten config while preserving specified nested structures"""
26 flattened = {}
27 no_flatten = set(no_flatten_keys or [])
28
29 for key, value in config.items():
30 if key in no_flatten:
31 flattened[key] = value
32 continue
33
34 if isinstance(value, dict):
35 nested_flat = flatten_config(value, no_flatten_keys)
36 for nested_key, nested_value in nested_flat.items():
37 if nested_key in flattened:
38 raise ValueError(f"Key conflict: '{nested_key}'")
39 flattened[nested_key] = nested_value
40 else:
41 if key in flattened:
42 raise ValueError(f"Key conflict: '{key}'")
43 flattened[key] = value
44 print("FLATTENED")
45 print(flattened)
46 return flattened
47
48
49try:

Callers 2

run_pipeline_taskFunction · 0.90
run_pipeline_configFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected