
    ,h                         S SK Jr  S SKJr  S SKJr  S SKJrJrJrJ	r	  S SK
Jr  S SKJr  S SKJr   " S S	\\5      r\ " S
 S5      5       r\ " S S5      5       r\ " S S5      5       rg)    )	dataclass)datetime)Enum)AnyDictListOptional)	constants)SpaceHardware)parse_datetimec                   ,    \ rS rSrSrSrSrSrSrSr	Sr
g	)
JobStage   z
Enumeration of possible stage of a Job on the Hub.

Value can be compared to a string:
```py
assert JobStage.COMPLETED == "COMPLETED"
```

Taken from https://github.com/huggingface/moon-landing/blob/main/server/job_types/JobInfo.ts#L61 (private url).
	COMPLETEDCANCELEDERRORDELETEDRUNNING N)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   __static_attributes__r       Q/var/www/html/shao/venv/lib/python3.13/site-packages/huggingface_hub/_jobs_api.pyr   r      s"    	 IHEGGr   r   c                   0    \ rS rSr% \\S'   \\   \S'   Srg)	JobStatus-   stagemessager   N)	r   r   r   r   r   __annotations__r	   strr   r   r   r   r   r   -   s    Oc]r   r   c                   4    \ rS rSr% \\S'   \\S'   \\S'   Srg)JobOwner3   idnametyper   N)r   r   r   r   r$   r#   r   r   r   r   r&   r&   3   s    G
I
Ir   r&   c                       \ rS rSr% Sr\\S'   \\   \S'   \\   \S'   \\   \S'   \\	\      \S'   \\	\      \S'   \\
\\4      \S	'   \\
\\4      \S
'   \\   \S'   \\S'   \\S'   \\S'   \\S'   SS jrSrg)JobInfo:   as  
Contains information about a Job.

Args:
    id (`str`):
        Job ID.
    created_at (`datetime` or `None`):
        When the Job was created.
    docker_image (`str` or `None`):
        The Docker image from Docker Hub used for the Job.
        Can be None if space_id is present instead.
    space_id (`str` or `None`):
        The Docker image from Hugging Face Spaces used for the Job.
        Can be None if docker_image is present instead.
    command (`List[str]` or `None`):
        Command of the Job, e.g. `["python", "-c", "print('hello world')"]`
    arguments (`List[str]` or `None`):
        Arguments passed to the command
    environment (`Dict[str]` or `None`):
        Environment variables of the Job as a dictionary.
    secrets (`Dict[str]` or `None`):
        Secret environment variables of the Job (encrypted).
    flavor (`str` or `None`):
        Flavor for the hardware, as in Hugging Face Spaces. See [`SpaceHardware`] for possible values.
        E.g. `"cpu-basic"`.
    status: (`JobStatus` or `None`):
        Status of the Job, e.g. `JobStatus(stage="RUNNING", message=None)`
        See [`JobStage`] for possible stage values.
    status: (`JobOwner` or `None`):
        Owner of the Job, e.g. `JobOwner(id="5e9ecfc04957053f60648a3e", name="lhoestq", type="user")`

Example:

```python
>>> 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'
```
r(   
created_atdocker_imagespace_idcommand	argumentsenvironmentsecretsflavorstatusownerendpointurlNc                    US   U l         UR                  S5      =(       d    UR                  S5      nU(       a  [        U5      OS U l        UR                  S5      =(       d    UR                  S5      U l        UR                  S5      =(       d    UR                  S5      U l        UR                  S0 5      n[        US   US	   US
   S9U l        UR                  S5      U l        UR                  S5      U l	        UR                  S5      U l
        UR                  S5      U l        UR                  S5      U l        UR                  S0 5      n[        US   UR                  S5      S9U l        UR                  S[        R                   5      U l        U R"                   SU R                  R$                   SU R                    3U l        g )Nr(   	createdAtr.   dockerImager/   spaceIdr0   r7   r)   r*   )r(   r)   r*   r1   r2   r3   r4   r5   r6   r!   r"   )r!   r"   r8   z/jobs//)r(   getr   r.   r/   r0   r&   r7   r1   r2   r3   r4   r5   r   r6   r
   ENDPOINTr8   r)   r9   )selfkwargsr.   r7   r6   s        r   __init__JobInfo.__init__~   sa   ,ZZ,H

<0H
8B.4"JJ}5SN9S

9-GJ1G

7B't5=uV}U
zz),K0!::m4zz),jj*Hb)fWovzz)?TU 

:y/A/ABmm_F4::??*;1TWWIFr   )r2   r1   r.   r/   r8   r3   r5   r(   r7   r4   r0   r6   r9   )returnN)r   r   r   r   r   r$   r#   r	   r   r   r   r   r   r   r&   rC   r   r   r   r   r,   r,   :   s    0d 	G""3-smd3i  S	""$sCx.))d38n%%]##O M	HGr   r,   N)dataclassesr   r   enumr   typingr   r   r   r	   huggingface_hubr
   huggingface_hub._space_apir   huggingface_hub.utils._datetimer   r$   r   r   r&   r,   r   r   r   <module>rL      s~    "   , , % 4 :sD (   
    UG UG UGr   