/hf/. Listing and writes use
OpenDAL (the hf-buckets extra). Reads stream
from the Hub.
For credential setup, see HF Buckets Setup.
Install
Config
HfBucketsVFS(config) takes an HfBucketsConfig object with the
bucket in namespace/bucket-name form plus an optional access token.
timeout is how many seconds one Hub request may go without progress:
connecting, waiting for the answer, or between two chunks of a download.
A large file that keeps arriving is never cut off, and 0 turns the
bound off.
Both READ and WRITE modes are supported out of the box.
Fields marked secret are redacted in snapshots.
VFS.md
The VFS.md an agent reads with HF Buckets mounted at/<path>.
- Rendered
- Raw
your-user/my-data contains:
/hf/ exposes:
/hf/data/file.txt maps to bucket key
data/file.txt.
Cache
The HF Buckets VFS usesIndexCacheStore with index_ttl = 600
(10 minutes). Directory listings are cached and populate file-size/type
entries that stat reads via a fast path, so a readdir followed by
per-entry stat calls (which is what ls, FUSE getattr, and most
shell commands trigger) costs one HTTP request instead of N. A configured index: replaces this lifetime with its own ttl, and the mount’s ttl: caps it.
Integration
What Hugging Face buckets answers through its own API, so fewer files are read. Integration explains each command.Example
Shell Commands
The HF Buckets VFS supports the full set of shell commands since it operates on real file content (text, binary, JSON, CSV, etc.). Large files benefit from range reads to avoid downloading entire objects.Read Commands
Text Processing
File Operations
Path Utilities
Compression
Encoding
Use Cases
- AI agents accessing HF datasets: Mount HF Buckets for agents to read and process datasets stored on the Hub
- Data pipelines: Read and write HF bucket objects with shell-like commands
- Sandboxed bucket access: Restrict agent operations to a specific bucket and prefix
- FUSE mounting: Expose HF Buckets through a virtual FUSE mount for external tools
Scoping a VFS to a key prefix
Passkey_prefix: str | None = None to HfBucketsConfig to transparently scope every operation to a subpath of the bucket:
/data/notes.md; the underlying bucket key is users/{user_id}/data/notes.md. Useful for multi-tenant systems.
Normalization: leading slashes are stripped and a trailing slash is added automatically. Both None and an empty string are treated as “no prefix.”