Skip to content

graph module overhaul#90

Open
kaitj wants to merge 7 commits intomainfrom
maint/reorg
Open

graph module overhaul#90
kaitj wants to merge 7 commits intomainfrom
maint/reorg

Conversation

@kaitj
Copy link
Collaborator

@kaitj kaitj commented Feb 20, 2026

This is a massive overhaul to make neuromaps_prime.graph more maintainable. It does move some things around, but breaks things into smaller modules. Test coverage is a little lower now, but will look into it as I add tests to cover additional methods.

😰

@kaitj kaitj requested a review from tamsinrogers February 20, 2026 20:26
@kaitj kaitj self-assigned this Feb 20, 2026
@github-actions
Copy link

github-actions bot commented Feb 20, 2026

Coverage

Coverage Report
FileStmtsMissCoverMissing
neuromaps_prime
   utils.py160100% 
neuromaps_prime/graph
   builder.py580100% 
   cache.py600100% 
   core.py690100% 
   models.py330100% 
   utils.py520100% 
neuromaps_prime/graph/transforms
   surface.py570100% 
   volume.py410100% 
neuromaps_prime/transforms
   surface.py350100% 
   utils.py290100% 
   volume.py210100% 
TOTAL4710100% 

Tests Skipped Failures Errors Time
163 8 💤 0 ❌ 0 🔥 3.104s ⏱️

@kaitj kaitj force-pushed the maint/reorg branch 3 times, most recently from 4f1ed15 to 003e126 Compare February 20, 2026 21:04
Combination of manual and agentic asissted fixes for tests with new organization
kaitj added 4 commits March 6, 2026 16:08
graph/methods/fetchers.py — deleted
GraphFetchers was a pure passthrough onto GraphCache with identical signatures. Its filtered list methods (fetch_surface_atlases, etc.) were moved directly onto GraphCache as get_surface_atlases, get_surface_transforms, get_volume_atlases, get_volume_transforms.

graph/methods/cache.py — merged + extended
Absorbed all fetcher methods (renamed fetch_* → get_* for consistency with the existing single-item getters), and gained require_surface_atlas — the raising variant that both ops classes previously duplicated privately.
Moved to graph/cache.py and deleted graph/methods

graph/models.py — simplified
Removed the ABC base and abstractmethod decorator. All four subclasses implemented fetch() identically as return self.file_path, so the method now lives once on the concrete Resource base.

graph/builder.py — de-duplicated
Four _parse_* methods (two for atlases, two for transforms) had the same nested-iteration shape. Collapsed to _parse_surface_resources and _parse_volume_resources, each accepting the target model class and a fixed_fields dict. The name prefix logic is derived from fixed_fields uniformly.

graph/utils.py — fetchers → cache
GraphUtils previously held a fetchers: GraphFetchers reference. Now holds cache: GraphCache directly and calls cache.get_surface_atlases / cache.get_surface_transforms.

graph/transforms/surface.py — fetchers → cache, _require_surface_atlas removed
SurfaceTransformOps dropped the fetchers field and the duplicated _require_surface_atlas. All lookups now go through self.cache.get_* or self.cache.require_surface_atlas.

graph/transforms/volume.py — same treatment
VolumeTransformOps dropped fetchers and its own copy of _require_surface_atlas. The _project_volume_to_surface ribbon dict comprehension replaced the sequential for-loop over ("white", "pial").

graph/core.py — fetchers removed, data_dir typed
self.fetchers is gone. The data_dir walrus-operator pattern gives it a clean Path | None type at construction. All fetch_* public methods now call self._cache.get_* directly.
Tests — fetchers → cache, fetch_* → get_*/require_* throughout. The two _require_surface_atlas tests moved from test_surf_to_surf.py to a new TestGraphCacheRequire class in test_graph.py. The vol-to-surf tests that simulated a miss via return_value=None were updated to use side_effect=ValueError(...) since require_surface_atlas raises rather than returning None.

_Unit tests co-written and optimized by by Claude Code_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant