MCPcopy Create free account
hub / github.com/dcharatan/flowmap / separate_multiple_defaults

Function separate_multiple_defaults

flowmap/config/tools.py:28–56  ·  view source on GitHub ↗

Return a function that will pull individual configurations out of a merged dict. For example, the merged dict might look like this: { a: ... b: ... } The returned function will generate this: [{ name: a, ... }, { name: b, ... }] In other words, this functi

(data_class_union)

Source from the content-addressed store, hash-verified

26
27
28def separate_multiple_defaults(data_class_union):
29 """Return a function that will pull individual configurations out of a merged dict.
30 For example, the merged dict might look like this:
31
32 {
33 a: ...
34 b: ...
35 }
36
37 The returned function will generate this:
38
39 [{ name: a, ... }, { name: b, ... }]
40
41 In other words, this function makes the types for default lists with single and
42 multiple items be typed identically.
43 """
44
45 def separate_fn(joined: dict) -> list:
46 # The dummy allows the union to be converted.
47 @dataclass
48 class Dummy:
49 dummy: data_class_union
50
51 return [
52 get_typed_config(Dummy, DictConfig({"dummy": {"name": name, **cfg}})).dummy
53 for name, cfg in joined.items()
54 ]
55
56 return separate_fn

Callers 1

get_typed_root_configFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected