-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Added iterate_episodes and made dataset an iterable #54
Conversation
Hey @Howuhh thanks a lot for this PR! I'm wondering if merging this new method I can merge this PR first after the pre-commit is fixed and make an issue for the single generator implementation |
Second thoughts, I don't think |
@rodrigodelazcano To be honest, I don't really understand the current issue with the pre-commit, and what's more, locally, all the checks go through without errors (with setup described in |
Interesting, let me have a look at it. |
@Howuhh regarding the pre-commit errors I'm also unable to replicate them locally. Looking at the logs it seems that the issue comes from pyright identifying the ndarray type as Unknown. I also think that we can omit the use of a numpy array to pass the list of indices, passing a list should be enough. Can you remove this type and see if the error is fixed? |
@rodrigodelazcano Yup, but then it will be a little bit inconsistent with type of |
also, there are examples such as @rodrigodelazcano I actually don't think it's necessary to remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me; I just added a small comment
minari/dataset/minari_dataset.py
Outdated
for ( | ||
episode_index | ||
) in episode_indices: # pyright: ignore [reportOptionalIterable] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to avoid #pyright: ignore
here and thus make it one line?
It seems it doesn't recognize in line 140 that episode_indices can't be None, but it should work with an assert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Howuhh can you edit this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodrigodelazcano yup, been a little busy, I'll correct it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, checks are all green locally, so mb this will work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I'll merge after @younik reviews are fixed
Description
Although the documentation says that Minari doesn't serve the purpose of creating replay buffers, the dataset itself only allows you to sample random episodes, which is not very useful in practice for creating custom replay buffers or dataloaders. It's much more useful to be able to iterate or get a generator by episodes (which won't load everything into memory). I am currently using Minari to build dataset for my tasks and this kind of functionality is very lacking for convenient use. So I added the ability to iterate through the episodes.
Type of change
Checklist:
pre-commit
checks withpre-commit run --all-files
(seeCONTRIBUTING.md
instructions to set it up)pytest -v
and no errors are present.pytest -v
has generated that are related to my code to the best of my knowledge.