Skip to content

Commit

Permalink
tools/nwb-read-tests: Verify nwbv2 files with DANDI as well
Browse files Browse the repository at this point in the history
This should catch issues like in the last commit earlier.
  • Loading branch information
t-b committed Sep 6, 2024
1 parent 93226dc commit 71a3484
Show file tree
Hide file tree
Showing 3 changed files with 1,184 additions and 12 deletions.
20 changes: 15 additions & 5 deletions tools/nwb-read-tests/nwbv2-read-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,27 @@ def checkFile(path):
print(f"The file {path} does not exist.", file=sys.stderr)
return 1

# 1.) Validation
# 1.) pynwb Validation
comp = run(["python", "-m", "pynwb.validate", path],
stdout=PIPE, stderr=STDOUT, universal_newlines=True, timeout=120)

if comp.returncode != 0:
print(f"Validation output: {comp.stdout}", file=sys.stderr)
print(f"pynwb validation output: {comp.stdout}", file=sys.stderr)
return 1

print(f"Validation output: {comp.stdout}", file=sys.stdout)
print(f"pynwb validation output: {comp.stdout}", file=sys.stdout)

# 2.) Read test
# 2.) dandi Validation
comp = run(["dandi", "validate", "--ignore", "(NWBI|DANDI)", path],
stdout=PIPE, stderr=STDOUT, universal_newlines=True, timeout=120)

if comp.returncode != 0:
print(f"dandi validation output: {comp.stdout}", file=sys.stderr)
return 1

print(f"dandi validation output: {comp.stdout}", file=sys.stdout)

# 3.) Read test
with NWBHDF5IO(path, mode='r', load_namespaces=True) as io:
nwbfile = io.read()

Expand All @@ -56,7 +66,7 @@ def checkFile(path):
print(f"epochs.treelevel: {nwbfile.epochs[:, 'treelevel']}")
print(f"epochs.timeseries: {nwbfile.epochs[:, 'timeseries']}")

# check that pynwb/hdmf can read our object IDs
# 4. Check that pynwb/hdmf can read our object IDs
with h5py.File(path, 'r') as f:
root_object_id_hdf5 = to_str(f["/"].attrs["object_id"])

Expand Down
1 change: 1 addition & 0 deletions tools/nwb-read-tests/requirements.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pynwb==2.8.1
dandi==0.63.0
Loading

0 comments on commit 71a3484

Please sign in to comment.