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.
Motivation
Fix issues related to type map caching:
This PR saves the type map pickle file in the user cache directory instead of the pynwb installation location, adds a catch for access errors when writing the cache files, and adds an option to disable caching.
A couple of questions related to implementation:
platformdirs
has a built-in versioning argument that creates distinct version folders in the cache directory. The current draft of this PR uses this approach to replace the version indicator file. A pro is that someone working with multiple versions of pynwb would have the appropriate typemap cached for each version. A con is multiple cache files would be saved, especially when developing (We might want to recommend developers use the environment variable to disable the cache in general). Any other considerations I'm missing or preference for which approach to use?2. I added areset_namespaces
function, since it is difficult to test type map caching because unpickleable extension namespaces are loaded as part of the test suite. This could partially addressunload_namespace
#1009, but may require some further testing to make sure everything is working as expected. I can move that to a separate PR if needed, I think it would just limit the tests here.Edit: I think any changes to resetting/unloading namespaces would need further discussion and should be moved to a separate PR. I'll remove the tests that require these changes for now.
TODO
How to test the behavior?
Checklist
ruff check . && codespell
from the source directory.