Hub Python Library documentation
Jobs
You are viewing main version, which requires installation from source. If you'd like
regular pip install, checkout the latest stable version (v1.7.1).
Jobs
Check the HfApi documentation page for the reference of methods to manage your Jobs on the Hub.
- Run a Job: run_job()
- Fetch logs: fetch_job_logs()
- Fetch metrics: fetch_job_metrics()
- Inspect Job: inspect_job()
- List Jobs: list_jobs()
- Cancel Job: cancel_job()
- Run a UV Job: run_uv_job()
Data structures
JobInfo
class huggingface_hub.JobInfo
< source >( **kwargs )
Parameters
- id (
str) — Job ID. - created_at (
datetimeorNone) — When the Job was created. - docker_image (
strorNone) — The Docker image from Docker Hub used for the Job. Can be None if space_id is present instead. - space_id (
strorNone) — The Docker image from Hugging Face Spaces used for the Job. Can be None if docker_image is present instead. - command (
list[str]orNone) — Command of the Job, e.g.["python", "-c", "print('hello world')"] - arguments (
list[str]orNone) — Arguments passed to the command - environment (
dict[str]orNone) — Environment variables of the Job as a dictionary. - secrets (
dict[str]orNone) — Secret environment variables of the Job (encrypted). - flavor (
strorNone) — Flavor for the hardware, as in Hugging Face Spaces. See SpaceHardware for possible values. E.g."cpu-basic". - labels (
dict[str, str]orNone) — Labels to attach to the job (key-value pairs). - volumes (
list[Volume]orNone) — Volumes mounted in the job container (buckets, models, datasets, spaces). - status — (
JobStatusorNone): Status of the Job, e.g.JobStatus(stage="RUNNING", message=None)See JobStage for possible stage values. - owner — (
JobOwnerorNone): Owner of the Job, e.g.JobOwner(id="5e9ecfc04957053f60648a3e", name="lhoestq", type="user")
Contains information about a Job.
Example:
>>> from huggingface_hub import run_job
>>> job = run_job(
... image="python:3.12",
... command=["python", "-c", "print('Hello from the cloud!')"]
... )
>>> job
JobInfo(id='687fb701029421ae5549d998', created_at=datetime.datetime(2025, 7, 22, 16, 6, 25, 79000, tzinfo=datetime.timezone.utc), docker_image='python:3.12', space_id=None, command=['python', '-c', "print('Hello from the cloud!')"], arguments=[], environment={}, secrets={}, flavor='cpu-basic', labels=None, status=JobStatus(stage='RUNNING', message=None), owner=JobOwner(id='5e9ecfc04957053f60648a3e', name='lhoestq', type='user'), endpoint='https://huggingface.co', url='https://huggingface.co/jobs/lhoestq/687fb701029421ae5549d998')
>>> job.id
'687fb701029421ae5549d998'
>>> job.url
'https://huggingface.co/jobs/lhoestq/687fb701029421ae5549d998'
>>> job.status.stage
'RUNNING'JobOwner
JobStage
class huggingface_hub.JobStage
< source >( value names = None module = None qualname = None type = None start = 1 )
Enumeration of possible stage of a Job on the Hub.
Possible values are: `COMPLETED`, `CANCELED`, `ERROR`, `DELETED`, `RUNNING`. Taken from https://github.com/huggingface/moon-landing/blob/main/server/job_types/JobInfo.ts#L61 (private url).JobStatus
Volume
class huggingface_hub.Volume
< source >( **kwargs )
Parameters
- type (
str) — Type of volume:"bucket","model","dataset", or"space". - source (
str) — Source identifier, e.g."username/my-bucket"or"username/my-model". - mount_path (
str) — Mount path inside the container, e.g."/data". Must start with/. - revision (
strorNone) — Git revision (only for repos, defaults to"main"). - read_only (
boolorNone) — Read-only mount. ForcedTruefor repos, defaults toFalsefor buckets. - path (
strorNone) — Subfolder prefix inside the bucket/repo to mount, e.g."path/to/dir".
Describes a volume to mount in a Job container.