Skip to content

Commit

Permalink
Make copy_nwb_file() not create external links
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Nov 29, 2021
1 parent d625c62 commit 423184e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 3 additions & 1 deletion dandi/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def get_metadata(path):
return None

if nwb_has_external_links(path):
raise NotImplementedError("NWB files with external links are not supported")
raise NotImplementedError(
f"NWB files with external links are not supported: {path}"
)

# First read out possibly available versions of specifications for NWB(:N)
meta["nwb_version"] = get_nwb_version(path)
Expand Down
9 changes: 4 additions & 5 deletions dandi/pynwb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,10 @@ def copy_nwb_file(src, dest):
dest = op.join(dest, op.basename(src))
else:
os.makedirs(op.dirname(dest), exist_ok=True)
# The simplest way yoh could find
with pynwb.NWBHDF5IO(src, "r") as ior, pynwb.NWBHDF5IO(
dest, "w", manager=ior.manager
) as iow:
iow.write(ior.read().copy(), link_data=False)
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)
return dest


Expand Down

0 comments on commit 423184e

Please sign in to comment.