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 (v2.4.0).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Jobs

Hub에서 Jobs를 관리하는 메서드에 대한 참조는 HfApi 문서 페이지를 확인하세요.

데이터 구조

JobInfo

클래스 huggingface_hub.JobInfo

< >

( **kwargs )

매개변수

  • id (str) — Job ID입니다.
  • created_at (datetime 또는 None) — Job이 생성된 시각.
  • started_at (datetime 또는 None) — Job이 실행을 시작한 시점입니다. Job이 여전히 스케줄링 중인 경우 None입니다.
  • finished_at (datetime 또는 None) — Job이 완료된 시점입니다. Job이 여전히 스케줄링 중이거나 실행 중이면 None입니다.
  • docker_image (str 또는 None) — Job에 사용되는 Docker Hub의 Docker 이미지입니다. space_id가 대신 존재하는 경우 None일 수 있습니다.
  • space_id (str 또는 None) — Job에 사용되는 Hugging Face Spaces의 Docker 이미지입니다. docker_image가 대신 존재하는 경우 None일 수 있습니다.
  • command (list[str] 또는 None) — Job의 명령어, 예: ["python", "-c", "print('hello world')"]
  • arguments (list[str] 또는 None) — 명령에 전달되는 인자
  • environment (dict[str] 또는 None) — Job의 환경 변수를 딕셔너리로 나타냅니다.
  • secrets (dict[str] 또는 None) — Job의 비밀 환경 변수(암호화됨).
  • flavor (str 또는 None) — 하드웨어의 Flavor입니다. 가능한 값은 JobHardware를 참고하세요. 예: "cpu-basic".
  • labels (dict[str, str] 또는 None) — 작업에 연결할 라벨(키-값 쌍).
  • volumes (list[Volume] 또는 None) — 작업 컨테이너에 마운트된 볼륨(버킷, 모델, 데이터셋, 스페이스).
  • status — (JobStatus 또는 None): Job의 상태, 예: JobStatus(stage="RUNNING", message=None) 가능한 stage 값은 JobStage를 참조하세요.
  • durations (JobDurations 또는 None) — Job의 시간별 세부 정보입니다. SCHEDULING을 포함한 모든 job 상태에 존재합니다.
  • owner — (JobOwner 또는 None): Job의 소유자, 예: JobOwner(id="5e9ecfc04957053f60648a3e", name="lhoestq", type="user")
  • initiator (JobInitiator 또는 None) — Job을 트리거한 요소입니다. 예를 들어, cron으로 트리거된 실행의 경우 JobInitiator(type="scheduled-job", id="...")입니다.
  • expose_urls (list[str] 또는 None) — Job의 노출된 포트에 접근할 수 있는 공개 URL 목록(노출된 포트당 하나)입니다. 예: ["https://687fb701029421ae5549d998--8000.hf.jobs"]. 포트가 노출되지 않은 경우 None입니다. 포트가 공개되어 있지 않은 경우, 해당 URL에 접근하려면 Job의 namespace에 대한 읽기 권한이 있는 HF 토큰이 필요합니다.
  • ssh_url (str 또는 None) — Job의 SSH 엔드포인트입니다. 예: "ssh://687fb701029421ae5549d998@ssh.hf.jobs". Job이 ssh=True로 시작된 경우에만 존재합니다. 연결하려면 Job의 namespace에 대한 쓰기 권한과 Hub에 등록된 SSH 공개 키(https://huggingface.co/settings/keys)가 필요합니다.
  • network (JobNetwork 또는 None) — Job이 참여한 Network 그룹과 해당 Job이 주장하는 별칭입니다. 예: JobNetwork(group="train", aliases=["master"]). network_group= 없이 Job이 시작된 경우 None입니다.
  • retry (int 또는 None) — Job에 구성된 재시도 횟수(attempts - 1).
  • expose (list[int] 또는 None) — Jobs 프록시를 통해 노출되는 모든 포트입니다. 공개 포트도 포함됩니다.
  • expose_public (list[int] 또는 None) — 인증 없이 접근할 수 있는 공개 포트입니다.

Job에 대한 정보를 포함합니다.

예:

>>> 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), started_at=datetime.datetime(2025, 7, 22, 16, 6, 31, 79000, tzinfo=datetime.timezone.utc), finished_at=None, 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), durations=JobDurations(scheduling_secs=6, running_secs=2, total_secs=8), owner=JobOwner(id='5e9ecfc04957053f60648a3e', name='lhoestq', type='user'), initiator=JobInitiator(type='user', id='5e9ecfc04957053f60648a3e', name='lhoestq'), 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: strname: strtype: str )

JobNetwork

class huggingface_hub.JobNetwork

< >

( **kwargs )

매개변수

  • group (str) — network_group=에 전달된 네트워크 그룹 이름.
  • aliases (list[str]) — network_aliases=에 전달된 값으로, Job이 그룹에서 주장하는 별칭입니다. 없으면 비어 있습니다.

Network group a Job이 참여했습니다.

JobStage

class huggingface_hub.JobStage

< >

( valuenames = Nonemodule = Nonequalname = Nonetype = Nonestart = 1 )

Hub에서 Job의 가능한 상태를 나열합니다.

Value는 문자열과 비교할 수 있습니다:

assert JobStage.COMPLETED == "COMPLETED"
Possible values are: `COMPLETED`, `CANCELED`, `ERROR`, `DELETED`, `SCHEDULING`, `RUNNING`. Taken from https://github.com/huggingface/moon-landing/blob/main/server/job_types/JobInfo.ts#L61 (private url).

JobStatus

클래스 huggingface_hub.JobStatus

< >

( stage: JobStagemessage: str | Noneexpose_urls: list[str] | Nonessh_url: str | None )

볼륨

class huggingface_hub.Volume

< >

( **kwargs )

매개변수

  • type (str) — 볼륨의 유형: "bucket", "model", "dataset" 또는 "space".
  • source (str) — 소식 식별자, 예: "username/my-bucket" 또는 "username/my-model".
  • mount_path (str) — 컨테이너 내부의 마운트 경로입니다. 예: "/data". /로 시작해야 합니다.
  • revision (str 또는 None) — Git 리비전(레포지토리에서만 사용되며, 기본값은 "main"입니다).
  • read_only (bool 또는 None) — 읽기 전용 마운트. 리포지토리의 경우 True로 고정되며, 버킷의 경우 기본값은 False입니다.
  • path (str 또는 None) — 마운트할 버킷/리포지토리 내부의 서브폴더 접두사입니다. 예: "path/to/dir".

Space 또는 Job 컨테이너에 마운트할 볼륨을 설명합니다.

to_dict

< >

( )

Hub API에서 예상하는 JSON 페이로드로 직렬화합니다.

to_uri

< >

( )

CLI에서 기대하는 형식으로 볼륨을 HF 마운트 URI로 반환합니다.

Update on GitHub