Apply fsspec config in HfFileSystem metaclass#4062
Open
joaquinhuigomez wants to merge 1 commit intohuggingface:mainfrom
Open
Apply fsspec config in HfFileSystem metaclass#4062joaquinhuigomez wants to merge 1 commit intohuggingface:mainfrom
joaquinhuigomez wants to merge 1 commit intohuggingface:mainfrom
Conversation
The HfFileSystem metaclass _Cached overrides fsspec.spec._Cached.__call__ but never calls apply_config, so fsspec config values (from environment variables or config files) are silently dropped for HfFileSystem while they work for every other fsspec filesystem. Call apply_config on kwargs at the start of __call__, matching the upstream fsspec._Cached behavior. Fixes huggingface#3996
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HfFileSystem's
_Cachedmetaclass overridesfsspec.spec._Cached.__call__but skips theapply_configcall that upstream fsspec uses to read config values from environment variables and config files. As a result,HfFileSystemsilently ignores fsspec config that works on every other filesystem backend.This patch calls
apply_config(cls, kwargs)at the start of__call__, matching upstream fsspec behavior.Fixes #3996
Note
Medium Risk
Changes
HfFileSysteminstantiation/caching by applying fsspec env/config defaults before tokenization, which can alter cache keys and runtime options for existing users relying on implicit defaults.Overview
Ensures
HfFileSystemhonors standard fsspec configuration (env vars / config files) by callingapply_configin the custom_Cached.__call__before computing the instance cache token.This aligns
HfFileSystembehavior with upstream fsspec filesystems so default options from config are applied consistently when creating/reusing cached filesystem instances.Reviewed by Cursor Bugbot for commit d89bbf8. Bugbot is set up for automated code reviews on this repo. Configure here.