
    QЦi6                        S SK Jr  S SKJr  S SKJr  S SK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\ " S S5      5       r\ " S S5      5       r\ " S S5      5       r\ " S S5      5       r\ " S S5      5       r\ " S S5      5       rSS.S\S\\   S \\\\4      S!\\\\4      S"\\   S#\\\\\4      S$\\\\4      S%\\\4   4S& jjrg)'    )	dataclass)datetime)Enum)AnyOptionalUnion)	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   aH  
Enumeration of possible stage of a Job on the Hub.

Value can be compared to a string:
```py
assert JobStage.COMPLETED == "COMPLETED"
```
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).
	COMPLETEDCANCELEDERRORDELETEDRUNNING N)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   __static_attributes__r       X/var/www/html/ai-image-ml/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'   \\
\\4      \S'   \\S'   \\S'   \\S'   \\S'   SS jrSrg)JobInfo:   a  
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"`.
    labels (`dict[str, str]` or `None`):
        Labels to attach to the job (key-value pairs).
    status: (`JobStatus` or `None`):
        Status of the Job, e.g. `JobStatus(stage="RUNNING", message=None)`
        See [`JobStage`] for possible stage values.
    owner: (`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', 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'
```
r'   
created_atdocker_imagespace_idcommand	argumentsenvironmentsecretsflavorlabels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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.   spaceIdr/   r7   r(   r)   r'   r(   r)   r0   r1   r2   r3   r4   r5   r6   r    r!   )r    r!   r8   z/jobs//)r'   getr   r-   r.   r/   r%   r7   r0   r1   r2   r3   r4   r5   r   r6   r	   ENDPOINTr8   r(   r9   )selfkwargsr-   r7   r6   s        r   __init__JobInfo.__init__   sq   ,ZZ,H

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

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

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

:y/A/ABmm_F4::??*;1TWWIFr   )r1   r0   r-   r.   r8   r2   r4   r'   r5   r7   r3   r/   r6   r9   returnN)r   r   r   r   r   r#   r"   r   r   listdictr   r
   r   r%   rD   r   r   r   r   r+   r+   :   s    2h 	G""3-smd3i  S	""$sCx.))d38n%%]##T#s(^$$O M	HGr   r+   c                       \ rS rSr% \\   \S'   \\   \S'   \\\      \S'   \\\      \S'   \\\\	4      \S'   \\\\	4      \S'   \\
   \S'   \\   \S	'   \\\      \S
'   \\   \S'   \\\\4      \S'   SS jrSrg)JobSpec   r.   r/   r0   r1   r2   r3   r4   timeouttagsarchr5   Nc                 H   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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
5      U l        UR                  S5      U l	        UR                  S5      U l
        UR                  S5      U l        g )Nr<   r.   r=   r/   r0   r1   r2   r3   r4   rM   rN   rO   r5   )r@   r.   r/   r0   r1   r2   r3   r4   rM   rN   rO   r5   rB   rC   s     r   rD   JobSpec.__init__   s    "JJ}5SN9S

9-GJ1Gzz),K0!::m4zz),jj*zz),JJv&	JJv&	jj*r   )rO   r1   r0   r.   r2   r4   r5   r3   r/   rN   rM   rF   )r   r   r   r   r   r#   r"   rH   rI   r   r
   intrD   r   r   r   r   rK   rK      s    3-smd3i  S	""$sCx.))d38n%%]##c]
49

3-T#s(^$$+r   rK   c                   4    \ rS rSr% \\S'   \\S'   SS jrSrg)LastJobInfo   r'   atNc                 >    US   U l         [        US   5      U l        g )Nr'   rW   )r'   r   rW   rQ   s     r   rD   LastJobInfo.__init__   s    , .r   )rW   r'   rF   )	r   r   r   r   r#   r"   r   rD   r   r   r   r   rU   rU      s    GL/r   rU   c                   @    \ rS rSr% \\   \S'   \\   \S'   SS jrSr	g)ScheduledJobStatus   last_jobnext_job_run_atNc                 *   UR                  S5      =(       d    UR                  S5      nU(       a  [        S0 UD6OS U l        UR                  S5      =(       d    UR                  S5      nU(       a  [        [	        U5      5      U l        g S U l        g )NlastJobr]   nextJobRunAtr^   r   )r@   rU   r]   r   r#   r^   )rB   rC   r]   r^   s       r   rD   ScheduledJobStatus.__init__   sj    ::i(BFJJz,B3;/h/ **^4U

CT8UGV~c/.BC\`r   r]   r^   rF   )
r   r   r   r   r   rU   r"   r   rD   r   r   r   r   r[   r[      s    {##h''ar   r[   c                       \ rS rSr% Sr\\S'   \\   \S'   \	\S'   \\   \S'   \\
   \S'   \\
   \S'   \\S	'   \\S
'   SS jrSrg)ScheduledJobInfo   a9  
Contains information about a Job.

Args:
    id (`str`):
        Scheduled Job ID.
    created_at (`datetime` or `None`):
        When the scheduled Job was created.
    tags (`list[str]` or `None`):
        The tags of the scheduled Job.
    schedule (`str` or `None`):
        One of "@annually", "@yearly", "@monthly", "@weekly", "@daily", "@hourly", or a
        CRON schedule expression (e.g., '0 9 * * 1' for 9 AM every Monday).
    suspend (`bool` or `None`):
        Whether the scheduled job is suspended (paused).
    concurrency (`bool` or `None`):
        Whether multiple instances of this Job can run concurrently.
    status (`ScheduledJobStatus` or `None`):
        Status of the scheduled Job.
    owner: (`JobOwner` or `None`):
        Owner of the scheduled Job, e.g. `JobOwner(id="5e9ecfc04957053f60648a3e", name="lhoestq", type="user")`
    job_spec: (`JobSpec` or `None`):
        Specifications of the Job.

Example:

```python
>>> from huggingface_hub import run_job
>>> scheduled_job = create_scheduled_job(
...     image="python:3.12",
...     command=["python", "-c", "print('Hello from the cloud!')"],
...     schedule="@hourly",
... )
>>> scheduled_job.id
'687fb701029421ae5549d999'
>>> scheduled_job.status.next_job_run_at
datetime.datetime(2025, 7, 22, 17, 6, 25, 79000, tzinfo=datetime.timezone.utc)
```
r'   r-   job_specschedulesuspendconcurrencyr6   r7   Nc                    US   U l         UR                  S5      =(       d    UR                  S5      nU(       a  [        U5      OS U l        [	        S0 UR                  S5      =(       d    UR                  S0 5      D6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R                  S
5      =(       d    UR                  S5      UR                  S5      =(       d    UR                  S5      S9U l
        UR                  S0 5      n[        US   US   US   S9U l        g )Nr'   r;   r-   rg   jobSpecrh   ri   rj   r6   r]   r`   r^   ra   rc   r7   r(   r)   r>   r   )r'   r@   r   r-   rK   rg   rh   ri   rj   r[   r6   r%   r7   )rB   rC   r-   r6   r7   s        r   rD   ScheduledJobInfo.__init__   s   ,ZZ,H

<0H
8B.4X6::j#9#VVZZ	SU=VX

:.zz),!::m4Hb)(ZZ
+Dvzz)/D"JJ'89WVZZ=W
 

7B't5=uV}U
r   )rj   r-   r'   rg   r7   rh   r6   ri   rF   )r   r   r   r   r   r#   r"   r   r   rK   boolr[   r%   rD   r   r   r   r   re   re      sO    &P 	G""smd^$OVr   re   c                   V    \ rS rSr% Sr\\S'   \\S'   \\S'   \\S'   \\S'   SS	 jrS
rg)JobAcceleratori  a  
Contains information about a Job accelerator (GPU).

Args:
    type (`str`):
        Type of accelerator, e.g. `"gpu"`.
    model (`str`):
        Model of accelerator, e.g. `"T4"`, `"A10G"`, `"A100"`, `"L4"`, `"L40S"`.
    quantity (`str`):
        Number of accelerators, e.g. `"1"`, `"2"`, `"4"`, `"8"`.
    vram (`str`):
        Total VRAM, e.g. `"16 GB"`, `"24 GB"`.
    manufacturer (`str`):
        Manufacturer of the accelerator, e.g. `"Nvidia"`.
r)   modelquantityvrammanufacturerNc                 h    US   U l         US   U l        US   U l        US   U l        US   U l        g )Nr)   rq   rr   rs   rt   )r)   rq   rr   rs   rt   rQ   s     r   rD   JobAccelerator.__init__%  s<    6N	G_
z*6N	">2r   )rt   rq   rr   r)   rs   rF   )	r   r   r   r   r   r#   r"   rD   r   r   r   r   rp   rp     s(      IJM
I3r   rp   c                   z    \ rS rSr% Sr\\S'   \\S'   \\S'   \\S'   \\   \S'   \	\S'   \
\S	'   \\S
'   SS jrSrg)JobHardwarei-  a)  
Contains information about available Job hardware.

Args:
    name (`str`):
        Machine identifier, e.g. `"cpu-basic"`, `"a10g-large"`.
    pretty_name (`str`):
        Human-readable name, e.g. `"CPU Basic"`, `"Nvidia A10G - large"`.
    cpu (`str`):
        CPU specification, e.g. `"2 vCPU"`, `"12 vCPU"`.
    ram (`str`):
        RAM specification, e.g. `"16 GB"`, `"46 GB"`.
    accelerator (`JobAccelerator` or `None`):
        GPU/accelerator details if available.
    unit_cost_micro_usd (`int`):
        Cost in micro-dollars per unit, e.g. `167` (= $0.000167).
    unit_cost_usd (`float`):
        Cost in USD per unit, e.g. `0.000167`.
    unit_label (`str`):
        Cost unit period, e.g. `"minute"`.

Example:

```python
>>> from huggingface_hub import list_jobs_hardware
>>> hardware_list = list_jobs_hardware()
>>> hardware_list[0]
JobHardware(name='cpu-basic', pretty_name='CPU Basic', cpu='2 vCPU', ram='16 GB', accelerator=None, unit_cost_micro_usd=167, unit_cost_usd=0.000167, unit_label='minute')
>>> hardware_list[0].name
'cpu-basic'
```
r(   pretty_namecpuramacceleratorunit_cost_micro_usdunit_cost_usd
unit_labelNc                     US   U l         US   U l        US   U l        US   U l        UR	                  S5      nU(       a  [        S	0 UD6OS U l        US   U l        US   U l        US   U l	        g )
Nr(   
prettyNamerz   r{   r|   unitCostMicroUSDunitCostUSD	unitLabelr   )
r(   ry   rz   r{   r@   rp   r|   r}   r~   r   )rB   rC   r|   s      r   rD   JobHardware.__init__Y  sy    6N	!,/%=%=jj/<G>8K8T#)*<#= #M2 -r   )r|   rz   r(   ry   r{   r}   r~   r   rF   )r   r   r   r   r   r#   r"   r   rp   rS   floatrD   r   r   r   r   rx   rx   -  s@    B I	H	H.))O	.r   rx   N)r5   imager0   envr3   r4   rM   r5   rG   c                    U/ U=(       d    0 U=(       d    [         R                  S.nU(       a  X7S'   U(       aV  SSSSS.n[        U[        5      (       a,  US   U;   a#  [	        [        US S 5      XS      -  5      US	'   O[	        U5      US	'   U(       a  XgS
'   S H-  n	U R                  U	5      (       d  M  U [        U	5      S  US'     U$    XS'   U$ )N)r0   r1   r2   r4   r3      <   i  iQ )smhdtimeoutSecondsr5   )zhttps://huggingface.co/spaces/zhttps://hf.co/spaces/zhuggingface.co/spaces/zhf.co/spaces/r=   r<   )r
   	CPU_BASIC
isinstancer#   rS   r   
startswithlen)
r   r0   r   r3   r4   rM   r5   rg   time_units_factorsprefixs
             r   _create_job_specr   e  s     yb3M33	 H %#$2DyIgs##7I(I),U73B<-@CU^`VaCb-b)cH%&),WH%&# F##"'F"6HY O #(Or   )dataclassesr   r   enumr   typingr   r   r   huggingface_hubr	   huggingface_hub._space_apir
   huggingface_hub.utils._datetimer   r#   r   r   r%   r+   rK   rU   r[   re   rp   rx   rH   rI   rS   r   r   r   r   r   <module>r      s   "   ' ' % 4 :sD (   
    YG YG YGx + + +6 / / / a a a @V @V @VF 3 3 3> 4. 4. 4.~ (,** #Y* 
$sCx.	!	*
 d38n%* ]#* eCO,-* T#s(^$* 
#s(^*r   