TidalPy.utilities.classes.config package

Submodules

TidalPy.utilities.classes.config.config module

class TidalPy.utilities.classes.config.config.ConfigHolder(replacement_config: dict = None, store_py_info: bool = False)[source]

Bases: TidalPyClass

Classes which contain a parameter dictionary inherit from this class

Provides functionality to store a default dictionary and override those defaults with a user provided dictionary.

clear_state()[source]

Clear all state properties to None.

Purposefully avoid clearing things set during initialization: This should not clear configurations, methods,

or loaded functions. Instead it will reset properties like temperature, pressure, orbital frequency, etc.

property config: dict
default_config = None
default_config_key = None
get_param(param_name: str, raise_missing: bool = True, fallback: Any = None)[source]

Retrieves a parameter from the configuration dictionary

User can set if, upon a missing parameter, an exception is raised or a fallback is used instead.

Parameters:
  • param_name (str) – Name of parameter.

  • raise_missing (bool = True) – Flag to determine if an exception is raised when a parameter is not found.

  • fallback (Any) – Fallback if a parameter is not found and an exception is not raised.

Returns:

param – If found, the desired parameter, otherwise fallback is returned.

Return type:

Any

property old_config: dict
print_config()[source]

Print the object’s configuration dictionary in an easy to read way usng the pprint package.

replace_config(replacement_config: dict, force_default_merge: bool = False)[source]

Replaces the current configuration dictionary with a user provided one

Parameters:
  • replacement_config (dict) – New replacement config that will be used along with the default configurations to make a new config file.

  • force_default_merge (bool = False) –

    If True then the default dict will be used to merge new replacement dicts - even if there is

    a config dict present.

property replacement_config: dict
save_config(class_name: str = None, save_to_run_dir: bool = True, additional_save_dirs: list = None, save_default: bool = False, save_old_config: bool = False, overwrite: bool = False) Tuple[str, ...][source]

Saves class’ configurations to a local JSON file.

Parameters:
  • class_name (str (optional)) – Name to give the configuration file. Defaults to class’ pyname.

  • save_to_run_dir (bool = True) – If true then configs will be saved into the currently active TidalPy run directory.

  • additional_save_dirs (list (optional)) – List of any additional directories that configs will be saved to. This must be a list of proper, os-compliant path strings

  • save_default (bool = False) – If true then the methods default configurations will also be saved.

  • save_old_config (bool = False) – If true then any overwritten config (saved to the class’ .old_config) will also be saved.

  • overwrite (bool = False) – If true then any configs at the same directory and with the same name will be overwritten.

Returns:

config_filepaths – Final full paths of the saved config (main config, not default or old) files.

Return type:

Tuple[str, …]

update_config(force_default_merge: bool = False) dict[source]

Combines the default and provided replacement configurations into one dictionary.

Replacement config’s parameters override the default config’s parameters. :param force_default_merge:

If True then the default dict will be used to merge new replacement dicts - even if there is

a config dict present.

Returns:

config – The post-combined configuration dictionary.

Return type:

dict

class TidalPy.utilities.classes.config.config.LayerConfigHolder(layer, store_config_in_layer: bool = True)[source]

Bases: ConfigHolder

Classes with configuration information which are stored within a layer and make calls to that layer’s attributes and methods.

property layer
layer_config_key = None
property layer_type
property world
class TidalPy.utilities.classes.config.config.WorldConfigHolder(world, store_config_in_world: bool = True)[source]

Bases: ConfigHolder

Classes with configuration information which are stored within a world and make calls to that world’s attributes and methods.

property world
world_config_key = None
property world_type