Ë
    çÍ:jƒ*  ã                   ó¾  — d dl mZ d dlmZ d dlmZ d dlmZmZmZm	Z	m
Z
 d dlmZ d dlmZ d dlmZ  G d„ d	ee«      Ze G d
„ d«      «       Ze G d„ d«      «       Ze G d„ d«      «       Ze G d„ d«      «       Ze G d„ d«      «       Ze G d„ d«      «       Ze G d„ d«      «       Zdedee   de	eeef      de	eeef      de	e   de	e
eeef      deeef   fd„Zy )!é    )Ú	dataclass)Údatetime)ÚEnum)ÚAnyÚDictÚListÚOptionalÚUnion)Ú	constants)ÚSpaceHardware)Úparse_datetimec                   ó$   — e Zd ZdZdZdZdZdZdZy)ÚJobStageah  
    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ÚRUNNINGN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   © ó    ún/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/huggingface_hub/_jobs_api.pyr   r      s"   „ ñ	ð €IØ€HØ€EØ€GØ�Gr   r   c                   ó(   — e Zd ZU eed<   ee   ed<   y)Ú	JobStatusÚstageÚmessageN)r   r   r   r   Ú__annotations__r	   Ústrr   r   r   r   r   -   s   … àƒOØ�c‰]Ôr   r   c                   ó,   — e Zd ZU eed<   eed<   eed<   y)ÚJobOwnerÚidÚnameÚtypeN)r   r   r   r!   r    r   r   r   r#   r#   3   s   … àƒGØ
ƒIØ
„Ir   r#   c                   óì   — e Zd ZU dZeed<   ee   ed<   ee   ed<   ee   ed<   eee      ed<   eee      ed<   ee	ee
f      ed<   ee	ee
f      ed	<   ee   ed
<   eed<   eed<   eed<   eed<   dd„Zy)ÚJobInfoa&	  
    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.
        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', 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                 óˆ  — |d   | _         |j                  d«      xs |j                  d«      }|rt        |«      nd | _        |j                  d«      xs |j                  d«      | _        |j                  d«      xs |j                  d«      | _        |j                  di «      }t        |d   |d	   |d
   ¬«      | _        |j                  d«      | _        |j                  d«      | _	        |j                  d«      | _
        |j                  d«      | _        |j                  d«      | _        |j                  di «      }t        |d   |j                  d«      ¬«      | _        |j                  dt        j                   «      | _        | j"                  › d| j                  j$                  › d| j                   › �| _        y )Nr$   Ú	createdAtr)   ÚdockerImager*   ÚspaceIdr+   r2   r%   r&   ©r$   r%   r&   r,   r-   r.   r/   r0   r1   r   r   )r   r   r3   z/jobs/ú/)r$   Úgetr   r)   r*   r+   r#   r2   r,   r-   r.   r/   r0   r   r1   r   ÚENDPOINTr3   r%   r4   )ÚselfÚkwargsr)   r2   r1   s        r   Ú__init__zJobInfo.__init__~   sa  € Ø˜‘,ˆŒØ—Z‘Z Ó,ÒH°·
±
¸<Ó0Hˆ
Ù8Bœ.¨Ô4ÈˆŒØ"ŸJ™J }Ó5ÒS¸¿¹ÀNÓ9SˆÔØŸ
™
 9Ó-ÒG°·±¸JÓ1GˆŒØ—
‘
˜7 BÓ'ˆÜ  t¡°5¸±=ÀuÈVÁ}ÔUˆŒ
Ø—z‘z )Ó,ˆŒØŸ™ KÓ0ˆŒØ!Ÿ:™: mÓ4ˆÔØ—z‘z )Ó,ˆŒØ—j‘j Ó*ˆŒØ—‘˜H bÓ)ˆÜ f¨W¡o¸v¿z¹zÈ)Ó?TÔUˆŒð Ÿ
™
 :¬y×/AÑ/AÓBˆŒØ—m‘m�_ F¨4¯:©:¯?©?Ð*;¸1¸T¿W¹W¸IÐFˆ�r   ©ÚreturnN)r   r   r   r   r!   r    r	   r   r   r   r   r   r   r#   r?   r   r   r   r(   r(   :   sš   … ñ0ðd 	ƒGØ˜Ñ"Ó"Ø˜3‘-ÓØ�s‰mÓØ�d˜3‘iÑ Ó Ø˜˜S™	Ñ"Ó"Ø˜$˜s C˜x™.Ñ)Ó)Ø�d˜3 ˜8‘nÑ%Ó%Ø�]Ñ#Ó#ØÓØƒOð ƒMØ	ƒHôGr   r(   c                   óÜ   — e Zd ZU ee   ed<   ee   ed<   eee      ed<   eee      ed<   eeeef      ed<   eeeef      ed<   ee	   ed<   ee
   ed<   eee      ed	<   ee   ed
<   dd„Zy)ÚJobSpecr*   r+   r,   r-   r.   r/   r0   ÚtimeoutÚtagsÚarchNc                 ó  — |j                  d«      xs |j                  d«      | _        |j                  d«      xs |j                  d«      | _        |j                  d«      | _        |j                  d«      | _        |j                  d«      | _        |j                  d«      | _        |j                  d	«      | _        |j                  d
«      | _        |j                  d«      | _	        |j                  d«      | _
        y )Nr7   r*   r8   r+   r,   r-   r.   r/   r0   rD   rE   rF   )r;   r*   r+   r,   r-   r.   r/   r0   rD   rE   rF   ©r=   r>   s     r   r?   zJobSpec.__init__    sÀ   € Ø"ŸJ™J }Ó5ÒS¸¿¹ÀNÓ9SˆÔØŸ
™
 9Ó-ÒG°·±¸JÓ1GˆŒØ—z‘z )Ó,ˆŒØŸ™ KÓ0ˆŒØ!Ÿ:™: mÓ4ˆÔØ—z‘z )Ó,ˆŒØ—j‘j Ó*ˆŒØ—z‘z )Ó,ˆŒØ—J‘J˜vÓ&ˆŒ	Ø—J‘J˜vÓ&ˆ�	r   r@   )r   r   r   r	   r!   r    r   r   r   r   Úintr?   r   r   r   rC   rC   “   s�   … à˜3‘-ÓØ�s‰mÓØ�d˜3‘iÑ Ó Ø˜˜S™	Ñ"Ó"Ø˜$˜s C˜x™.Ñ)Ó)Ø�d˜3 ˜8‘nÑ%Ó%Ø�]Ñ#Ó#Ø�c‰]ÓØ
�4˜‘9Ñ
ÓØ
�3‰-Óô
'r   rC   c                   ó*   — e Zd ZU eed<   eed<   dd„Zy)ÚLastJobInfor$   ÚatNc                 ó>   — |d   | _         t        |d   «      | _        y )Nr$   rL   )r$   r   rL   rH   s     r   r?   zLastJobInfo.__init__²   s   € Ø˜‘,ˆŒÜ  ¨¡Ó.ˆ�r   r@   )r   r   r   r!   r    r   r?   r   r   r   rK   rK   ­   s   … àƒGØƒLô/r   rK   c                   ó6   — e Zd ZU ee   ed<   ee   ed<   dd„Zy)ÚScheduledJobStatusÚlast_jobÚnext_job_run_atNc                 ó  — |j                  d«      xs |j                  d«      }|rt        di |¤Žnd | _        |j                  d«      xs |j                  d«      }|rt        t	        |«      «      | _        y d | _        y )NÚlastJobrP   ÚnextJobRunAtrQ   r   )r;   rK   rP   r   r!   rQ   )r=   r>   rP   rQ   s       r   r?   zScheduledJobStatus.__init__¼   sj   € Ø—:‘:˜iÓ(ÒB¨F¯J©J°zÓ,BˆÙ3;œÑ/ hÒ/ÀˆŒØ Ÿ*™* ^Ó4ÒU¸¿
¹
ÐCTÓ8UˆÙGVœ~¬c°/Ó.BÓCˆÕÐ\`ˆÕr   r@   )r   r   r   r	   rK   r    r   r?   r   r   r   rO   rO   ·   s   … à�{Ñ#Ó#Ø˜hÑ'Ó'ôar   rO   c                   ó‚   — e Zd ZU dZeed<   ee   ed<   eed<   ee   ed<   ee	   ed<   ee	   ed<   e
ed<   eed	<   dd„Zy
)ÚScheduledJobInfoaÅ  
    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Úconcurrencyr1   r2   Nc                 óž  — |d   | _         |j                  d«      xs |j                  d«      }|rt        |«      nd | _        t	        di |j                  d«      xs |j                  di «      ¤Ž| _        |j                  d«      | _        |j                  d«      | _        |j                  d«      | _        |j                  d	i «      }t        |j                  d
«      xs |j                  d«      |j                  d«      xs |j                  d«      ¬«      | _
        |j                  di «      }t        |d   |d   |d   ¬«      | _        y )Nr$   r6   r)   rW   ÚjobSpecrX   rY   rZ   r1   rP   rS   rQ   rT   )rP   rQ   r2   r%   r&   r9   r   )r$   r;   r   r)   rC   rW   rX   rY   rZ   rO   r1   r#   r2   )r=   r>   r)   r1   r2   s        r   r?   zScheduledJobInfo.__init__ö   s  € Ø˜‘,ˆŒØ—Z‘Z Ó,ÒH°·
±
¸<Ó0Hˆ
Ù8Bœ.¨Ô4ÈˆŒÜÑX 6§:¡:¨jÓ#9Ò#V¸V¿Z¹ZÈ	ÐSUÓ=VÑXˆŒØŸ
™
 :Ó.ˆŒØ—z‘z )Ó,ˆŒØ!Ÿ:™: mÓ4ˆÔØ—‘˜H bÓ)ˆÜ(Ø—Z‘Z 
Ó+ÒD¨v¯z©z¸)Ó/DØ"ŸJ™JÐ'8Ó9ÒW¸V¿Z¹ZÈÓ=Wô
ˆŒð —
‘
˜7 BÓ'ˆÜ  t¡°5¸±=ÀuÈVÁ}ÔUˆ�
r   r@   )r   r   r   r   r!   r    r	   r   rC   ÚboolrO   r#   r?   r   r   r   rV   rV   Ã   sO   … ñ&ðP 	ƒGØ˜Ñ"Ó"ØÓØ�s‰mÓØ�d‰^ÓØ˜$‘ÓØÓØƒOôVr   rV   Úimager,   Úenvr/   r0   rD   rA   c                 óT  — |g |xs i |xs t         j                  dœ}|r||d<   |rPdddddœ}t        |t        «      r+|d   |v r$t	        t        |d d «      ||d      z  «      |d	<   nt	        |«      |d	<   d
D ]'  }| j                  |«      sŒ| t        |«      d  |d<    |S  | |d<   |S )N)r,   r-   r.   r0   r/   é   é<   i  i€Q )ÚsÚmÚhÚdéÿÿÿÿÚtimeoutSeconds)zhttps://huggingface.co/spaces/zhttps://hf.co/spaces/zhuggingface.co/spaces/zhf.co/spaces/r8   r7   )r   Ú	CPU_BASICÚ
isinstancer!   rI   ÚfloatÚ
startswithÚlen)	r^   r,   r_   r/   r0   rD   rW   Útime_units_factorsÚprefixs	            r   Ú_create_job_specrp     sê   € ð ØØ’y˜bØÒ3œM×3Ñ3ñ	 €Hñ Ø%ˆ�ÑáØ#$¨2°D¸yÑIÐÜ�gœsÔ#¨°©Ð7IÑ(IÜ),¬U°7¸3¸B°<Ó-@ÐCUÐV]Ð^`ÑVaÑCbÑ-bÓ)cˆHÐ%Ò&ä),¨W«ˆHÐ%Ñ&ðò 
(ˆð ×Ñ˜FÕ#Ø"'¬¨F«¨Ð"6ˆH�YÑØð €Oð
(ð #(ˆ�ÑØ€Or   N)Údataclassesr   r   Úenumr   Útypingr   r   r   r	   r
   Úhuggingface_hubr   Úhuggingface_hub._space_apir   Úhuggingface_hub.utils._datetimer   r!   r   r   r#   r(   rC   rK   rO   rV   rI   rk   rp   r   r   r   ú<module>rw      sq  ðõ "Ý Ý ß 3Õ 3å %Ý 4Ý :ôˆs�Dô ð( ÷ð ó ðð
 ÷ð ó ðð ÷UGð UGó ðUGðp ÷'ð 'ó ð'ð2 ÷/ð /ó ð/ð ÷að aó ðað ÷@Vð @Vó ð@VðF&àð&ð �#‰Yð&ð 
�$�s˜C�x‘.Ñ	!ð	&ð
 �d˜3 ˜8‘nÑ%ð&ð �]Ñ#ð&ð �e˜C ¨˜OÑ,Ñ-ð&ð 
ˆ#ˆsˆ(�^ô&r   