huggingface_hub v2.3.0 lists an 800,000-file dataset in 20 seconds, down from 13 minutes

2 hours ago

huggingface_hub v2.3.0: HfFileSystem lists large repos in parallel (an 800,000-file dataset in about 20 seconds instead of 13 minutes), Bucket listings that refresh live, attachments in Hub discussions, one-request safetensors shard headers, and fixes for create_commit, hf jobs run, InferenceClient and custom endpoints. https://github.com/huggingface/huggingface_hub/releases/tag/v2.3.0 https://github.com/huggingface/huggingface_hub/compare/v2.2.0...v2.3.0

Ask

Ask about this presentation

Answers are generated from this presentation.

Chapters

  1. 0:00Large repos list in parallel
  2. 0:15Shallow listings stop early
  3. 0:28Bucket listings stay fresh
  4. 0:44Live follow limits
  5. 0:5802: Discussions and models
  6. 1:00Attachments in discussions
  7. 1:15Shard headers in one request
  8. 1:28Gated repos that hide requesters
  9. 1:4403: Fixes
  10. 1:46create_commit keeps re-added files
  11. 1:59hf jobs run keeps streaming
  12. 2:12Queued Jobs show their status
  13. 2:26InferenceClient fixes
  14. 2:41Endpoint, offline and Bucket fixes
  15. 2:56The biggest repo you list
Show transcript

Large repos list in parallel

010203HfFileSystem
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5153
Hugging Face

huggingface_hub v2.3.0 lists large repos in parallel

allenai/objaverse · 798,924 files776 s → 19.7 s

huggingface_hub 2.3 lists large repos in parallel. Listing every file in the objaverse dataset, almost 800,000 of them, took about 13 minutes. Now it takes about 20 seconds.

Shallow listings stop early

huggingface_hub v2.3.0
010203HfFileSystem
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5153

A two-level listing now stops at two levels

datasets/allenai/objaversebeforeafter
find(), 798,924 files801 requests, 776 s807 requests, 19.7 s
find(maxdepth=2), 328 entries801 requests, 776 s6 requests, 1.5 s

The Hub sends a file tree a thousand entries at a time, each page after the last, so the library now lists folders side by side. And a listing two levels deep stops at two levels, in six requests.

Bucket listings stay fresh

huggingface_hub v2.3.0
010203HfFileSystem
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5096

Bucket listings update while another process writes

HfFileSystem(live_follow=True)
fsspecpandaspyarrow

HfFileSystem caches folder listings, so files another process added to a Bucket stayed hidden until you cleared the cache. With live follow, the Hub sends each change and the stale listing is dropped. It works from pandas and pyarrow too.

Live follow limits

huggingface_hub v2.3.0
010203HfFileSystem
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5096

Live follow is off by default, and Buckets only

One open connectionper followed Bucket
Listings and metadatafile reads already fetch from the Hub
Model, dataset and Space reposnot supported

It's off by default, because it keeps a connection open for every Bucket it follows. It only refreshes listings, since reading a file always fetches it from the Hub. Model, dataset and Space repos don't get it.

02: Discussions and models

huggingface_hub v2.3.0
010203Discussions and models
02
Discussions and models

Discussions, models and gated repos.

Attachments in discussions

huggingface_hub v2.3.0
010203Discussions and models
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5161

Attach images, video and audio to discussions and PRs

api.upload_attachment("screenshot.png")

hf discussions create … --attach ./after.png

Discussions and pull requests on the Hub can now carry images, video and audio, from Python or from the hf command line. Before, that meant calling an undocumented Hub endpoint by hand.

Shard headers in one request

huggingface_hub v2.3.0
010203Discussions and models
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5159

Every safetensors shard header in one request

get_sharded_safetensors_metadata reads the main revision only. get_safetensors_metadata is unchanged.

Reading the safetensors headers of a sharded model took one request per shard. A new function gets them all in one. It only reads the main revision, and the old function is unchanged.

Gated repos that hide requesters

huggingface_hub v2.3.0
010203Discussions and models
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5047

Access requests work on repos that hide who asked

Listing requestsused to fail with a KeyError
Each requestnow has a request_id to accept or reject it by
username, fullnamenow typed str | None

Gated repos can now hide the name and email of people asking for access. Listing their requests used to crash. Now you accept each request by its own identifier. Type checkers may flag code that expects a username.

03: Fixes

huggingface_hub v2.3.0
010203Fixes
03
Fixes

Fixes you may have hit.

create_commit keeps re-added files

huggingface_hub v2.3.0
010203Fixes
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5196

create_commit keeps files you re-add after a delete

CommitOperationDelete("x/", is_folder=True),
# unchanged on the Hub:
CommitOperationAdd("x/a.txt", b"keep me\n"),

# before: x/a.txt is deleted
# after:  x/a.txt is kept

Since version 0.24, deleting a folder and pushing the same unchanged files back in one commit removed those files from the repo, without any error. Now the files are kept.

hf jobs run keeps streaming

huggingface_hub v2.3.0
010203Fixes
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5162

hf jobs run keeps streaming logs

hf jobs run before and after: logs keep streaming and Ctrl+C exits with a hint

hf jobs run used to stop printing logs when the stream ended before the Job did. It now reconnects until the Job finishes, and Control C exits right away with a hint on how to follow or cancel it.

Queued Jobs show their status

huggingface_hub v2.3.0
010203Fixes
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5163

A Job waiting for hardware says so

hf jobs run showing the scheduling status while the Job waits for hardware

While a Job waited for hardware, the CLI printed nothing, so it looked stuck. Now it shows the Hub's status message and how long the Job has been waiting, in interactive terminals only.

InferenceClient fixes

huggingface_hub v2.3.0
010203Fixes
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5197 · #5200 · #5150

InferenceClient frees memory and unblocks async

Non-streaming responsesfreed after each call; 30 calls with a 1 MB prompt held 30 MB
AsyncInferenceClientqueue-based providers such as fal-ai no longer freeze the event loop
timeoutraises InferenceTimeoutError, as documented

A reused Inference Client stops holding every finished response in memory. The async client stops freezing your event loop while queue-based providers like fal work. And a timeout raises the documented timeout error.

Endpoint, offline and Bucket fixes

huggingface_hub v2.3.0
010203Fixes
huggingface/huggingface_hub · GitHub release notes v2.3.0 · #5149 · #5199 · #5237

Your token stays on your endpoint

HfApi(endpoint=...)20 methods went to huggingface.co with your token
HF_HUB_OFFLINE=1a pinned download could delete the file in local_dir
push_to_hub into a new Bucketfailed with FileNotFoundError since v2.2.0

With a custom endpoint, 20 methods were sent to huggingface dot co with your token. In offline mode, a pinned download could delete your local copy. And pushing a dataset into a new Bucket works again.

The biggest repo you list

huggingface_hub v2.3.0
010203Fixes
huggingface/huggingface_hub · GitHub release notes v2.3.0

How many files are in the biggest repo you list?

Release notes: github.com/huggingface/huggingface_hub › Releases › v2.3.0

The full list is in the 2.3 release notes on GitHub. So, how many files are in the biggest repo you list with HfFileSystem?