Skip to content

Composite step

Base class for composite pipeline steps using Template Method pattern.

This module centralizes recursive operations common to all composite steps, including mermaid diagram generation, retry policy propagation, and error handling.

Author

Kadek Denaya (kadek.d.r.diana@gdplabs.id)

References

NONE

BaseCompositeStep(name, retry_config=None, error_handler=None, cache_store=None, cache_config=None)

Bases: BasePipelineStep, ABC

Base class for all composite pipeline steps.

Attributes:

Name Type Description
name str

A unique identifier for the pipeline step.

retry_policy RetryPolicy | None

Configuration for retry behavior using LangGraph's RetryPolicy.

Initialize the composite step.

Parameters:

Name Type Description Default
name str

A unique identifier for the pipeline step.

required
retry_config RetryConfig | None

Configuration for retry behavior. Defaults to None.

None
error_handler BaseStepErrorHandler | None

Strategy to handle errors during execution.

None
cache_store 'BaseCache' | None

Cache store to be used for caching. Defaults to None, in which case no cache store is used.

None
cache_config dict[str, Any] | None

Cache configuration to be used for caching. Defaults to None, in which case no cache configuration is used.

None

add_to_graph(graph, previous_endpoints, retry_policy=None)

Template method: Add this composite step to the graph.

Parameters:

Name Type Description Default
graph StateGraph

The graph to add this step to.

required
previous_endpoints list[str]

Endpoints from previous steps to connect to.

required
retry_policy RetryPolicy | None

Retry policy to use for this step and propagate to child steps. If provided, takes precedence over the step's own retry policy. Defaults to None, in which case the step's own retry policy is used.

None

Returns:

Type Description
list[str]

list[str]: Exit points after adding all child steps

apply_exclusions(exclusions) abstractmethod

Apply exclusions to this composite step and its children.

Subclasses must implement full exclusion behavior, including any internal structure updates and propagation to children.

Parameters:

Name Type Description Default
exclusions 'ExclusionSet'

The exclusion set to apply.

required

Raises:

Type Description
NotImplementedError

If not implemented by subclass.

get_mermaid_diagram()

Template method: Generate complete mermaid diagram.

Returns:

Name Type Description
str str

Complete mermaid diagram representation.