Skip to content

Commit

Permalink
Prepare for release of PyNWB 2.8.2 (#1960)
Browse files Browse the repository at this point in the history
* update changelog

* update dependencies

* update requirements-doc.txt

* revert opt requirements update

* update numpy requirement

* update environment

* add family driver file validation, ignore dandi file validation

* revert warning filtering in validation

* Update CHANGELOG.md

* Update environment-ros3.yml
  • Loading branch information
stephprince authored Sep 9, 2024
1 parent 6196568 commit b9f9e5a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PyNWB Changelog

## PyNWB 2.8.2 (Upcoming)
## PyNWB 2.8.2 (September 9, 2024)

### Enhancements and minor changes
- Added support for numpy 2.0. @mavaylon1 [#1956](https://github.com/NeurodataWithoutBorders/pynwb/pull/1956)
Expand Down
6 changes: 3 additions & 3 deletions environment-ros3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ channels:
dependencies:
- python==3.12
- h5py==3.11.0
- hdmf==3.14.1
- matplotlib==3.8.0
- numpy==1.26.4
- hdmf==3.14.3
- matplotlib==3.8.4
- numpy==2.1.1
- pandas==2.2.2
- python-dateutil==2.9.0
- setuptools
Expand Down
39 changes: 31 additions & 8 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import argparse
import glob
import h5py
import inspect
import logging
import os.path
Expand Down Expand Up @@ -152,6 +153,9 @@ def validate_nwbs():
logging.info('running validation tests on NWB files')
examples_nwbs = glob.glob('*.nwb')

# exclude files downloaded from dandi, validation of those files is handled by dandisets-health-status checks
examples_nwbs = [x for x in examples_nwbs if not x.startswith('sub-')]

import pynwb
from pynwb.validate import get_cached_namespaces_to_validate

Expand All @@ -162,15 +166,34 @@ def validate_nwbs():
ws = list()
with warnings.catch_warnings(record=True) as tmp:
logging.info("Validating with pynwb.validate method.")
with pynwb.NWBHDF5IO(nwb, mode='r') as io:
errors = pynwb.validate(io)
TOTAL += 1
is_family_nwb_file = False
try:
with pynwb.NWBHDF5IO(nwb, mode='r') as io:
errors = pynwb.validate(io)
except OSError as e:
# if the file was created with the family driver, need to use the family driver to open it
if 'family driver should be used' in str(e):
is_family_nwb_file = True
match = re.search(r'(\d+)', nwb)
filename_pattern = nwb[:match.start()] + '%d' + nwb[match.end():] # infer the filename pattern
memb_size = 1024**2 # note: the memb_size must be the same as the one used to create the file
with h5py.File(filename_pattern, mode='r', driver='family', memb_size=memb_size) as f:
with pynwb.NWBHDF5IO(file=f, manager=None, mode='r') as io:
errors = pynwb.validate(io)
else:
raise e

TOTAL += 1

if errors:
FAILURES += 1
ERRORS += 1
for err in errors:
print("Error: %s" % err)

if errors:
FAILURES += 1
ERRORS += 1
for err in errors:
print("Error: %s" % err)
# if file was created with family driver, skip pynwb.validate CLI because not yet supported
if is_family_nwb_file:
continue

namespaces, _, _ = get_cached_namespaces_to_validate(nwb)

Expand Down

0 comments on commit b9f9e5a

Please sign in to comment.