-
Notifications
You must be signed in to change notification settings - Fork 3k
Keep hffs cache in workers when streaming #7820
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
base: main
Are you sure you want to change the base?
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
I'll try this :)
if name == "token" and getattr(self, "storage_options", None) is not None: | ||
if "hf" not in self.storage_options: | ||
self.storage_options["hf"] = {"token": value, "endpoint": config.HF_ENDPOINT} | ||
self.storage_options["hf"] = {"endpoint": config.HF_ENDPOINT, "token": value} |
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.
Did you need to make this change? seems weird since dicts aren't ordered in python
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.
because fsspec
cache that maps a filesystem argument to the cached instance is sensitive to the order ^^'
with those changes every instance of HfFileSystem in datasets
uses the same order
storage_options = { | ||
"token": token, | ||
"endpoint": config.HF_ENDPOINT, | ||
"token": token, |
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.
same, weird that you need this :S
(and also reorder the hffs args to improve caching)
When using
DataLoader(iterable_dataset, num_workers=...)
the dataset is pickled and passed to the worker. However previously the resulting dataset would be in a process with an empty hffs cache. By keeping the cache attached toIterableDataset
, the cached hffs instances are pickled with the dataset and re-populates the cache in the DataLoader workersthis requires huggingface/huggingface_hub#3443 to work effectively though, otherwise the unpickled hffs cache would start empty
cc @andimarafioti @LTMeyer