huggingface_hub adds centralized hf:// URI and mount parsing
Introduced 2026-04-30 · score 0.92
HOW TO USE IT
When code accepts Hugging Face Hub locations or volume mount strings, parse locations with `parse_hf_uri` and mounts with `parse_hf_mount`. Call `.to_uri()` on each parsed value to emit its canonical string.
from huggingface_hub import parse_hf_uri, parse_hf_mount
uri = parse_hf_uri("hf://datasets/<namespace>/<dataset>@refs/pr/3/train.json")
canonical_uri = uri.to_uri()
mount = parse_hf_mount("hf://buckets/<namespace>/<bucket>/sub/dir:/mnt:ro")
canonical_mount = mount.to_uri()WHY THIS HELPS
When maintaining code that accepts Hub locations or volume mount specifications, parse and round-trip their `hf://` strings with the library helpers.
REQUIREMENTS AND LIMITATIONS
- Version: v1.13.0
- uri (required): `parse_hf_uri` input. HF URI syntax is `hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]`; ID is `<namespace>/<name>`. Type prefix is optional for models; datasets, spaces, kernels, and buckets use plural prefixes. Revision is optional and applies to repos; path is optional.
- endpoint: A custom Hub endpoint used by `parse_hf_uri` to recognize web URLs on that endpoint; it has no effect on `hf://` URIs.
- mount_str (required): `parse_hf_mount` input; must start with `hf://` and include a mount path. Syntax: `hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]:<MOUNT_PATH>[:ro|:rw]`.
- <MOUNT_PATH> (required): Absolute local mount path; must start with `/`.
- :ro | :rw: Optional read-only or read-write flag; the documented alternatives are mutually exclusive.
- Prerequisite: Use the v1.13.0-or-later `huggingface_hub` library version containing these helpers.
- Prerequisite: The helpers parse strings without network calls; no authentication setup is documented for parsing.
- The parsers are pure string parsers and make no network calls.
- The parser handles repo type prefixes, revisions, and paths and rejects invalid URI shapes.
FIRST-PARTY EVIDENCE
- https://github.com/huggingface/huggingface_hub/releases/tag/v1.13.0
- https://github.com/huggingface/huggingface_hub/pull/4158
- https://github.com/huggingface/huggingface_hub/blob/v1.13.0/docs/source/en/package_reference/hf_uris.md
- https://huggingface.co/docs/huggingface_hub/package_reference/hf_uris
Check the installed version and the source before using it. Entry JSON