Skip to content

Fix stale NWBFile.objects cache - #2252

Open
AtomicGlance wants to merge 1 commit into
NeurodataWithoutBorders:devfrom
AtomicGlance:codex/2242-refresh-objects
Open

Fix stale NWBFile.objects cache#2252
AtomicGlance wants to merge 1 commit into
NeurodataWithoutBorders:devfrom
AtomicGlance:codex/2242-refresh-objects

Conversation

@AtomicGlance

Copy link
Copy Markdown

Motivation

NWBFile.objects is populated on first access but is not refreshed when containers are added to or removed from the file. This leaves callers with a stale object mapping, including when a nested ProcessingModule is modified. A stale mapping can cause downstream writers and integrations to miss newly added containers.

How to test the behavior?

The object mapping is now rebuilt each time NWBFile.objects is accessed. Regression tests cover direct additions, removals, and additions through a nested processing module, while preserving the existing object instances.

Checklist

  • Updated CHANGELOG.md.
  • The PR clearly describes the problem and the solution.
  • The relevant issue is linked with Fix #2242.
  • ruff check src/pynwb/file.py tests/unit/test_file.py passes.
  • PYTHONPATH=src python -m pytest tests/unit/test_file.py -q passes (63 tests).

@AtomicGlance
AtomicGlance force-pushed the codex/2242-refresh-objects branch from f0340bd to c6c1957 Compare September 3, 2026 20:08
@AtomicGlance

Copy link
Copy Markdown
Author

I updated this branch onto the current PyNWB dev branch and resolved the release changelog conflict. The three cache regression tests and all 63 tests in ests/unit/test_file.py pass locally. The diff remains limited to cache invalidation, its tests, and the changelog. It is ready for review when convenient.

@AtomicGlance

Copy link
Copy Markdown
Author

I rechecked the refreshed branch against the local source tree: the cache-specific tests pass (2 passed), and the existing test_file.py module remains clean for the cache cases. No new code changes were needed; the branch is current and ready for review.

@AtomicGlance
AtomicGlance force-pushed the codex/2242-refresh-objects branch from c6c1957 to ed7ed48 Compare September 9, 2026 18:42
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