MCPcopy Create free account
hub / github.com/BioinfoMachineLearning/FlowDock / resolve_omegaconf_variable

Function resolve_omegaconf_variable

flowdock/__init__.py:16–35  ·  view source on GitHub ↗

Resolve an OmegaConf variable path to its value.

(variable_path: str)

Source from the content-addressed store, hash-verified

14
15
16def resolve_omegaconf_variable(variable_path: str) -> Any:
17 """Resolve an OmegaConf variable path to its value."""
18 # split the string into parts using the dot separator
19 parts = variable_path.rsplit(".", 1)
20
21 # get the module name from the first part of the path
22 module_name = parts[0]
23
24 # dynamically import the module using the module name
25 try:
26 module = importlib.import_module(module_name)
27 # use the imported module to get the requested attribute value
28 attribute = getattr(module, parts[1])
29 except Exception:
30 module = importlib.import_module(".".join(module_name.split(".")[:-1]))
31 inner_module = ".".join(module_name.split(".")[-1:])
32 # use the imported module to get the requested attribute value
33 attribute = getattr(getattr(module, inner_module), parts[1])
34
35 return attribute
36
37
38def resolve_dataset_path_dirname(dataset: str) -> str:

Callers 4

evaluateFunction · 0.90
trainFunction · 0.90
sampleFunction · 0.90

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected