Skip to content

Apply fsspec config in HfFileSystem metaclass#4062

Open
joaquinhuigomez wants to merge 1 commit intohuggingface:mainfrom
joaquinhuigomez:fix/hf-filesystem-fsspec-config
Open

Apply fsspec config in HfFileSystem metaclass#4062
joaquinhuigomez wants to merge 1 commit intohuggingface:mainfrom
joaquinhuigomez:fix/hf-filesystem-fsspec-config

Conversation

@joaquinhuigomez
Copy link
Copy Markdown
Contributor

@joaquinhuigomez joaquinhuigomez commented Apr 7, 2026

HfFileSystem's _Cached metaclass overrides fsspec.spec._Cached.__call__ but skips the apply_config call that upstream fsspec uses to read config values from environment variables and config files. As a result, HfFileSystem silently 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 HfFileSystem instantiation/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 HfFileSystem honors standard fsspec configuration (env vars / config files) by calling apply_config in the custom _Cached.__call__ before computing the instance cache token.

This aligns HfFileSystem behavior 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.

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
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.

HfFileSystem is incompatible with fsspec's config

1 participant