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 Fix] Fix h5py group creation #111

Merged

Conversation

rodrigodelazcano
Copy link
Member

@rodrigodelazcano rodrigodelazcano commented Jul 14, 2023

Description

While creating a dataset I got an error due to a simplification in this previous PR #102 to create non-existing h5py groups. It appears that this code doesn't work as I thought. The following code is an example that we can't check for existing/non-existing groups and create the group as default with the get function in h5py:

import h5py


with h5py.File('testing_file.hdf5', 'a') as f:

    f.create_group('new_group')

    group = f.get('new_group', default=f.create_group('new_group'))

The code will throw an error saying that the group already exists.

My proposed fix is a function to implement the previous functionality from the mentioned PR (#102)

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • I have run pytest -v and no errors are present.
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I solved any possible warnings that pytest -v has generated that are related to my code to the best of my knowledge.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

rodrigodelazcano added 2 commits July 14, 2023 14:50
Copy link
Collaborator

@balisujohn balisujohn left a comment

Choose a reason for hiding this comment

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

Is there a test that could be added that would test this behavior? If so, I think that test should be added. Otherwise, LGTM

@balisujohn balisujohn mentioned this pull request Jul 17, 2023
7 tasks
Copy link
Member

@younik younik left a comment

Choose a reason for hiding this comment

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

Ah, my bad! The function is called even if the key exists; thanks for fixing this

@rodrigodelazcano
Copy link
Member Author

Is there a test that could be added that would test this behavior? If so, I think that test should be added. Otherwise, LGTM

Lets add the test in another PR so that we can move forward with the next release of Minari

@balisujohn
Copy link
Collaborator

LGTM :^)

@balisujohn balisujohn merged commit 5877b31 into Farama-Foundation:main Jul 17, 2023
12 checks passed
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.

3 participants