Skip to main content

hfget

PyPI Python versions License: MIT CI

Download models and datasets from the Hugging Face Hub, and continue partial files from where they stopped.

hfget takes the same arguments as hf download and saves files in the same layout, so transformers and the other Hugging Face tools find them. The difference: when a download is interrupted, hfget keeps the partial file and continues it, byte for byte.

Why

hf download (huggingface_hub 2.4) deletes a partial file when the download is interrupted. Running it again skips the files that finished, but a large file that was half done starts again from zero. On a slow or unstable connection, a 5 GB weight file can then take hours more.

hfget keeps every byte it has received:

What happens What hfget does
The network drops, or no data arrives for 60 seconds Waits and continues by itself. The wait doubles after each failed attempt, up to 60 seconds.
You press Ctrl+C, close the terminal, or the computer restarts Keeps the partial file. Run the same command again to continue.
More than 10 attempts in a row download nothing new Stops with a message. Run the download again to continue.
The repo is gated or private, or not found Stops at once with a message, because retrying will not help.

Install

pip install hfget

Or as a command-line tool with uv:

uv tool install hfget     # installs the `hfget` command
uvx hfget --help          # or run it once without installing

Requirements: Python 3.10 or newer, and curl on your PATH (it does the downloading). curl is preinstalled on macOS and most Linux systems. Otherwise: sudo apt install curl (Debian/Ubuntu) or brew install curl (macOS).

Quick start

# Download a model into a folder
hfget Qwen/Qwen3-0.6B --local-dir models/Qwen3-0.6B

# Or into the Hugging Face cache, where transformers looks for models
hfget Qwen/Qwen3-0.6B

# See what would be downloaded, without downloading
hfget Qwen/Qwen3-0.6B --local-dir models/Qwen3-0.6B --dry-run

# Only some files
hfget Qwen/Qwen3-0.6B config.json tokenizer.json --local-dir models/Qwen3-0.6B
hfget Qwen/Qwen3-0.6B --include "*.json" --local-dir models/Qwen3-0.6B

If the download stops, run the same command again. To check a folder later, also run the same command again: it prints All files are already downloaded. or downloads only what is missing.

What you see while downloading

In a terminal, two lines say what is downloaded and where. Below them, a live area shows one row per active file and a total row:

Qwen/Qwen3.5-4B @ 851bf6e8 → models/Qwen3.5-4B
2 files to download (2 resuming, 3.98 GB already on disk) · 12 already complete
✓ config.json  3.20 kB
↓ model.safetensors-00001-of-00002.safetensors  ━━━━━━━━━━━━━━╸─────   71%  3.80 / 5.30 GB  1.9 MB/s
↻ model.safetensors-00002-of-00002.safetensors  retry 2 in 4 s · no data for 60 s
  Total 1/2                                      ━━━━━━━━━━━━━╸──────   65%  6.10 / 9.32 GB  2.1 MB/s  ETA 26 min  elapsed 41 min
  • ↓ downloads, ↻ waits before a retry, and a spinner means the checksum is being checked.
  • A finished file leaves the live area and stays above it as a ✓ line.
  • Speeds cover the last 10 seconds and leave out bytes from earlier runs. ETA is the bytes left divided by the speed.
  • When the window gets narrower, the speed, then the byte counts, then the bar are dropped. Long names are shortened in the middle, so the ending stays visible. The live area redraws correctly after the terminal rewraps lines when you resize it.
  • At the end, a summary line replaces the live area, for example ✓ Downloaded 2 files (9.32 GB) in 1 h 12 min · average 2.1 MB/s.
  • Colors follow NO_COLOR. Plain ASCII characters are used if the terminal cannot show the Unicode ones.

When stderr is not a terminal (a log file or a pipe), or with --format agent, you get plain lines instead, about every 10 % or 30 seconds:

[ 42%] 3.91 / 9.32 GB · 2.1 MB/s · ETA 43 min

--quiet and --json show no progress.

Use it from Python

from hfget import download

path = download("Qwen/Qwen3-0.6B", local_dir="models/Qwen3-0.6B")
print(path)  # models/Qwen3-0.6B

download takes the same options as the command line: filenames, repo_type, revision, include, exclude, cache_dir, local_dir, force_download, token, max_workers and on_progress. It returns the folder, or the file if you asked for exactly one file by name.

To look before you download, split it in two steps:

from hfget import execute_plan, plan_download

plan = plan_download("Qwen/Qwen3-0.6B", local_dir="models/Qwen3-0.6B")
print(f"{len(plan.pending)} of {len(plan.files)} files, {plan.bytes_to_download} bytes to download")
execute_plan(plan)

To follow the progress, pass a callback. It receives a DownloadProgress snapshot about four times a second:

from hfget import DownloadProgress, download


def show(progress: DownloadProgress) -> None:
    print(f"{progress.done_bytes} / {progress.total_bytes} bytes")
    for file in progress.files:
        print(f"  {file.path}: {file.state.name} {file.bytes_on_disk} / {file.size}")


download("Qwen/Qwen3-0.6B", filenames=["config.json"], local_dir="models/qwen", on_progress=show)

The library never prints. It logs through the standard logging module under the hfget logger, and raises hfget.DownloadError (a problem retrying will not fix) or hfget.StoppedError (the download was stopped). Partial files are always kept, so calling download again continues them.

Command-line options

The options match hf download:

Option Meaning
REPO_ID The repo, for example Qwen/Qwen3-0.6B. datasets/..., spaces/... and hf://... forms also work.
FILENAMES... Only these files. A name that ends with / means a whole folder.
--type, --repo-type model (default), dataset, space or kernel
--revision A branch, tag or commit. Default: main.
--include / --exclude Glob patterns, for example --include "*.json". Repeat the option for more patterns.
--local-dir Save the files in this folder.
--cache-dir Hugging Face cache folder, used when --local-dir is not set. Default: ~/.cache/huggingface/hub.
--force-download Download files again even if they are already complete. Partial files are still continued.
--dry-run Only show what would be downloaded.
--token Hugging Face access token. Default: your saved login (hf auth login) or HF_TOKEN.
--max-workers Number of files downloaded at the same time. Default: 8.
--format, --json, -q / --quiet Output format. human shows the live progress area, agent prints plain progress lines, auto (default) picks human in a terminal and agent otherwise.
--no-truncate Accepted so hf download commands work unchanged. It has no effect.
--version Print the version.

How it works

  1. Find the files. The huggingface_hub library gets the commit of the requested revision and lists every file with its size and checksum.
  2. Choose the files. File names and --include / --exclude patterns are matched with the library's own matching function, so the selection is the same as hf download.
  3. Skip finished files. A file is skipped when it already exists with the right size and checksum record.
  4. Download. curl --continue-at - downloads each file into an .incomplete file. After an interruption, curl asks the server only for the bytes that are still missing.
  5. Check. When a file is complete, its checksum is compared with the one from the Hub (sha256 for large files, the git blob id for small ones). A file that does not match is downloaded again.
  6. Move into place. The file is moved to its final name and its record is written.

Your access token is passed to curl on stdin, so it never shows in the process list.

Where the files go

With --local-dir models/Qwen3-0.6B:

models/Qwen3-0.6B/
├── config.json, tokenizer.json, ...      finished files
└── .cache/huggingface/download/
    ├── <file>.metadata                   record: commit, checksum, time
    └── <file>.incomplete                 partial file while downloading

Without --local-dir, files go to the Hugging Face cache (blobs/, snapshots/, refs/). Both layouts are the same as hf download writes them, so you can mix the two tools.

Platform support

  • Tested on Linux and macOS, with Python 3.10 to 3.14.
  • Windows is not tested yet. The cache layout uses symlinks, which need Developer Mode on Windows.
  • The live display is built for terminals that rewrap lines when you resize them, as most modern terminals do. It is tested in tmux. In terminals that cut long lines instead, such as classic xterm, shrinking the window may erase a few lines above the live area.

Development

git clone https://github.com/msharara1998/hfget
cd hfget
uv sync
uv run ruff format && uv run ruff check && uv run ty check
uv run pytest               # offline tests
uv run pytest -m network    # also downloads a small real file from the Hub

License

MIT. See LICENSE.

Metadata

Release files for hfget 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hfget 0.1.0
File Size Uploaded Provenance Actions
hfget-0.1.0.tar.gz 38.4 kB Without provenance Details for hfget-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hfget 0.1.0
File Interpreter ABI Platform Actions
hfget-0.1.0-py3-none-any.whl Python 3 none any Details for hfget-0.1.0-py3-none-any.whl

Total release size: 81.9 kB

Release files / hfget-0.1.0.tar.gz

Download URL hfget-0.1.0.tar.gz
Size 38.4 kB
Tags Source
SHA-256 checksum
How to use checksums
577351c55fa9de9e1208bfe579c7093b4992a2992831b9970ebd57b479d9072e
BLAKE2b-256 checksum
How to use checksums
01fe436d2d1ec63c17d6bb0260966bddda5f505a2b6d5560533bef4df5329c14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / hfget-0.1.0-py3-none-any.whl

Download URL hfget-0.1.0-py3-none-any.whl
Size 43.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad44bd47360ea2c38030ffec7e7b36d69aa5a01c4674a8b306f9ed6bd35de65b
BLAKE2b-256 checksum
How to use checksums
5a7fdd32719cab59e7afcd0908819058660bac30e703ed86b43eaac4426d6a71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for hfget 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page