Repository navigation
Wire --no-viz flag in cluster-only + GRAPHIFY_VIZ_NODE_LIMIT env var (closes #541) - #565
Conversation
…OR_VIZ Adds opt-in env var so users with large graphs (>5000 nodes) can either raise the HTML viz limit or disable viz entirely (set to 0) without patching the package. - New _viz_node_limit() helper reads GRAPHIFY_VIZ_NODE_LIMIT, falls back to MAX_NODES_FOR_VIZ on unset/empty/non-integer values. - to_html() now uses the helper; ValueError message references both --no-viz and GRAPHIFY_VIZ_NODE_LIMIT for discoverability. - 7 new tests in test_export.py covering default, raise/lower, zero, invalid, empty, and end-to-end to_html behavior. Addresses option 2 in Graphify-Labs#541 (env var as default behavior, zero-config for most users, tunable for large repos. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> EOF )
Before this change, `graphify cluster-only <path>` called to_html() unconditionally, so on graphs >5000 nodes the ValueError fired AFTER graph.json was written but BEFORE the "Done — ..." print, leaving a stale graph.html on disk and no clear signal in the CLI output. This mirrors the watch.py rebuild pattern (already merged): try/except around to_html, delete the stale graph.html when skipping, and emit a "Done" line that accurately reflects which artifacts landed. - Parse "--no-viz" from sys.argv (documented as such in skill.md but previously never wired into the Python CLI). - Wrap to_html() in try/except so core outputs (graph.json + GRAPH_REPORT.md) always land. - Remove stale graph.html when viz is skipped or fails — avoids the silent desync where graph.html lags behind graph.json by days. - Update help text under `cluster-only` to advertise --no-viz. Addresses option 1 in Graphify-Labs#541 (--no-viz flag, simplest opt-in). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Hi, In Severity: action required | Category: correctness How to fix: Parse cluster-only args properly Agent prompt to fix - you can give this to your LLM of choice:
We noticed a couple of other issues in this PR as well - happy to share if helpful. Found by Qodo code review. FYI, Qodo is free for open-source. |
|
Fixed in v0.6.6. Available on PyPI: |
Summary
Closes #541 by exposing both APIs the reporter proposed:
GRAPHIFY_VIZ_NODE_LIMITenv var (option 2 in Expose --no-viz flag and/or GRAPHIFY_VIZ_NODE_LIMIT env var #541): overrideMAX_NODES_FOR_VIZwithout patching the package. Set to0to disable HTML viz unconditionally (CI runners). Falls back to default on unset / empty / non-integer values.--no-vizflag (option 1 in Expose --no-viz flag and/or GRAPHIFY_VIZ_NODE_LIMIT env var #541): now wired intocluster-only. The flag was already documented inskill.mdbut never actually parsed by the Python CLI.Also fixes a related crash:
cluster-onlypreviously calledto_html()unconditionally, so on graphs >5000 nodes theValueErrorfired aftergraph.jsonwas written but before the final "Done — …" line, leaving a stalegraph.htmlon disk and no clear signal in CLI output. This mirrors the existingwatch.pyrebuild pattern (try/except + delete stale html).Repro of the cluster-only crash
Before:
After (default):
With
--no-viz:With
GRAPHIFY_VIZ_NODE_LIMIT=10000:Out of scope (intentionally)
graphify hook install --no-viz(the original Expose --no-viz flag and/or GRAPHIFY_VIZ_NODE_LIMIT env var #541 reporter's option 1): the hook script invokes_rebuild_code()fromwatch.py, which already has the try/except guard. So hook users onv5are implicitly safe from the crash, and the env var lets them tune the limit globally. A dedicatedhook install --no-vizflag could be added in a follow-up if you'd like a more explicit knob — happy to do it.argparserefactor of__main__.py: would be cleaner than the ad-hocsys.argvslicing, but is a larger change that deserves its own PR.Tests
tests/test_export.pygains 7 tests (all green together with the existing 13):test_viz_node_limit_default— unset env var falls back toMAX_NODES_FOR_VIZtest_viz_node_limit_env_override_higher—=20000raises the captest_viz_node_limit_env_override_zero_disables—=0disables viztest_viz_node_limit_invalid_falls_back_to_default— non-integer is ignoredtest_viz_node_limit_empty_falls_back_to_default— whitespace/empty is ignoredtest_to_html_raises_with_lowered_limit— end-to-end ValueError with=1test_to_html_writes_with_raised_limit— end-to-end success with=100000Run with:
pytest tests/test_export.py -vCompatibility
MAX_NODES_FOR_VIZ = 5_000,to_htmlstill raisesValueError).graphify.export:_viz_node_limit(underscore-prefixed; tests import it for direct unit coverage).Verified against
graphify cluster-only .on a real 8881-node graph (a polyglot Flutter + Postgres + n8n repo): all three exit paths (default,--no-viz, env var override) produce the expected output and artifact mtimes.