Skip to main content

Python class

Pipeline

Pipeline

class max.interfaces.Pipeline

source

Bases: Generic[PipelineInputsType, PipelineOutputType], ABC

Defines the interface for pipeline operations.

This generic abstract class defines the interface for pipeline operations that transform inputs of type PipelineInputsType into outputs of type PipelineOutputsDict[PipelineOutputType]. All concrete pipeline implementations must inherit from this class and implement the execute() method.

class MyPipeline(Pipeline[MyInputs, MyOutput]):
    def execute(self, inputs: MyInputs) -> dict[RequestID, MyOutput]:
        # Implementation here
        pass

execute()

abstract execute(inputs)

source

Executes the pipeline operation with the given inputs.

This method must be implemented by all concrete pipeline classes. It takes inputs of the specified type and returns outputs according to the pipeline’s processing logic.

Parameters:

inputs (PipelineInputsType) – The input data for the pipeline operation.

Returns:

A dictionary mapping RequestID to pipeline output objects.

Raises:

NotImplementedError – If not implemented by a concrete subclass.

Return type:

dict[RequestID, PipelineOutputType]

release()

abstract release(request_id)

source

Releases any resources or state associated with a specific request.

This method should be implemented by concrete pipeline classes to perform cleanup or resource deallocation for the given request ID. It is typically called when a request has completed processing and its associated resources (such as memory, cache, or temporary files) are no longer needed.

Parameters:

request_id (RequestID) – The unique identifier of the request to release resources for.

Raises:

NotImplementedError – If not implemented by a concrete subclass.

Return type:

None