httomo.runner.method_wrapper.MethodWrapper#

class httomo.runner.method_wrapper.MethodWrapper(*args, **kwargs)[source]#

Interface for method wrappers, that is used by the pipeline and task runners to execute methods in a generic way.

Methods

__init__(*args, **kwargs)

append_config_params(params)

Appends to the configuration parameters all values that are in the given dictionary

calculate_max_slices(data_dtype, ...)

If it runs on GPU, determine the maximum number of slices that can fit in the available memory in bytes, and return a tuple of

calculate_output_dims(non_slice_dims_shape)

Calculate the dimensions of the output for this method

calculate_padding()

Calculate the padding required by the method

execute(block)

Execute the method.

get_side_output()

Override this method for functions that have a side output.

Attributes

comm

The MPI communicator used

config_params

Access a copy of the configuration parameters (cannot be modified directly)

cupyrun

True if method runs on GPU and expects a CuPy array as inputs

gpu_time

Get the time spent on GPU in the last call to execute

implementation

Implementation of this method

is_cpu

True if this is a CPU-only method

is_gpu

True if this is a GPU method

memory_gpu

Memory requirements for GPU execution

method

The actual method underlying this wrapper

method_name

Returns the name of the method function

module_path

Returns the full module path where the method function is defined

output_dims_change

Whether output dimensions change after executing this method

package_name

The name of the top-level package where this method is implementated, e.g. 'httomolib'.

padding

Determine if the method needs padding

parameters

List of parameter names of the underlying method

recon_algorithm

Determine the recon algorithm used, if the method is reconstruction.

save_result

Whether to save the result of this method to intermediate files

sweep

Determine if the method performs sweep

task_id

pattern

append_config_params(params: Dict[str, str | bool | int | float | PathLike | ndarray | cupy.ndarray | List[str | bool | int | float | PathLike | ndarray | cupy.ndarray]])[source]#

Appends to the configuration parameters all values that are in the given dictionary

calculate_max_slices(data_dtype: dtype, non_slice_dims_shape: Tuple[int, int], available_memory: int) Tuple[int, int][source]#

If it runs on GPU, determine the maximum number of slices that can fit in the available memory in bytes, and return a tuple of

(max_slices, available_memory)

The available memory may have been adjusted for the methods that follow, in case something persists afterwards.

calculate_output_dims(non_slice_dims_shape: Tuple[int, int]) Tuple[int, int][source]#

Calculate the dimensions of the output for this method

calculate_padding() Tuple[int, int][source]#

Calculate the padding required by the method

property comm: mpi4py.MPI.Comm#

The MPI communicator used

property config_params: Dict[str, Any]#

Access a copy of the configuration parameters (cannot be modified directly)

property cupyrun: bool#

True if method runs on GPU and expects a CuPy array as inputs

execute(block: T) T[source]#

Execute the method.

Parameters:

block (T (implements Block)) – A numpy or cupy dataset, mutable (method might work in-place).

Returns:

A CPU or GPU-based dataset object with the output

Return type:

T (implements Block)

get_side_output() Dict[str, Any][source]#

Override this method for functions that have a side output. The returned dictionary will be merged with the dict_params parameter passed to execute for all methods that follow in the pipeline

property gpu_time: GpuTimeInfo#

Get the time spent on GPU in the last call to execute

property implementation: Literal['gpu', 'cpu', 'gpu_cupy']#

Implementation of this method

property is_cpu: bool#

True if this is a CPU-only method

property is_gpu: bool#

True if this is a GPU method

property memory_gpu: GpuMemoryRequirement | None#

Memory requirements for GPU execution

property method: Callable#

The actual method underlying this wrapper

property method_name: str#

Returns the name of the method function

property module_path: str#

Returns the full module path where the method function is defined

property output_dims_change: bool#

Whether output dimensions change after executing this method

property package_name: str#

The name of the top-level package where this method is implementated, e.g. ‘httomolib’

property padding: bool#

Determine if the method needs padding

property parameters: List[str]#

List of parameter names of the underlying method

pattern: Pattern#
property recon_algorithm: str | None#

Determine the recon algorithm used, if the method is reconstruction. Otherwise return None.

property save_result: bool#

Whether to save the result of this method to intermediate files

property sweep: bool#

Determine if the method performs sweep

task_id: str#