Repository navigation
refactor(mesh-brain): replace graspologic Leiden with NetworkX Louvain — unblock numpy 2.x + py3.13 (#10524) - #10530
Merged
Merged
Conversation
…n — unblock numpy 2.x + py3.13 (#10524) graspologic 3.4.4 (latest) hard-pins numpy<2.0 and requires Python <3.13, silently capping the backend a major numpy version behind and blocking the py3.14 migration. It was used in exactly one place — two leiden() calls in community_clusterer.py. Swap to NetworkX's built-in Louvain (already a dependency, weight-aware, deterministic via seed) so no package is added. - community_clusterer: _detect_communities() helper via louvain_communities, same {node: community_id} contract; drop graspologic imports - requirements: remove graspologic; lift opencv-python-headless <4.11 cap (numpy>=2 now resolvable in backend) - lifespan: drop dead graspologic-missing ImportError/24h-pause branch (NetworkX is a hard dep; generic handler covers real failures) - tests: remove graspologic stubs + ImportError-path tests (behavior gone) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
✅ SSOT Configuration Compliance: Passing🎉 No hardcoded values detected that have SSOT config equivalents! |
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thinking Path
Part of #10524 (Task 1). The repo can't unify on a single latest numpy because
graspologic 3.4.4(latest, no numpy-2 release even in dev) hard-pinsnumpy<2.0.0andrequires_python <3.13— silently capping the backend a major version behind and blocking the py3.14 migration. graspologic was used in exactly one place: twoleiden(G, trials=N)calls incommunity_clusterer.py. NetworkX (already a dependency) ships weight-aware Louvain with the same{node: community_id}shape, so the swap removes the blocker without adding a package.What Changed
community_clusterer.py— new_detect_communities()helper usingnetworkx.algorithms.community.louvain_communities(seeded for determinism); both Leiden call sites now route through it; graspologic imports removed. Return contract unchanged.requirements.txt— removedgraspologic>=3.4.4; lifted theopencv-python-headless<4.11cap (numpy>=2 is now resolvable in the backend).lifespan.py— removed the deadexcept ImportError → "pip install graspologic" → sleep 24hbranch. NetworkX is a hard dependency, so that condition can no longer occur; the genericexcept Exceptionstill handles real failures.sys.modulesstubs fromcommunity_clusterer_test.pyandmesh_db_adapter_test.py, plus the two tests asserting the now-removed ImportError/24h-pause behavior. All clustering assertions retained and now run against real Louvain.Verification
grep -rn graspologic --include=*.py→ only explanatory comments remain (no code refs).py_compileclean on all changed files.Follow-ups (Task 2/3 of #10524): add
constraints/shared.txtas the single numpy source of truth referenced by every component; CI guard against version re-drift across portable/co-locatable roles.Model Used
Claude Opus 4.8 (1M context)