# Exporting a Ray builder graph

Take a graph out of the Ray DAG Builder as a standalone Python module, a Ray Job script, a cron wrapper, a multi-cell notebook, a Mermaid diagram or a Ray Serve config, and what each export refuses.

Source: https://docs.eugo.io/docs/platform/ray-builder-exports/

---

Besides writing code into a notebook cell, the [visual Ray builder](/docs/platform/ray-builder.md) can export a graph as files: a standalone Python module, a Ray Job script, a cron wrapper, a multi-cell notebook, a diagram or a Ray Serve config.

> **Applies to:** the EugoLab image, November 2026.

Every export writes its files next to the notebook and names them after the notebook's file name, written `<stem>` on this page: a notebook `analysis.ipynb` exports `analysis_dag.py`, and so on.

## Before you export

- **Save the notebook.** An unsaved notebook has no file name, so the exports have nowhere to write.
- **Fix the graph's errors.** Exports are blocked, like **Emit**, while the sidebar lists problems.

## The exports at a glance

| Button or command | Writes | Graph target |
|---|---|---|
| **Export .py** (**Ray DAG: Export as .py module**) | `<stem>_dag.py` | Any graph |
| **Export Job** (**Ray DAG: Export as Ray Job**) | `<stem>_dag.py` and `<stem>_submit.sh` | Ray Core / Data |
| **Schedule…** (**Ray DAG: Export as scheduled job (cron)**) | `<stem>_dag.py` and `<stem>_cron.sh` | Ray Core / Data |
| **Export cells** (**Ray DAG: Export as multi-cell notebook**) | `<stem>_dag.ipynb` | Any graph |
| **Ray DAG: Export as Mermaid diagram** | `<stem>_dag.mmd` | Any graph |
| **Ray DAG: Export Serve config (serve build)** | `<stem>_serve_config.yaml` | Ray Serve |

## A standalone .py module

Click **Export .py** ("Export the graph as a standalone .py module next to the notebook"). The builder writes `<stem>_dag.py`, a Python module you can run on its own.

The module copies in the notebook cells that define the functions your nodes use. The file's header states what it does not copy:

- helpers defined in other cells that no node refers to;
- notebook variables, such as a data frame built in an earlier cell;
- notebook magics, which are commented out.

## A Ray Job script

1. Optional: run **Ray DAG: Configure Ray Job (entrypoint resources)…** to reserve CPUs, GPUs, memory or custom resources for the job's driver, and add metadata. This changes only the exported job, not the code in the cell.
2. Click **Export Job** ("Export the .py module + a runnable ray-job-submit script next to the notebook"). The builder writes `<stem>_dag.py` and `<stem>_submit.sh`.

`<stem>_submit.sh` submits the module with Ray's job CLI, uploading the notebook's folder as the job's working directory: `ray job submit --address <addr> --working-dir . -- python <stem>_dag.py`.

If the header's **Ship working dir** checkbox (a runtime environment `working_dir`) is on, it clashes with that upload, and the script's header warns you. A job's other runtime environment settings, such as `pip` packages or environment variables, are fine.

## A scheduled job (cron)

1. Click **Schedule…** ("Export the .py module + a cron wrapper (you install the schedule with crontab -e)").
2. Enter a 5-field cron expression: minute, hour, day, month and weekday. Shortcuts such as `@daily` are not accepted.
3. The builder writes `<stem>_dag.py` and `<stem>_cron.sh` and shows the line to add to your crontab: "Install the schedule with `crontab -e` (set PATH= + the absolute path first): &lt;line&gt;".

The builder does not schedule anything itself: you install the line on the machine that should run the job.

## A multi-cell notebook

Click **Export cells** ("Export the graph as a runnable multi-cell notebook (one cell per stage) next to the notebook"). The builder writes `<stem>_dag.ipynb`, with one cell per stage of the graph and the functions your nodes use copied in. Its inputs cell carries the `parameters` tag that papermill reads. Bind-mode, Serve, Train and Tune graphs come out as a single cell.

### Authoring across cells in this notebook

To spread the graph across the cells of the notebook you are in, instead of a separate file, click **Cells: off** so that it reads **Cells: on** ("Toggle in-place multi-cell authoring: emit the graph across one cell per stage in this notebook (manual emit)"). The builder then owns one cell per stage. As you edit the graph, it updates those cells in place; when a change adds, removes or reorders stages, the cells change at your next **Emit**. Click **Cells: on** to go back to a single cell.

## A Mermaid diagram

Run **Ray DAG: Export as Mermaid diagram** from the command palette. The builder writes `<stem>_dag.mmd`, a text diagram of the graph that Mermaid renders.

## A Ray Serve config

With a Ray Serve graph, run **Ray DAG: Export Serve config (serve build)** from the command palette. It needs a Serve graph with at least one deployment. The builder writes `<stem>_serve_config.yaml` and says: "Wrote &lt;file&gt;. Deploy with: serve deploy &lt;file&gt;. Edit import_path (see the file header) and review before deploy."

Edit `import_path` as the file's header describes, and review the file before you deploy it.

## Serve graphs and job exports

A Serve application keeps running, so a job that starts one never finishes. **Export Job**, **Submit Job** and **Schedule…** therefore refuse a Serve graph:

- "Ray Job export is not available for a Serve graph — serve.run is long-lived and would hang the job. Export .py and run it (or serve.run) directly."
- "Ray Job submit is not available for a Serve graph — serve.run is long-lived and would hang the job."
- "Scheduled export is not available for a Serve graph — serve.run is long-lived and a recurring job would hang. Export .py and run it directly."

For a Serve graph, use **Export .py** or the Serve config export.

## Checking the code before you export

**Check syntax** parses the generated Python in the notebook's kernel. The setting **Check syntax before emit** does the same at every emit, and **Format emitted code (black, in kernel)** formats the code at every emit; both are off by default (see [Settings](/docs/platform/ray-builder-reference.md#settings)).

## Related

- [Visual Ray builder](/docs/platform/ray-builder.md): how a graph becomes code.
- [Ray builder reference](/docs/platform/ray-builder-reference.md): every button, setting and shortcut.
- [Ray builder troubleshooting](/docs/platform/ray-builder-troubleshooting.md).
