Skip to content

Commit

Permalink
Fix comparison but also make caching optional depending on either ori…
Browse files Browse the repository at this point in the history
…ginal file had it
  • Loading branch information
yarikoptic committed Sep 13, 2024
1 parent 4061912 commit 7ed9c30
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions dandi/pynwb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,19 +515,22 @@ def copy_nwb_file(src: str | Path, dest: str | Path) -> str:
dest = op.join(dest, op.basename(src))
else:
os.makedirs(op.dirname(dest), exist_ok=True)
kws = {}
if Version(pynwb.__version__) >= Version("2.8.2"):

Check warning on line 519 in dandi/pynwb_utils.py

View check run for this annotation

Codecov / codecov/patch

dandi/pynwb_utils.py#L518-L519

Added lines #L518 - L519 were not covered by tests
# we might make it leaner by not caching the spec if original
# file did not have it. Possible only since 2.8.2.dev11
kws["cache_spec"] = bool(pynwb.NWBHDF5IO.get_namespaces(src))

Check warning on line 522 in dandi/pynwb_utils.py

View check run for this annotation

Codecov / codecov/patch

dandi/pynwb_utils.py#L522

Added line #L522 was not covered by tests
with pynwb.NWBHDF5IO(src, "r") as ior, pynwb.NWBHDF5IO(dest, "w") as iow:
data = ior.read()
data.generate_new_id()
iow.export(

Check warning on line 526 in dandi/pynwb_utils.py

View check run for this annotation

Codecov / codecov/patch

dandi/pynwb_utils.py#L526

Added line #L526 was not covered by tests
ior,
nwbfile=data,
# do not export spec since
**(
{"cache_spec": False}
if Version(pynwb.__version__) > Version("2.8.2")
else {}
),
**kws,
)
import pdb

Check warning on line 531 in dandi/pynwb_utils.py

View check run for this annotation

Codecov / codecov/patch

dandi/pynwb_utils.py#L531

Added line #L531 was not covered by tests

pdb.set_trace()

Check warning on line 533 in dandi/pynwb_utils.py

View check run for this annotation

Codecov / codecov/patch

dandi/pynwb_utils.py#L533

Added line #L533 was not covered by tests
return str(dest)


Expand Down

0 comments on commit 7ed9c30

Please sign in to comment.