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

[Bug]: Calling io.read() more than once results in error #914

Closed
3 tasks done
rly opened this issue Jul 25, 2023 · 0 comments · Fixed by #915
Closed
3 tasks done

[Bug]: Calling io.read() more than once results in error #914

rly opened this issue Jul 25, 2023 · 0 comments · Fixed by #915

Comments

@rly
Copy link
Contributor

rly commented Jul 25, 2023

What happened?

Prior to HDMF 3.7.0, you could call io.read() more than once. Now you get a ValueError:
ValueError: io has already been set for this container (name=root, type=<class 'pynwb.file.NWBFile'>)

This line https://github.com/hdmf-dev/hdmf/blob/dev/src/hdmf/container.py#L256 needs to be changed to also check that the new read_io object is not the same as the old read_io object.

Steps to Reproduce

from pynwb import NWBHDF5IO
io = NWBHDF5IO("/Users/rly/Downloads/20230622_155936.nwb", "r", load_namespaces=True)
nwbfile = io.read()
nwbfile = io.read()

Traceback

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/rly/Documents/NWB/hdmf/src/hdmf/utils.py", line 644, in func_call
    return func(args[0], **pargs)
  File "/Users/rly/Documents/NWB/pynwb/src/pynwb/__init__.py", line 304, in read
    file = super().read(**kwargs)
  File "/Users/rly/Documents/NWB/hdmf/src/hdmf/backends/hdf5/h5tools.py", line 477, in read
    return super().read(**kwargs)
  File "/Users/rly/Documents/NWB/hdmf/src/hdmf/utils.py", line 644, in func_call
    return func(args[0], **pargs)
  File "/Users/rly/Documents/NWB/hdmf/src/hdmf/backends/io.py", line 61, in read
    container.read_io = self
  File "/Users/rly/Documents/NWB/hdmf/src/hdmf/container.py", line 257, in read_io
    raise ValueError("io has already been set for this container (name=%s, type=%s)" %
ValueError: io has already been set for this container (name=root, type=<class 'pynwb.file.NWBFile'>)

Operating System

macOS

Python Executable

Conda

Python Version

3.11

Package Versions

No response

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant