Skip to content

collect_files() in extract.py ignores .graphifyignore #188

Closed

Description

@Leo86868

Bug

collect_files() in extract.py does not filter files through .graphifyignore. This means _rebuild_code() in watch.py (which calls collect_files()) scans all files regardless of ignore patterns.

Meanwhile, detect() in detect.py correctly loads and applies .graphifyignore via _load_graphifyignore() + _is_ignored().

Impact

On a project with node_modules/ in .graphifyignore, collect_files() returns 40,272 files instead of 210. The resulting Louvain clustering takes ~17 minutes and produces a polluted graph.

Steps to Reproduce

  1. Create a project with a node_modules/ directory and a .graphifyignore containing node_modules/
  2. Run _rebuild_code(Path('.')) from graphify.watch
  3. Observe that collect_files() returns files from node_modules/

Expected Behavior

collect_files() should respect .graphifyignore the same way detect() does.

Suggested Fix

Have collect_files() accept an optional root parameter and call _load_graphifyignore(root) + _is_ignored() to filter results, similar to how detect() does it in detect.py lines 306-333.

Workaround

Monkey-patching collect_files before calling _rebuild_code:

from graphify.detect import _load_graphifyignore, _is_ignored
from graphify.extract import collect_files as _original
from graphify import extract as _mod

def _filtered(target, *, follow_symlinks=False):
    files = _original(target, follow_symlinks=follow_symlinks)
    root = target if target.is_dir() else target.parent
    patterns = _load_graphifyignore(root)
    return [f for f in files if not _is_ignored(f, root, patterns)] if patterns else files

_mod.collect_files = _filtered

Environment

  • graphify 0.4.6
  • Python 3.13
  • macOS

Activity

  1. safishamsi commented on Apr 10, 2026

    @safishamsi
    Member

    Fixed in v4 (commit 271ee0a). collect_files() now loads .graphifyignore via _load_graphifyignore and filters through _is_ignored the same way detect() does. An optional root parameter lets callers specify where to look for the ignore file. Thanks for the detailed report and the workaround.

  2. added a commit that references this issue on Apr 10, 2026
    271ee0a
  3. added a commit that references this issue on Apr 23, 2026
    cede5b6
  4. added a commit that references this issue on Sep 10, 2026
    9c3c701
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