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 the padding required by the method
execute
(block)Execute the method.
Override this method for functions that have a side output.
Attributes
The MPI communicator used
Access a copy of the configuration parameters (cannot be modified directly)
True if method runs on GPU and expects a CuPy array as inputs
Get the time spent on GPU in the last call to execute
Implementation of this method
True if this is a CPU-only method
True if this is a GPU method
Memory requirements for GPU execution
The actual method underlying this wrapper
Returns the name of the method function
Returns the full module path where the method function is defined
Whether output dimensions change after executing this method
The name of the top-level package where this method is implementated, e.g. 'httomolib'.
Determine if the method needs padding
List of parameter names of the underlying method
Determine the recon algorithm used, if the method is reconstruction.
Whether to save the result of this method to intermediate files
Determine if the method performs sweep
- 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
- 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
- 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#