Skip to content

Workflow

Fluent DAG builder. Every wf.<type>(...) call creates a Node, registers it on the workflow, and returns the Node for chaining with >>.

A workflow is serialized to the backend's workflow_data shape via to_workflow_data() and executed remotely via deploy() / deploy_and_run() (both call the deployed nexus-backend over HTTP).

nodes property

nodes

Read-only view of nodes in insertion order.

connections property

connections

Read-only view of edges in insertion order.

trigger

trigger(trigger)

Attach a Trigger. Last call wins.

set_variable

set_variable(name, value)

Set a workflow-scoped variable referenced via {{ name }}.

add_node

add_node(*, name, node_type, category, configuration=None)

Generic escape hatch when no typed helper exists for a node type. Prefer the typed helpers (wf.postgres, wf.ai_tagging, ...) when available.

connect

connect(source, target)

Add an edge explicitly. Equivalent to source >> target.

to_workflow_data

to_workflow_data()

Return the internal schema consumed by the engine / API.

validate

validate()

Dry-run structural checks on the workflow.

Returns a list of human-readable error messages. An empty list means the workflow looks structurally valid; deploying it may still fail server-side validation (connection strings, credentials, etc.) but the shape is consistent.

Checks performed
  • No node has an empty name or duplicate name.
  • Every edge references a node that belongs to this workflow.
  • At least one terminal (no outgoing edge) node exists.
  • No cycles in the DAG.
  • Unknown nodes referenced in an expr.node('Name') expression inside any node's configuration surface as warnings.

visualize

visualize(*, fmt='mermaid')

Render the DAG as a string.

fmt="mermaid" (default) produces a flowchart LR block that renders natively in GitHub Markdown and Jupyter notebooks. fmt="ascii" produces a simple a -> b edge listing for terminals and quick diffs.

assert_valid

assert_valid()

Raise :class:WorkflowBuildError if :meth:validate returns issues.

to_json

to_json(*, indent=2)

Serialize the workflow to a JSON string.

Round-trips with Workflow.from_json(). Useful for version control, diffing, and cross-language export.

to_yaml

to_yaml()

Serialize the workflow to YAML.

Requires the [yaml] extra: pip install athena-sdk[yaml].

from_workflow_data classmethod

from_workflow_data(data)

Reconstruct a Workflow from a workflow_data dict.

Inverse of :meth:to_workflow_data. Node objects are re-created by name and wired via the same connection list — back-end-assigned node ids do not survive the round trip (they are regenerated on the next deploy).

from_json classmethod

from_json(payload)

Parse a JSON string produced by :meth:to_json back into a Workflow.

from_yaml classmethod

from_yaml(payload)

Parse a YAML string produced by :meth:to_yaml back into a Workflow.

Requires the [yaml] extra.

run

run()

Execute the workflow in-process via the bundled nexus-backend engine.

run_async async

run_async()

Async variant of run(). Uses the same in-process engine.

deploy

deploy()

Push the workflow to a deployed nexus-backend. Returns the workflow id.

deploy_and_run

deploy_and_run()

Deploy to a hosted nexus-backend + trigger + block until complete.