Closes #541: GRAPHIFY_NO_VIZ + GRAPHIFY_VIZ_NODE_LIMIT env vars#542
Closes #541: GRAPHIFY_NO_VIZ + GRAPHIFY_VIZ_NODE_LIMIT env vars#542saxster wants to merge 1 commit intosafishamsi:v5from
Conversation
Closes safishamsi#541. The post-commit hook calls _rebuild_code in watch.py. v0.5.0 catches ValueError from to_html (the >5000-node guard fires inside the visualization step itself), but on large graphs the hook still pays the full to_html attempt before the guard rejects. Two new opt-outs let users skip the attempt entirely: - GRAPHIFY_NO_VIZ=1 — unconditional skip; for CI runners and headless dev boxes that never open graph.html. - GRAPHIFY_VIZ_NODE_LIMIT=N — soft cap; skip when node count exceeds N. GRAPHIFY_NO_VIZ takes priority. Both default to off, preserving current behavior. Pre-existing ValueError catch stays as a backstop. 7 new tests cover: defaults off, NO_VIZ truthy/falsy values, NODE_LIMIT threshold (one below, equal, one above), invalid (non-int) NODE_LIMIT silently treated as unset, NO_VIZ priority over NODE_LIMIT.
There was a problem hiding this comment.
Pull request overview
Adds environment-variable controls to skip generating the HTML visualization during code-only rebuilds, primarily to speed up git hook runs on large graphs and CI/headless environments.
Changes:
- Introduces
_viz_skip_reason(node_count)ingraphify/watch.pyto decide whether to skip HTML viz based onGRAPHIFY_NO_VIZandGRAPHIFY_VIZ_NODE_LIMIT. - Updates
_rebuild_code()to short-circuit theto_html()call when configured, and to remove any stalegraph.htmlwhen skipping. - Adds focused unit tests covering default behavior, env var parsing, limits, invalid values, and precedence rules.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
graphify/watch.py |
Adds env-var based skip logic for HTML viz generation and integrates it into _rebuild_code() with stale graph.html cleanup. |
tests/test_watch.py |
Adds tests validating _viz_skip_reason() behavior across env var combinations and edge cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi, When viz is skipped, Severity: action required | Category: reliability How to fix: Make stale delete best-effort Agent prompt to fix - you can give this to your LLM of choice:
Found by Qodo code review. FYI, Qodo is free for open-source. |
Closes #541.
Summary
Adds two env-var opt-outs to
_rebuild_codeingraphify/watch.pyso users can skip the HTML viz step without patching the post-commit hook script:GRAPHIFY_NO_VIZ=1— unconditional skip; for CI runners and headless dev boxes that never opengraph.html.GRAPHIFY_VIZ_NODE_LIMIT=N— soft cap; skip when node count exceeds N.GRAPHIFY_NO_VIZtakes priority. Both default to off, preserving current behavior. The pre-existingValueErrorcatch aroundto_htmlstays as a backstop for unrelated rendering failures.Why
v0.5.0 catches
ValueErrorfromto_htmlso the hook no longer fails on >5000-node graphs — but it still pays the fullto_htmlattempt before the guard rejects. On a 6000-node Django graph this was costing several seconds per commit. The env vars let the user short-circuit before the attempt.Implementation
New helper
_viz_skip_reason(node_count)reads the two env vars and returns a reason string (or None). Theto_htmlcall site checks the reason first and skips with a printed message if set.Tests
7 new tests in
tests/test_watch.py:GRAPHIFY_NO_VIZtruthy valuesGRAPHIFY_NO_VIZfalsy values (0,false,no, empty, whitespace)GRAPHIFY_VIZ_NODE_LIMITthreshold (one below, equal, one above)GRAPHIFY_VIZ_NODE_LIMITsilently treated as unsetGRAPHIFY_NO_VIZpriority overGRAPHIFY_VIZ_NODE_LIMITpytest tests/test_watch.py— 18/18 pass. Full suite — 440/447 (the 7 failures are pre-existing in v0.5.0 and unrelated to this change; verified by stashing the diff and re-running).Test plan
pytest tests/test_watch.py -qpytest -q(full suite — same baseline failures, no new ones)GRAPHIFY_NO_VIZ=1 graphify update .shows skip message + nograph.htmlproducedGRAPHIFY_VIZ_NODE_LIMIT=10 graphify update .on a >10-node repo shows skip message