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

Enh/detect nwb1 #1086

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open

Enh/detect nwb1 #1086

wants to merge 5 commits into from

Conversation

bendichter
Copy link
Contributor

Motivation

fix #1077

What do we want as an error message here? Something along those lines. Maybe we could point the user to the legacy library, but that didn't work for me either with this file. Also, these changes use the io._HDF5IO__built which has a leading underscore. Is there a better way to access these variables?

How to test the behavior?

Use this NWB 1 file:

from pynwb import NWBHDF5IO
io = NWBHDF5IO('JY1579AAAA.nwb', 'r')
io.read()

Checklist

  • Have you checked our Contributing document?
  • Have you ensured the PR description clearly describes problem and the solution?
  • Is your contribution compliant with our coding style? This can be checked running flake8 from the source directory.
  • Have you checked to ensure that there aren't other open Pull Requests for the same change?
  • Have you included the relevant issue number using #XXX notation where XXX is the issue number?

@codecov
Copy link

codecov bot commented Oct 8, 2019

Codecov Report

Merging #1086 into dev will decrease coverage by 0.1%.
The diff coverage is 37.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #1086      +/-   ##
==========================================
- Coverage   67.39%   67.29%   -0.11%     
==========================================
  Files          38       38              
  Lines        2288     2296       +8     
  Branches      393      394       +1     
==========================================
+ Hits         1542     1545       +3     
- Misses        677      682       +5     
  Partials       69       69
Impacted Files Coverage Δ
src/pynwb/__init__.py 70.07% <37.5%> (-2.2%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c6ec626...94c84ae. Read the comment docs.

@bendichter
Copy link
Contributor Author

fyi @yarikoptic

@yarikoptic
Copy link
Contributor

yarikoptic commented Oct 8, 2019

fyi @yarikoptic

THANK YOU! It should help to save some gray hairs of yours truly!
I am a bit lost in the diff, but I don't know pynwb internals well enough to express any pros/cons, but I would have slept much better if the diff was accompanied with a test which would validate that nwb v.1 file does indeed trigger that exception handling ;) which somewhat boils down to #1087 (unless you see a better/easier way, e.g. manually create a sample .nwb 1.0 file)

try:
return super(NWBHDF5IO, self).read(**kwargs)
except ValueError as e:
built = next(iter(self._HDF5IO__built.values()))
Copy link
Contributor

Choose a reason for hiding this comment

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

@ajtritt and I suggest checking for neurodata_type. If it does not exist, then the file is not 2.0+.

To report the NWB 1.x version, it would be better to open the h5py.File and look for the root-level dataset 'nwb_version' (around 1.0.4) or the root-level dataset 'neurodata_version' (1.0.0).

@yarikoptic
Copy link
Contributor

Note sure what has stopped this PR from being finalized. Seems remains useful to have. Can it happen soon or should it be re-draft-ed/closed?

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.

Provide dedicated "Cannot load NWB 1.0" Exception/Error instead of an arbitrary crash
5 participants