paidiverpy.config#

__init__.py for config module.

Submodules#

Classes#

Configuration

Configuration class.

Package Contents#

class paidiverpy.config.Configuration(config_file_path: str | None = None, add_general: dict[str, Any] | None = None, add_steps: list[dict[str, Any]] | None = None)[source]#

Configuration class.

Parameters:
  • config_file_path (str, optional) – The configuration file path. Defaults to None.

  • add_general (dict, optional) – The general configuration. Defaults to None.

  • add_steps (list[dict], optional) – The steps configuration. Defaults to None.

static validate_config(config: dict[str, Any] | str | pathlib.Path, local: bool = True) None[source]#

Validate the configuration.

Parameters:
  • config (dict | str | Path) – The configuration to validate.

  • local (bool, optional) – Whether the schema is local. Defaults to True.

add_general(config: dict[str, Any], validate: bool = False) None[source]#

Add a configuration.

Parameters:
  • config (dict) – The configuration.

  • validate (bool, optional) – Whether to validate the configuration. Defaults to False.

Raises:

ValueError – Invalid configuration name.

add_step(config_index: int | None = None, parameters: dict[str, Any] | None = None, insert: bool = False, validate: bool = False, step_class: type[paidiverpy.colour_layer.ColourLayer] | type[paidiverpy.convert_layer.ConvertLayer] | type[paidiverpy.position_layer.PositionLayer] | type[paidiverpy.sampling_layer.SamplingLayer] | type[paidiverpy.custom_layer.CustomLayer] | type[paidiverpy.investigation_layer.InvestigationLayer] | None = None) int[source]#

Add a step to the configuration.

Parameters:
  • config_index (int, optional) – The configuration index. Defaults to None.

  • parameters (dict, optional) – The parameters for the step. Defaults to None.

  • insert (bool, optional) – Whether to insert the step at the given index. Defaults to False.

  • validate (bool, optional) – Whether to validate the configuration. Defaults to True.

  • step_class (BaseModel, optional) – The class of the step. Defaults to None.

Raises:

ValueError – Invalid step index.

Returns:

The step index.

Return type:

int

remove_step(config_index: int | None = None) int[source]#

Remove a step from the configuration.

Parameters:

config_index (int, optional) – The configuration index. Defaults to None, which means the last step will be removed.

Raises:

ValueError – Invalid step index.

Returns:

The step index.

Return type:

int

export(output_path: pathlib.Path | str | None) None | str[source]#

Export the configuration to a file.

Parameters:

output_path (str, optional) – The path to save the configuration file. If None, returns the configuration as a YAML string.

Returns:

If output_path is None, returns the configuration as a YAML string.

Otherwise, writes the configuration to the specified file.

Return type:

None | str

get_output_path(output_path: str | pathlib.Path | None = None) tuple[pathlib.Path | str, bool][source]#

Get the output path.

Parameters:

output_path (str, optional) – The output path. Defaults to None.

Returns:

The output path and whether it is remote.

Return type:

tuple[Path | str, bool]

to_dict(yaml_convert: bool = False) dict[str, Any][source]#

Convert the configuration to a dictionary.

Parameters:

yaml_convert (bool, optional) – Whether to convert the configuration to a yaml format. Defaults to False.

Returns:

The configuration as a dictionary.

Return type:

dict

__repr__() str[source]#

Return the string representation of the configuration.

Returns:

The string representation of the configuration.

Return type:

str