Skip to content

Sequential Strategy¤

Chain operators to execute one after another.

See Also¤


datarax.operators.strategies.sequential ¤

Sequential composition strategies.

logger module-attribute ¤

logger = getLogger(__name__)

SequentialStrategy ¤

Bases: CompositionStrategyImpl

Applies operators in sequence (chain).

apply ¤

apply(operators: list[OperatorModule], context: StrategyContext) -> tuple[PyTree, PyTree, dict[str, Any]]

Apply operators sequentially, piping each output to the next.

Parameters:

Name Type Description Default
operators list[OperatorModule]

Ordered list of operators to chain.

required
context StrategyContext

Execution context with input data, state, and RNG params.

required

Returns:

Type Description
tuple[PyTree, PyTree, dict[str, Any]]

Tuple of (data, state, metadata) after all operators have run.

describe ¤

describe() -> dict[str, Any]

Return a serializable description of this strategy.

ConditionalSequentialStrategy ¤

ConditionalSequentialStrategy(conditions: Sequence[Callable[[PyTree], bool | Array]])

Bases: CompositionStrategyImpl

Applies operators sequentially with conditions.

Only applies operators where condition evaluates to True.

Parameters:

Name Type Description Default
conditions Sequence[Callable[[PyTree], bool | Array]]

List of callables that determine whether each operator is applied.

required

conditions instance-attribute ¤

conditions = conditions

apply ¤

apply(operators: list[OperatorModule], context: StrategyContext) -> tuple[PyTree, PyTree, dict[str, Any]]

Apply operators sequentially, skipping those whose condition is False.

Uses jax.lax.cond for vmap-compatible conditional execution.

Parameters:

Name Type Description Default
operators list[OperatorModule]

Operators to apply (must match length of conditions).

required
context StrategyContext

Execution context with input data, state, and RNG params.

required

Returns:

Type Description
tuple[PyTree, PyTree, dict[str, Any]]

Tuple of (data, state, metadata) after conditional execution.

Raises:

Type Description
ValueError

If operator count doesn't match condition count.

describe ¤

describe() -> dict[str, Any]

Return a serializable description of this strategy.