aw.orchestration

Orchestration and workflow management for agentic steps.

Provides utilities to chain multiple agentic steps together and manage the overall workflow.

Functions

create_cosmo_prep_workflow([...])

Create a workflow specifically for cosmograph preparation.

create_data_prep_workflow([loading_config, ...])

Factory to create a data preparation workflow.

load_and_prepare(source_uri[, target, ...])

Convenience function to load and prepare data in one call.

load_for_cosmo(source_uri[, max_retries, strict])

Load and prepare data specifically for cosmograph visualization.

Classes

AgenticWorkflow([context])

Orchestrates a chain of agentic steps.

InteractiveWorkflow([context])

Workflow with human-in-the-loop capabilities.

class aw.orchestration.AgenticWorkflow(context=None)[source]

Bases: object

Orchestrates a chain of agentic steps.

Manages the execution of multiple steps in sequence, handling context/artifact passing between steps.

Example

>>> workflow = AgenticWorkflow()
>>> workflow.add_step('loading', loading_agent)
>>> workflow.add_step('preparing', preparing_agent)
>>> result = workflow.run(source_uri)
add_step(name, step)[source]

Add a step to the workflow.

Parameters:
  • name (str) – Name/identifier for the step

  • step (AgenticStep) – Agent or step implementation

Return type:

AgenticWorkflow

Returns:

Self for chaining

run(initial_input)[source]

Execute the workflow.

Parameters:

initial_input (Any) – Input to the first step

Return type:

tuple[Any, dict[str, Any]]

Returns:

Tuple of (final_artifact, workflow_metadata)

run_partial(initial_input, stop_after=None)[source]

Run workflow up to a specific step.

Parameters:
  • initial_input (Any) – Input to first step

  • stop_after (str) – Name of step to stop after (runs all if None)

Return type:

tuple[Any, dict[str, Any]]

Returns:

Tuple of (artifact, metadata)

class aw.orchestration.InteractiveWorkflow(context=None)[source]

Bases: AgenticWorkflow

Workflow with human-in-the-loop capabilities.

Pauses execution to request human input/approval at configured points.

Example

>>> workflow = InteractiveWorkflow()
>>> workflow.add_step('loading', agent, require_approval=True)
>>> result = workflow.run_interactive(source_uri)
add_step(name, step, require_approval=False)[source]

Add step with optional approval requirement.

Return type:

InteractiveWorkflow

run_interactive(initial_input)[source]

Run workflow with human-in-loop checkpoints.

Return type:

tuple[Any, dict]

set_approval_callback(callback)[source]

Set callback for human approval.

Parameters:

callback (Callable[[str, Any, dict], bool]) – Function(step_name, artifact, metadata) -> bool Returns True to continue, False to abort

Return type:

None

aw.orchestration.create_cosmo_prep_workflow(cosmo_validator=None, max_retries=3)[source]

Create a workflow specifically for cosmograph preparation.

Parameters:
  • cosmo_validator (Callable) – Custom cosmo validator (uses default if None)

  • max_retries (int) – Maximum retries for each step

Return type:

AgenticWorkflow

Returns:

Configured workflow

Example

>>> workflow = create_cosmo_prep_workflow()
>>> prepared_df, metadata = workflow.run('data.csv')
aw.orchestration.create_data_prep_workflow(loading_config=None, preparing_config=None, target='generic')[source]

Factory to create a data preparation workflow.

Creates a workflow with LoadingAgent -> PreparationAgent.

Parameters:
  • loading_config (StepConfig) – Configuration for loading agent

  • preparing_config (StepConfig) – Configuration for preparing agent

  • target (str) – Target format for preparation

Return type:

AgenticWorkflow

Returns:

Configured workflow

Example

>>> workflow = create_data_prep_workflow(target='cosmo-ready')
>>> df, metadata = workflow.run('/path/to/data.csv')
aw.orchestration.load_and_prepare(source_uri, target='generic', validator=None, max_retries=3)[source]

Convenience function to load and prepare data in one call.

Parameters:
  • source_uri (str) – URI of data source

  • target (str) – Target format/purpose

  • validator (Callable) – Optional custom validator

  • max_retries (int) – Maximum retry attempts

Return type:

tuple[Any, dict]

Returns:

Tuple of (prepared_dataframe, metadata)

Example

>>> df, meta = load_and_prepare('data.csv', target='cosmo-ready')
aw.orchestration.load_for_cosmo(source_uri, max_retries=3, strict=False)[source]

Load and prepare data specifically for cosmograph visualization.

Parameters:
  • source_uri (str) – URI of data source

  • max_retries (int) – Maximum retry attempts

  • strict (bool) – If True, actually calls cosmograph for validation

Return type:

tuple[Any, dict]

Returns:

Tuple of (prepared_dataframe, metadata)

Example

>>> df, meta = load_for_cosmo('data.csv')
>>> from cosmograph import cosmo
>>> cosmo(df, **meta['preparing']['metadata']['validation_result']['params'])