Skip to content

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

@saxster

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions