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 8dba010
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions dandi/pynwb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,18 +515,18 @@ 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"):
# 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))
with pynwb.NWBHDF5IO(src, "r") as ior, pynwb.NWBHDF5IO(dest, "w") as iow:
data = ior.read()
data.generate_new_id()
iow.export(
ior,
nwbfile=data,
# do not export spec since
**(
{"cache_spec": False}
if Version(pynwb.__version__) > Version("2.8.2")
else {}
),
**kws,
)
return str(dest)

Expand Down

0 comments on commit 8dba010

Please sign in to comment.