omegaconf_resolvers
OmegaConf resolvers for the mldft package.
The separators of the override in the run names are __ and - per default (key1-value1__key2-value2).
You can change them by setting the environment variables MLDFT_RUN_NAME_KEY_VALUE_SEP and
MLDFT_RUN_NAME_OVERRIDE_SEP, e.g. by adding the following to your shell configuration file:
export MLDFT_RUN_NAME_KEY_VALUE_SEP="="
export MLDFT_RUN_NAME_OVERRIDE_SEP=", "
- _get_leaf_key(full_key: str) str[source]
- Returns the leaf key of a full key: “key1.subkey1/subsubkey1” -> “subsubkey1” 
- checkpoint_path_to_run_number(ckpt_path: str) str[source]
- Converts a checkpoint path to a run number. E.g. “…/sciai- dft/train/runs/448_maybe2_lower_bound_loss/checkpoints/last.ckpt” gets mapped to “448”. - If the checkpoint path is not in the expected format, an exception is raised. - Parameters:
- ckpt_path ( - str) – The checkpoint path to convert.
- Returns:
- The run number. 
- Return type:
- str 
- Raises:
- ValueError – If the checkpoint path is not in the expected format. 
 
- dir_counter(path: str, length: int = 2) str[source]
- Counts the number of runs in a directory. - Parameters:
- path ( - str) – The path to the directory.
- length ( - int, optional) – The length of the counter. Defaults to 2.
 
- Returns:
- The counter as a string with leading zeros. 
- Return type:
- str 
 
- leafs_only_override_dirname(overrides_string: str) str[source]
- Converts an override string of the form “key1.subkey1=value1,key2=value2,key3/subkey3=value3” to a more compact form “subkey1-value1__key2-value2__subkey3-value3”. - Parameters:
- overrides_string ( - str) – The override string to compactify, as returned by- ${hydra.job.override_dirname}.
- Returns:
- The compactified override string. 
- Return type:
- str 
 
- parse_reps_import(rep)[source]
- Imports and calls the parse_reps function from tensorframes. - The import is done here to make the tests run without the tensorframes package. If the package is not installed, using this resolver will raise an ImportError that indicates that the tensorframes package is missing. 
- smart_override_dirname(overrides_string: str, exclude_keys: list | str = None) str[source]
- Converts an override string of the form “key1.subkey1=str_value1,key2=int_value2,key3/subkey3=float_value3” to a more compact form “str_value1__key2-int_value2__subkey3-float_value3”, where the subkeys are only shown if the value is numeric. - Parameters:
- overrides_string ( - str) – The override string to compactify, as returned by- ${hydra.job.override_dirname}.
- exclude_keys ( - list | str, optional) – A list of keys to exclude from the compactified string. Defaults to None.
 
- Returns:
- The compactified override string. 
- Return type:
- str 
 
- split_overrides_string(overrides_string: str) dict[source]
- Splits an override string of the form “key1.subkey1=value1,key2=value2,key3/subkey3=value3” by commas, which are not in brackets. - Note: This is still not perfect, e.g. “’” will lead to problems. - Parameters:
- overrides_string ( - str) – The override string to split.
- Returns:
- The split override string as a dictionary with keys (before ‘=’) and values (after ‘=’). 
- Return type:
- dict 
 
- values_only_override_dirname(overrides_string: str) str[source]
- Converts an override string of the form “key1.subkey1=value1,key2=value2,key3/subkey3=value3” to a more compact form “value1__value2__value3”. - Parameters:
- overrides_string ( - str) – The override string to compactify, as returned by- ${hydra.job.override_dirname}.
- Returns:
- The compactified override string. 
- Return type:
- str