Skip to content

common_flows

Canonical chain flows for the standard worker workloads.

These builders are the single construction point for the flows a worker routes internally. Stage boundaries are expressed as generation-progress states, so a ChainExecutionContext over one of these flows can be driven entirely by advance_for_progress.

GENERATE_STAGE_NAME module-attribute

GENERATE_STAGE_NAME = 'generate'

POST_PROCESS_STAGE_NAME module-attribute

POST_PROCESS_STAGE_NAME = 'post_process'

SAFETY_CHECK_STAGE_NAME module-attribute

SAFETY_CHECK_STAGE_NAME = 'safety_check'

SUBMIT_STAGE_NAME module-attribute

SUBMIT_STAGE_NAME = 'submit'

image_generation_flow

image_generation_flow(
    *,
    post_processing: bool,
    safety_check: bool,
    submit: bool = True
) -> ChainFlow

Build the flow for an image generation unit of work.

Parameters:

  • post_processing (bool) –

    Whether the work includes a post-processing stage.

  • safety_check (bool) –

    Whether the work includes a safety-check stage.

  • submit (bool, default: True ) –

    Whether the work includes a submit stage. Defaults to True.

Returns:

  • ChainFlow ( ChainFlow ) –

    generate -> (post_process) -> (safety_check) -> (submit).

Source code in horde_sdk/worker/chaining/common_flows.py
def image_generation_flow(
    *,
    post_processing: bool,
    safety_check: bool,
    submit: bool = True,
) -> ChainFlow:
    """Build the flow for an image generation unit of work.

    Args:
        post_processing (bool): Whether the work includes a post-processing stage.
        safety_check (bool): Whether the work includes a safety-check stage.
        submit (bool, optional): Whether the work includes a submit stage. Defaults to True.

    Returns:
        ChainFlow: generate -> (post_process) -> (safety_check) -> (submit).
    """
    stages = [_generate_stage()]
    if post_processing:
        stages.append(_post_process_stage())
    if safety_check:
        stages.append(_safety_check_stage())
    if submit:
        stages.append(_submit_stage())
    return _build_linear_flow(stages)

alchemy_flow

alchemy_flow(
    *, safety_check: bool = False, submit: bool = True
) -> ChainFlow

Build the flow for a standalone alchemy (post-processing) unit of work.

Parameters:

  • safety_check (bool, default: False ) –

    Whether the work includes a safety-check stage. Defaults to False.

  • submit (bool, default: True ) –

    Whether the work includes a submit stage. Defaults to True.

Returns:

  • ChainFlow ( ChainFlow ) –

    post_process -> (safety_check) -> (submit).

Source code in horde_sdk/worker/chaining/common_flows.py
def alchemy_flow(
    *,
    safety_check: bool = False,
    submit: bool = True,
) -> ChainFlow:
    """Build the flow for a standalone alchemy (post-processing) unit of work.

    Args:
        safety_check (bool, optional): Whether the work includes a safety-check stage. Defaults to False.
        submit (bool, optional): Whether the work includes a submit stage. Defaults to True.

    Returns:
        ChainFlow: post_process -> (safety_check) -> (submit).
    """
    stages = [_post_process_stage()]
    if safety_check:
        stages.append(_safety_check_stage())
    if submit:
        stages.append(_submit_stage())
    return _build_linear_flow(stages)

text_generation_flow

text_generation_flow(
    *, safety_check: bool = False, submit: bool = True
) -> ChainFlow

Build the flow for a text generation unit of work.

Parameters:

  • safety_check (bool, default: False ) –

    Whether the work includes a safety-check stage. Defaults to False.

  • submit (bool, default: True ) –

    Whether the work includes a submit stage. Defaults to True.

Returns:

  • ChainFlow ( ChainFlow ) –

    generate -> (safety_check) -> (submit).

Source code in horde_sdk/worker/chaining/common_flows.py
def text_generation_flow(
    *,
    safety_check: bool = False,
    submit: bool = True,
) -> ChainFlow:
    """Build the flow for a text generation unit of work.

    Args:
        safety_check (bool, optional): Whether the work includes a safety-check stage. Defaults to False.
        submit (bool, optional): Whether the work includes a submit stage. Defaults to True.

    Returns:
        ChainFlow: generate -> (safety_check) -> (submit).
    """
    stages = [_generate_stage()]
    if safety_check:
        stages.append(_safety_check_stage())
    if submit:
        stages.append(_submit_stage())
    return _build_linear_flow(stages)