Python class
Pipeline
Pipeline
class max.interfaces.Pipeline
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
passexecute()
abstract execute(inputs)
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
RequestIDto pipeline output objects. -
Raises:
-
NotImplementedError – If not implemented by a concrete subclass.
-
Return type:
release()
abstract release(request_id)
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
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!