Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default load_namespaces=True #1748

Merged
merged 26 commits into from
Nov 27, 2023
Merged

default load_namespaces=True #1748

merged 26 commits into from
Nov 27, 2023

Conversation

bendichter
Copy link
Contributor

@bendichter bendichter commented Jul 28, 2023

Fix #1143

test_outer_import_structure tests that the imports available from the pynwb module are unchanged. This PR removes the warn library, so it has also been removed form this test. This will technically break backwards compatibility if a user is running from pynwb import warn, but that would be highly unusual and unlikely.

@bendichter bendichter requested review from rly and oruebel July 28, 2023 21:27
@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2aceed0) 91.75% compared to head (ad0e08f) 91.96%.
Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1748      +/-   ##
==========================================
+ Coverage   91.75%   91.96%   +0.21%     
==========================================
  Files          27       27              
  Lines        2619     2615       -4     
  Branches      684      682       -2     
==========================================
+ Hits         2403     2405       +2     
+ Misses        141      138       -3     
+ Partials       75       72       -3     
Flag Coverage Δ
integration 71.28% <100.00%> (+0.18%) ⬆️
unit 83.63% <75.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bendichter
Copy link
Contributor Author

I don't understand why I am failing flake8. @rly , can you help?

@oruebel
Copy link
Contributor

oruebel commented Jul 31, 2023

I don't understand why I am failing flake8.

The GitHub Action indicated the following flake8 issues:

./tests/integration/hdf5/test_ecephys.py:3:109: E231 missing whitespace after ','
./tests/unit/test_ecephys.py:5:104: E231 missing whitespace after ','

@bendichter
Copy link
Contributor Author

oh, I see. It's the imports

rly
rly previously approved these changes Jul 31, 2023
@rly
Copy link
Contributor

rly commented Jul 31, 2023

Currently, calling load_namespaces=True is resulting in lots of this warning:
UserWarning: No cached namespaces found in [...].nwb

This comes from hdmf. I think we can remove that warning. @bendichter could you make a PR for this?

@oruebel
Copy link
Contributor

oruebel commented Sep 6, 2023

Fix #1143

tests/unit/test_file.py Outdated Show resolved Hide resolved
@oruebel
Copy link
Contributor

oruebel commented Sep 6, 2023

@bendichter just FYI, there were a few conflicts in particular in the streaming tutorial, when I updated the PR with the dev branch. Here the changes I made during the merge:

e7023c2

@oruebel
Copy link
Contributor

oruebel commented Sep 6, 2023

The "coverage / ubuntu-latest" action seems to show a large number of warnings and one test failure that appear to be related to the changes in this PR (see https://github.com/NeurodataWithoutBorders/pynwb/actions/runs/6098358982/job/16548020150?pr=1748)

In particular

======================================================================
FAIL: test_validate_file_cached_ignore (validation.test_validate.TestValidateCLI.test_validate_file_cached_ignore)
Test that validating a file with cached spec against the core namespace succeeds.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/pynwb/pynwb/tests/validation/test_validate.py", line 139, in test_validate_file_cached_ignore
    self.assertEqual(result.stderr.decode('utf-8'), '')
AssertionError: '/opt/hostedtoolcache/Python/3.11.4/x64/li[552 chars]."\n' != ''
- /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/hdmf/spec/namespace.py:531: UserWarning: Ignoring cached namespace 'hdmf-common' version 1.0.0 because version 1.8.0 is already loaded.
-   warn("Ignoring cached namespace '%s' version %s because version %s is already loaded."
- /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/hdmf/spec/namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.1.0 because version 2.6.0-alpha is already loaded.
-   warn("Ignoring cached namespace '%s' version %s because version %s is already loaded."
- 

Additionally, there are a lot of warnings where either no cached namespaces are found or another version of the same namespace has already been loaded:

/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/hdmf/backends/hdf5/h5tools.py:213: UserWarning: No cached namespaces found in test_RoiResponseSeries.nwb
/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/hdmf/spec/namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.1.0 because version 2.6.0-alpha is already loaded.

rly
rly previously approved these changes Oct 4, 2023
@bendichter
Copy link
Contributor Author

@rly it looks like you are altering the NWBHDF5IO call to ignore the "no namespace found error". I guess this wouldn't really come up in practice since the NWB files are generally stored with cached schema. Is that right?

tests/unit/test_file.py Outdated Show resolved Hide resolved
docs/gallery/advanced_io/linking_data.py Outdated Show resolved Hide resolved
docs/gallery/advanced_io/linking_data.py Outdated Show resolved Hide resolved
@rly
Copy link
Contributor

rly commented Oct 4, 2023

@rly it looks like you are altering the NWBHDF5IO call to ignore the "no namespace found error". I guess this wouldn't really come up in practice since the NWB files are generally stored with cached schema. Is that right?

That was done in hdmf-dev/hdmf#926 . But yes, that warning wouldn't really come up in practice except when reading old files where the schema was not cached by default. For those old files without the core/hdmf-common schema cached, even if the schema were cached, they would be ignored because the schema loaded by pynwb would take precedence. So it's not a useful warning.

@rly
Copy link
Contributor

rly commented Nov 27, 2023

@bendichter can we merge this?

@bendichter bendichter merged commit 9fafde2 into dev Nov 27, 2023
24 checks passed
# namespaces are not loaded when creating an NWBHDF5IO object in write mode
if 'w' in mode or mode == 'x':
raise ValueError("cannot load namespaces from file when writing to it")
if mode in 'wx' or manager is not None or extensions is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this introduced a bug.

if extensions is not None:
warn("loading namespaces from file - ignoring 'extensions' argument")
# namespaces are not loaded when creating an NWBHDF5IO object in write mode
if 'w' in mode or mode == 'x':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here was correct.

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.

Automagically load necessary Python modules for extensions registered in nwb-extensions
4 participants