es_sfgtools.utils.model_update module

es_sfgtools.utils.model_update.deep_merge_dicts(base: Dict[str, Any], override: Dict[str, Any]) Dict[str, Any]

Recursively merge override dict into base dict.

For nested dictionaries, values are merged recursively rather than replaced. For other types, override values replace base values.

Parameters:
  • base (dict) – The base dictionary to merge into.

  • override (dict) – The override dictionary with values to merge.

Returns:

A new dictionary with merged values.

Return type:

dict

es_sfgtools.utils.model_update.validate_and_merge_config(base_class: BaseModel, override_config: BaseModel | Dict[str, Any]) BaseModel

Validates and merges override configuration with base config, checking for typos.

Performs a deep merge so that nested configuration objects (like pride_config) are merged field-by-field rather than completely replaced.

Parameters:
  • base_class (BaseModel) – The base configuration class instance (Pydantic model).

  • override_config (dict) – The override configuration dictionary to update the base config.

Returns:

A new instance of the base_class with merged configuration.

Return type:

BaseModel

Raises:

ValueError – If there are typos or invalid keys in the override_config.

es_sfgtools.utils.model_update.validate_keys_recursively(config_dict: dict, model_class: BaseModel, path: str = '')

Recursively validate keys and suggest corrections for typos.

Parameters:
  • config_dict (dict) – The dictionary to validate.

  • model_class (BaseModel) – The Pydantic model to validate against.

  • path (str, optional) – The current path in the nested dictionary, for error reporting.

Returns:

A list of error messages.

Return type:

list