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

Fix/read bad icephys table #919

Closed
wants to merge 4 commits into from
Closed

Fix/read bad icephys table #919

wants to merge 4 commits into from

Conversation

oruebel
Copy link
Contributor

@oruebel oruebel commented Jul 26, 2023

Motivation

Fix #918

Relax the error checking in the __init__ methods of DynamicTable and AlignedDynamicTable to raise warnings when reading from file and raise errors when creating new data. This is to try and allow users to access bad data files while ensuring that we don't construct bad files ourselves.

How to test the behavior?

See #918 for details

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Have you checked our Contributing document?
  • Have you ensured the PR clearly describes the problem and the solution?
  • Is your contribution compliant with our coding style? This can be checked running ruff 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 "Fix #XXX" notation where XXX is the issue number? By including "Fix #XXX" you allow GitHub to close issue #XXX when the PR is merged.

@codecov
Copy link

codecov bot commented Jul 26, 2023

Codecov Report

Patch coverage: 35.29% and project coverage change: -0.21% ⚠️

Comparison is base (64a444f) 88.33% compared to head (b5ad48c) 88.12%.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #919      +/-   ##
==========================================
- Coverage   88.33%   88.12%   -0.21%     
==========================================
  Files          45       45              
  Lines        9283     9309      +26     
  Branches     2651     2661      +10     
==========================================
+ Hits         8200     8204       +4     
- Misses        765      782      +17     
- Partials      318      323       +5     
Files Changed Coverage Δ
src/hdmf/common/table.py 85.08% <20.00%> (-0.45%) ⬇️
src/hdmf/common/alignedtable.py 88.60% <37.93%> (-9.06%) ⬇️

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

Comment on lines +598 to +608
try:
from pynwb import NWBHDF5IO
except ImportError:
self.skipTest("PyNWB not installed for testing")
test_filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"bad_nwb_icephys_aligned_dynamic_table_file.nwb")

with NWBHDF5IO(test_filename, 'r', load_namespaces=True) as nwbio:
with warnings.catch_warnings(record=True) as w:
_ = nwbio.read()
self.assertEqual(len(w), 7)
Copy link
Contributor Author

@oruebel oruebel Jul 26, 2023

Choose a reason for hiding this comment

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

@rly the easiest way to test this is to just try an read the broken NWB file which has all the different errors. However, PyNWB is not installed for our CI, so this test gets skipped. Is there a way that we can read the file without just HDF5IO?

@oruebel oruebel requested a review from rly July 26, 2023 08:35
@rly
Copy link
Contributor

rly commented Jul 26, 2023

From discussion in #918 and with @oruebel in person, I think we do not need to clutter the code base by raising warnings when reading incorrectly constructed files. It is better to fix this upstream. If this comes up again as a common failure mode of the files, then let's add it in.

@rly rly closed this Jul 26, 2023
@rly rly deleted the fix/read_bad_icephys_table branch October 3, 2023 16:54
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.

[Bug]: Reading AlignedDynamicTable from disk causes hdf5 error
2 participants