nvflare.fuel.utils.dict_utils module

augment(to_dict: dict, from_dict: dict, from_override_to=False, append_list='components') str[source]

Augments the to_dict with the content from the from_dict.

  • Items in from_dict but not in to_dict are added to the to_dict

  • Items in both from_dict and to_dict must be ether dicts or list of dicts, and augment will be done on these items recursively

  • Non-dict/list items in both from_dict and to_dict are considered conflicts.

Parameters:
  • to_dict – the dict to be augmented

  • from_dict – content to augment the to_dict

  • from_override_to – content in from_dict overrides content in to_dict when conflict happens

  • append_list – str or list of str: item keys for list to be appended

Returns:

An error message if any; empty str if success.

Note

The content of the to_dict is updated

extract_first_level_primitive(d)[source]
merge_dict(dict1, dict2)[source]
update(d, u)[source]
update_components(target_dict: dict, from_dict: dict) str[source]

update components in target_dict with components from the from_dict. If a component with the same ID exists in both target_dict and from_dict, the component in from_dict will replace the one in target_dict. If a component only exists in from_dict, it will be added to the component list of target_dict. :param target_dict: the dict to be updated :param from_dict: the dict that will be used to update the target_dict

Returns:

update_configs_with_envs(configs, env)[source]