Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "cache_spec:False" in our copy_nwb_file helper while exporting NWB copy #1497

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading