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

Make calling io->open() explicit #128

Merged
merged 3 commits into from
Jan 13, 2025
Merged

Make calling io->open() explicit #128

merged 3 commits into from
Jan 13, 2025

Conversation

oruebel
Copy link
Contributor

@oruebel oruebel commented Jan 12, 2025

While working on debugging #123 I came across the issue that open seemed to be called more than once on the same file. Part of the issue seems to be that io->open is being called implicitly on behalf of the user in NWBFile.initialize. This PR updates the logic to always require that the user call io-open before making any modifications to the file, e.g, initializing the NWBFile. This PR makes a few changes:

  • Modified NWBFile.initialize to more robustly check if a file has been initialized. The current logic requires that a file must not exist on disk before calling NWBFile.initialize, i.e., if a user calls io->open() before calling NWBFile.initialize, the current logic would fail.
  • Added NWBFile.isInitialized to check whether the expected file structure exists within the file
  • Updated HDF5IO.create* methods to perform the more strict check that canModifyObjects() is true rather than just whether the file isOpen()
  • Updated test suite to call io->open() directly where it was missing
  • Updated testWorkflowExamples.cpp to add REQUIRE checks . The example previously passed independent of whether the workflow was successful or not because the status of I/O operations was not being checked. Since the AqNWB functions did not raise exceptions (but simply returned a Status::Failure) the workflow would run to completion even if the file was not being created at all.

@oruebel oruebel requested a review from stephprince January 12, 2025 20:30
@oruebel oruebel mentioned this pull request Jan 13, 2025
@oruebel
Copy link
Contributor Author

oruebel commented Jan 13, 2025

@stephprince this PR is ready for review

Copy link
Collaborator

@stephprince stephprince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good to me and I'm fine to make io->open() explicit.

However, I'm not sure what the original issue was with calling io->open() twice? I thought it was handled in Status HDF5IO::open(FileMode mode) that if the file was already opened and io->open() was called, nothing would happen.

@oruebel
Copy link
Contributor Author

oruebel commented Jan 13, 2025

However, I'm not sure what the original issue was with calling io->open() twice? I thought it was handled in Status HDF5IO::open(FileMode mode) that if the file was already opened and io->open() was called, nothing would happen.

I'm not 100% sure yet either. I'm still debugging the Windows issue. But making it explicit at least makes debugging easier.

@oruebel oruebel merged commit 14a825c into add_read Jan 13, 2025
9 checks passed
@oruebel oruebel deleted the add_read_explicit_open branch January 13, 2025 18:20
@oruebel oruebel mentioned this pull request Jan 13, 2025
49 tasks
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 this pull request may close these issues.

2 participants