Skip to content

Commit

Permalink
Merge pull request #1497 from dandi/enh-test-export
Browse files Browse the repository at this point in the history
Use "cache_spec:False" in our copy_nwb_file helper while exporting NWB copy
  • Loading branch information
yarikoptic authored Sep 27, 2024
2 parents 4373cc5 + 8dba010 commit fdd65d0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dandi/pynwb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,19 @@ 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)
iow.export(
ior,
nwbfile=data,
**kws,
)
return str(dest)


Expand Down

0 comments on commit fdd65d0

Please sign in to comment.