Repository navigation
Commit 95fc2e4
feat(dag-viewer): standalone Python render + animated transitions (#255)
* feat(dag-viewer): standalone Python render + animated transitions
Adds a headless/no-browser path for tools/dag-viewer, on top of #249's
Compare/Union modes:
- `render.py` bakes a dag_export WorkloadGraph JSON (or several, merged
the same way index.html's multi-file drop does) into one self-contained
HTML file — every vendored script and the query data inlined, so it
opens directly with no server and no drag-and-drop. index.html's own
fetch('dag.json') convenience is blocked as cross-origin by most
browsers over file://; embedding sidesteps that too, not just the
no-browser case. `--mode compare|union` opens the page straight into
that view with every loaded query pre-selected.
- Extracted index.html's inline <script> into `viewer.js`, unchanged
apart from the additions below, so index.html and render.py's output
share one copy of the interaction logic instead of forking it.
- Mode switches, the shared-subtree ring, and initial layout now animate
(dagre's `animate: true`, a `transition-property` on node/edge style so
class toggles ease instead of snap, and a fade-in on newly built
elements) rather than hard-cutting to a new static layout on every
render() call.
- `test_render.py` unit-tests render.py's merge/inline/escape logic
(plain unittest.TestCase, matching tools/clickhouse's convention; not
wired into CI, same as that tool).
Query cost isn't rendered — dag_export doesn't emit one yet (no cost
estimator wired into pre-ASAP IR). The side panel dumps a clicked node's
`detail` verbatim, so a future `cost` field there needs no viewer change.
Stacked on #249 (targets that branch, not main, until it merges) — see
issue #186 and PR #249's description for the Compare/Union groundwork
this builds on.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(dag-viewer): correct test_render.py's run instructions
python3 -m unittest tools/dag-viewer/test_render.py doesn't actually work
run from the repo root -- unittest resolves the file-path form to a bare
'test_render' module but never adds tools/dag-viewer/ to sys.path, so the
file's own 'from render import ...' fails with ModuleNotFoundError. Same
latent bug exists in tools/clickhouse/test_extract_functions.py's docs
(copied from there), left alone since it's pre-existing and out of scope
here.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(dag-viewer): clean error messages for render.py's bad-input paths
A nonexistent input file or malformed JSON crashed with a raw Python
traceback (FileNotFoundError / json.JSONDecodeError propagating straight
out of main()) instead of a one-line stderr message + exit 1, matching
the existing 'no queries in input' / '--mode needs 2+ queries' style.
Found by actually running every command tools/dag-viewer's docs mention,
end to end, including through a real cargo-built dag_export.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(dag-viewer): reverse edge arrow direction to data-flow order
Structural edges pointed from a node to its children (parent -> child,
i.e. output -> its input), which is backwards for a data-flow diagram:
an arrowhead should point at the consumer, not the input. Swap
source/target for the edges built in all three view modes
(single/compare/union) so arrows now run input -> consumer, matching
the top-to-bottom dagre layout (scans at top, query root at bottom).
Addresses review feedback on #255.
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>1 parent 7e5afa8 commit 95fc2e4
6 files changed
Lines changed: 1225 additions & 764 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
41 | 76 | | |
42 | 77 | | |
43 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
60 | 70 | | |
61 | 71 | | |
62 | 72 | | |
| |||
0 commit comments