fl4health.utils.config module¶
- exception InvalidConfigError[source]¶
Bases:
ValueError
- make_dict_with_epochs_or_steps(local_epochs=None, local_steps=None)[source]¶
Given two optional variables, this function will determine which, if any, are not None and create a dictionary from the value. If both are not None, it will prioritize
local_epochs
. If both are None, then the dictionary is empty.- Parameters:
- Returns:
Dictionary with at most one of the non-none values, keyed by the name of the non-none variable
- Return type:
- narrow_dict_type(dictionary, key, narrow_type_to)[source]¶
Checks if a key exists in dictionary and if so, verify it is of type
narrow_type_to
.- Parameters:
- Returns:
The type-checked value at dictionary[key]
- Return type:
T
- Raises:
ValueError – If dictionary[key] is not of type
narrow_type_to
or if the key is not present in dictionary.
- narrow_dict_type_and_set_attribute(self, dictionary, dictionary_key, attribute_name, narrow_type_to, func=None)[source]¶
Checks a key exists in dictionary, verify its type and sets the corresponding attribute. Optionally, passes narrowed value to function prior to setting attribute. If key is not present in dictionary or dictionary[dictionary_key] has the wrong type, a
ValueError
is thrown.- Parameters:
- Raises:
ValueError – If dictionary[key] is not of type
narrow_type_to
or if the key is not present in dictionary.- Return type: