Hub Python 庫文件

工作機會

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

作業

檢視 HfApi 文件頁面,瞭解管理 Hub 上的作業的方法參考。

資料結構

JobInfo

class huggingface_hub.JobInfo

< >

( **kwargs )

引數

  • id (str) — 作業 ID。
  • created_at (datetimeNone) — 作業建立時間。
  • docker_image (strNone) — 用於作業的 Docker Hub Docker 映象。如果存在 space_id,則可以為 None。
  • space_id (strNone) — 用於作業的 Hugging Face Spaces Docker 映象。如果存在 docker_image,則可以為 None。
  • command (List[str]None) — 作業命令,例如 ["python", "-c", "print('hello world')"]
  • arguments (List[str]None) — 傳遞給命令的引數
  • environment (Dict[str]None) — 作業的環境變數,以字典形式表示。
  • secrets (Dict[str]None) — 作業的秘密環境變數(已加密)。
  • flavor (strNone) — 硬體型別,與 Hugging Face Spaces 中的相同。有關可能的值,請參閱 SpaceHardware。例如 "cpu-basic"
  • status — (JobStatusNone): 作業狀態,例如 JobStatus(stage="RUNNING", message=None)。有關可能的階段值,請參閱 JobStage
  • status — (JobOwnerNone): 作業所有者,例如 JobOwner(id="5e9ecfc04957053f60648a3e", name="lhoestq", type="user")

包含有關作業的資訊。

示例

>>> 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', 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

class huggingface_hub.JobOwner

< >

( id: str name: str type: str )

JobStage

class huggingface_hub.JobStage

< >

( value names = None module = None qualname = None type = None start = 1 )

Hub 上作業可能階段的列舉。

值可以與字串進行比較

assert JobStage.COMPLETED == "COMPLETED"

取自 https://github.com/huggingface/moon-landing/blob/main/server/job_types/JobInfo.ts#L61 (私有 URL)。

JobStatus

class huggingface_hub.JobStatus

< >

( stage: JobStage message: typing.Optional[str] )

< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.