hf jobs stats and fetch_job_metrics return a snapshot by default
Introduced 2026-10-08 · score 0.98
HOW TO USE IT
For a running job, use `hf jobs stats <job-id>` or `fetch_job_metrics(job_id=..., follow=False)` to read the current metrics sample and return without waiting. Add `-f/--follow` or `follow=True` to stream until the job completes.
hf jobs stats <job-id>hf jobs stats --format json <job-id>from huggingface_hub import fetch_job_metrics
for metrics in fetch_job_metrics(job_id="<job-id>", follow=False):
print(metrics)WHY THIS HELPS
Read metrics for a running job in a script or coding-agent workflow without waiting for the job to finish.
BEFORE THIS CHANGE
`hf jobs stats` and `HfApi.fetch_job_metrics` streamed metrics until the job finished, so callers of a running job could wait until their own timeout.
REQUIREMENTS AND LIMITATIONS
- Version: v2.2.0
- JOB_IDS: One or more job IDs; the CLI docs also allow `namespace/job_id`.
- -f, --follow: Stream live stats until the jobs complete; without it, print one snapshot.
- --format: The v2.2.0 release lists `json`, `agent`, and `quiet` for raw API metrics in snapshot output.
- job_id (required): The job ID for `fetch_job_metrics`.
- follow: Defaults to `False` and returns the current sample; `True` streams until the job completes, according to the v2.2.0 release.
- Snapshot output prints the latest sample of each job once and exits.
- Pass `follow=True` or use `-f/--follow` to stream until the job completes.
- Docs conflict: The current CLI reference documents `-f/--follow` and snapshot output but does not list `--format` under `hf jobs stats`; the v2.2.0 release explicitly says snapshot output supports `--format json|agent|quiet`. https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/package_reference/cli.md
FIRST-PARTY EVIDENCE
- https://github.com/huggingface/huggingface_hub/releases/tag/v2.2.0
- https://github.com/huggingface/huggingface_hub/pull/5091
- https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/package_reference/cli.md
- https://huggingface.co/docs/huggingface_hub/v2.1.1/en/package_reference/hf_api
Check the installed version and the source before using it. Entry JSON