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

Fix iterable.Cached. #3060

Merged
merged 3 commits into from
Nov 26, 2023
Merged

Fix iterable.Cached. #3060

merged 3 commits into from
Nov 26, 2023

Conversation

jaheba
Copy link
Contributor

@jaheba jaheba commented Nov 24, 2023

Previously, we only cached elements that were consumed on the first iteration.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Please tag this pr with at least one of these labels to make our release process faster: BREAKING, new feature, bug fix, other change, dev setup

@jaheba jaheba added pending v0.13.x backport This contains a fix to be backported to the v0.13.x branch pending v0.14.x backport This contains a fix to be backported to the v0.14.x branch labels Nov 24, 2023
Copy link
Contributor

@lostella lostella left a comment

Choose a reason for hiding this comment

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

Beautiful! Thanks

cache: list = field(default_factory=list, init=False)

def __post_init__(self):
# ensure we only iterate once over the iterable
self._iterable = iter(self.iterable)
Copy link
Contributor

Choose a reason for hiding this comment

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

Then _iterable could be called iterator I guess

@lostella lostella removed the pending v0.13.x backport This contains a fix to be backported to the v0.13.x branch label Nov 24, 2023
@lostella lostella merged commit 07ef9f0 into awslabs:dev Nov 26, 2023
19 checks passed
@jaheba jaheba deleted the fix-iterable-cached branch November 27, 2023 07:40
lostella pushed a commit to lostella/gluonts that referenced this pull request Nov 27, 2023
@lostella lostella mentioned this pull request Nov 27, 2023
lostella added a commit that referenced this pull request Nov 27, 2023
* Fix `iterable.Cached`. (#3060)

* Torch: Remove double caching of dataset. (#3061)

---------

Co-authored-by: Jasper <[email protected]>
@lostella lostella removed the pending v0.14.x backport This contains a fix to be backported to the v0.14.x branch label Dec 4, 2023
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.

None yet

2 participants