Code Editor & Round-trip

Switch to code view at any time to edit the .py file directly in a CodeMirror 6 editor, with syntax highlighting and import validation. Split mode shows canvas and code side by side.

The round-trip invariant

DagSmith parses your file with libcst(a lossless concrete syntax tree for Python), never the standard astmodule for anything that touches your source. The core guarantee:

codegen(parse(source)) == source, byte-for-byte, whenever the graph hasn't changed.

When you do change something on the canvas, DagSmith doesn't regenerate the whole file — it applies a targeted, kwarg-level edit to just the statement that changed, so a one-field parameter tweak on a hand-written DAG produces a one-line diff, not a reformatted file.

Validation before deploy

Before a draft can be deployed, DagSmith validates it in two stages, both outside the api-server process:

  • A fast syntax/AST check.
  • A full DagBag import, executed in an isolated, time-limited subprocess — never eval/exec/importlib on your source in-process.

Deploying safely

Deploy writes the file atomically (temp file + os.replace), takes a backup first, and checks the file hasn't changed since you opened the draft — a 409 conflict shows a diff so you can resolve it instead of silently overwriting someone else's change. A Load from bundle button lets you pull the currently deployed file back into your draft at any time (with a confirmation, since it discards draft-only changes).