StepsContainer#

class petpal.pipelines.steps_containers.StepsContainer(name: str, *steps: StepType)#

A container for managing and executing a sequence of steps in a pipeline.

This class allows for the addition, removal, and execution of steps, as well as printing their details and combining multiple step containers.

Variables:
  • name (str) – Name of the steps container.

  • step_objs (list[StepType]) – List of step objects in the container.

  • step_names (list[str]) – List of step names in the container.

Initializes the StepsContainer with a name and an optional sequence of steps.

Parameters:
  • name (str) – Name of the steps container.

  • *steps (StepType) – Optional sequence of steps to add to the container.

__repr__()#

Provides an unambiguous string representation of the TACsFromSegmentationStep instance.

Returns:

str – A string representation showing how the instance can be recreated.

add_step(step: StepType)#

Adds a step to the container if it is not already present.

Parameters:

step (StepType) – The step to add.

Raises:
  • TypeError – If the step is not of the correct type.

  • KeyError – If a step with the same name already exists.

remove_step(step: int | str)#

Removes a step from the container by index or name.

Parameters:

step (Union[int, str]) – The index or name of the step to remove.

Raises:
  • IndexError – If the step index does not exist.

  • KeyError – If the step name does not exist.

print_step_details()#

Prints the details of all steps in the container.

__str__() str#

Returns a detailed string representation of the StepsContainer instance.

Returns:

str – A string describing the steps-container, including its name, and the names of the sequence of steps.

__call__()#

Executes all steps in the container in sequence.

__getitem__(step: int | str)#

Gets a step from the container by index or name.

Parameters:

step (Union[int, str]) – The index or name of the step to get.

Returns:

StepType – The requested step.

Raises:
  • IndexError – If the step index does not exist.

  • KeyError – If the step name does not exist.

  • TypeError – If the key is not an integer or string.

__add__(other: StepsContainer) StepsContainer#

Combines this StepsContainer with another one. The other container cannot have steps with the same name.

Parameters:

other (StepsContainer) – The other steps container to combine with.

Returns:

StepsContainer – A new StepsContainer containing steps from both containers.

Raises:
  • TypeError – If the other object is not a StepsContainer.

  • KeyError – If a step with the same name already exists.

classmethod default_preprocess_steps(name: str = 'preproc')#

Creates a default StepsContainer with common preprocessing steps.

We have the following steps in sequence:
Parameters:

name (str, optional) – Name of the steps container. Defaults to ‘preproc’.

Returns:

StepsContainer – A new StepsContainer with default preprocessing steps.

classmethod default_graphical_analysis_steps(name: str = 'km_graphical_analysis')#

Creates a default StepsContainer with common graphical analysis steps.

We have the following steps in sequence:
Parameters:

name (str, optional) – Name of the steps container. Defaults to ‘km_graphical_analysis’.

Returns:

StepsContainer – A new StepsContainer with default graphical analysis steps.

Notes

The steps do not technically depend on each other and can be run out of sequence.

classmethod default_parametric_graphical_analysis_steps(name: str = 'km_parametric_graphical_analysis')#

Creates a default StepsContainer with common parametric graphical analysis steps.

We have the following steps in sequence:
Parameters:

name (str, optional) – Name of the steps container. Defaults to ‘km_parametric_graphical_analysis’.

Returns:

StepsContainer – A new StepsContainer with default parametric graphical analysis steps.

Notes

The steps do not technically depend on each other and can be run out of sequence.

classmethod default_tcm_analysis_steps(name: str = 'km_tcm_analysis')#

Creates a default StepsContainer with common TCM analysis steps.

We have the following steps in sequence:
Parameters:

name (str, optional) – Name of the steps container. Defaults to ‘km_tcm_analysis’.

Returns:

StepsContainer – A new StepsContainer with default TCM analysis steps.

classmethod default_kinetic_analysis_steps(name: str = 'km')#

Creates a default StepsContainer with common kinetic analysis steps.

We have the following steps in sequence:
Parameters:

name (str, optional) – Name of the steps container. Defaults to ‘km’.

Returns:

StepsContainer – A new StepsContainer with default kinetic analysis steps.

Notes

The steps do not technically depend on each other and can be run out of sequence.