Skip to content

Expose --no-viz flag and/or GRAPHIFY_VIZ_NODE_LIMIT env var #541

Closed

Description

@saxster

Labels: hook, viz, large-repo

Body:

Problem

graphify hook install writes a .git/hooks/post-commit whose _HOOK_SCRIPT calls to_html() unconditionally. On graphs with more than ~5,000 nodes, to_html() raises (the pyvis layout pass blows up). The hook fails after every commit on large repos.

We patched our local copy of the hook (2026-04-25) to gate the viz step:

if G.number_of_nodes() <= 5000:
    to_html(...)
else:
    print('[graphify hook] HTML viz skipped (> 5000 nodes); graph.json + GRAPH_REPORT.md updated.')

But graphify hook install regenerates the script from upstream _HOOK_SCRIPT, clobbering the patch on every reinstall.

Reproducer

  1. Install the hook on any repo whose code-graph exceeds 5,000 nodes (a 50k-LOC Django project does it).
  2. Make a commit.
  3. Observe the hook fail during to_html rendering.

Proposal

Any one of:

  1. Flag. graphify hook install --no-viz — generates a hook that skips to_html entirely. Simplest, opt-in.
  2. Env var. GRAPHIFY_VIZ_NODE_LIMIT=5000 (default) — the generated hook reads the env var and skips to_html above the threshold, printing a warning. Zero-config for most users; tunable for large repos.
  3. Both. Env var as default behavior, --no-viz as explicit opt-out.

Option 2 is the safest default — the hook stays useful on every repo size without manual patching, and CI consumers (who don't need the HTML) can set the limit to 0.

Motivation

Keeps the post-commit hook trustworthy across repo sizes. Also unblocks downstream users who don't need the HTML viz at all (CI runners, headless dev boxes).

Activity

  1. market4drill commented on Apr 27, 2026

    @market4drill

    Opened #565 to address this — implements both APIs you proposed:

    • GRAPHIFY_VIZ_NODE_LIMIT env var (your option 2) — overrides MAX_NODES_FOR_VIZ without patching the package, supports 0 to disable viz unconditionally for CI.
    • --no-viz flag in cluster-only (your option 1, narrowed to the CLI command that actually crashes today on v5).

    The hook script itself doesn't need a direct change on v5: _HOOK_SCRIPT calls _rebuild_code() from watch.py, which already wraps to_html() in try/except ValueError. So with this PR merged, your hook is safe by default (no crash) and tunable via env var (no manual patching after graphify hook install).

    If you'd rather have an explicit graphify hook install --no-viz flag too (your option 1's stricter form, generating a hook variant that skips viz entirely), happy to add it as a follow-up — kept it out of #565 to keep the diff small.

  2. safishamsi commented on May 2, 2026

    @safishamsi
    Member

    Fixed in v0.6.3. The cluster-only command now wraps to_html in try/except ValueError — graphs with >5000 nodes skip HTML viz gracefully instead of crashing, consistent with the watch/hook path.

  3. added a commit that references this issue on May 2, 2026
    6c9b5ef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions