Skip to main content

Export a workflow to Python

Any graph can become a plain Python script, so a workflow you built visually can run without EdgeWeave: on a server, in a notebook, in a scheduled job, or in a pipeline you already have. The script is ordinary code you can read, edit and keep in version control.

Export a graph​

  1. Open the workflow tab you want to export. The active tab is the one that is exported.
  2. Press Export to Python in the toolbar.
  3. A window shows the generated script. Copy it, or use the download button to save it as workflow.py.

What the script looks like​

The script has three parts:

  1. Imports and helper functions the nodes need, each emitted once. These are the same functions the nodes use when they run in EdgeWeave, so the exported script computes what the node previews showed.
  2. One statement per node, in run order. Each result is a variable named after its node, for example node_7 = ml_evaluate(node_6, node_4, 'test').
  3. Sticky notes become comments, in the place they were in the graph.

Run it like any script:

python workflow.py

The script runs the whole graph but only prints what your graph tells it to. A Print / Debug node prints its input. To inspect any other result, add a print(node_7) yourself, or run the script in a notebook or IDE and look at the variables.

The script needs the Python packages the nodes use (pandas, scikit-learn, and so on). Install them into the environment you run it in.

Credentials stay out of the script​

Passwords, tokens and API keys typed into node fields are not written into the export. The script reads them from environment variables instead (for example PGPASSWORD for a PostgreSQL password). Set them where the script runs.

Custom and third-party nodes​

Every node that ships with EdgeWeave exports. A node you write yourself, or one from a marketplace module, exports only if its author described how, with the codegen option of @node. Without it the node is exported as a pass-through with a warning. A node whose author states it cannot be exported writes a comment explaining why and raises NotImplementedError when the script reaches it, so a missing piece is never silent.

Each node's page in the node reference says whether it supports Python export, and so does the right-click documentation in the editor.

Subsystems and loops​

A subsystem exports as a Python function, and the node that calls it exports as a call to that function. For-loops on the canvas (control flow) export as for loops.

Export a dashboard instead​

If you want to share results rather than code, see Export a dashboard.