+
    PjŸ                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtHt ^ RI	H	t	 ^ RI
Ht ^ RIHtHt ^ RIHtHtHt ^ RIHt ^ RIHtHtHtHtHtHt ^ R	IHt ^ R
IHt ^ RI H!t! ^ RI"H#t# ^ RI$H%t% ^ RI&H't'H(t( ^RI)H*t*H+t+H,t,H-t-H.t.H/t/H0t0H1t1H2t2H3t3H4t4H5t5H6t6 ^RI7H8t8H9t9 ^RI:H;t;H<t< ]!Pz                  ! ]>4      t?R R lt@R R ltARtB]]C]8! RR7      3,          tD]]CR,          ]9! RR7      3,          tE]]CR,          ]9! R].! ]4      R7      3,          tF]]G]C,          R,          ]9! RRRR7      3,          tH]]CR,          ]9! RR7      3,          tI]]J]9! R R!R"R7      3,          tK]]CR,          ]9! R#R7      3,          tL]]G]M,          R,          ]9! R$R%R7      3,          tN]]J]9! R&R'R7      3,          tO]]G]C,          R,          ]9! R(R)R7      3,          tP]]CR,          ]9! R*R+R,R7      3,          tQ]]JR,          ]9! R-R7      3,          tR]]JR,          ]9! R.R7      3,          tS]]C]8! R/R7      3,          tT]]C]8! R0R7      3,          tU]]G]C,          R,          ]8! R1R7      3,          tV]]G]C,          ]8! R2R7      3,          tW]]C]8! R3R7      3,          tX]]G]C,          R,          ]8! R4R7      3,          tY]]C]8! R5R7      3,          tZ]]G]C,          R,          ]9! R6R7R8R7      3,          t[]6! R9R7      t\R: R; lt]]\P                  R<R=R>/. ROR?7      RR@ RA ll4       t_]\P                  RB. RORC7      RRD RE ll4       t`RF RG ltaRH RI ltbRJ RK ltc]\P                  RLRM.RC7      RRN RO ll4       td]\P                  RP. RORC7      RRQ RR ll4       te]\P                  RSRT.RC7      RU RV l4       tf]\P                  RWRX.RC7      RRY RZ ll4       tg]\P                  R[R\.RC7      RR] R^ ll4       th]\P                  R_. RORC7      RR` Ra ll4       ti]\P                  RbRcRd.RC7      RRe Rf ll4       tj]\P                  Rg. RORC7      RRh Ri ll4       tk]6! RjR7      tl]\P                  ]lRkRl7       ]lP                  R<R=R>/. ROR?7      RRm Rn ll4       tn]6! RoR7      to]\P                  ]oRpRl7       ]oP                  R<R=R>/Rq.R?7      RRr Rs ll4       tp]oP                  RPRt.RC7      RRu Rv ll4       tq]oP                  RWRw.RC7      RRx Ry ll4       tr]oP                  RzR{.RC7      RR| R} ll4       ts]oP                  R~R.RC7      RR R ll4       tt]oP                  RR.RC7      RR R ll4       tu]oP                  RR.RC7      RR R ll4       tv]oP                  RbRR.RC7      RR R ll4       tw]6! RR7      tx]oP                  ]xRkRl7       ]xP                  R<R=R>/RR.R?7      RR R ll4       tyR R ltzR R lt{]! R4      t|R R lt}R R lt~R# )z@Contains commands to interact with jobs on the Hugging Face Hub.N)CallableIterable)fnmatch)Path)EmptyQueue)	AnnotatedAnyTypeVar)urlsplit)HfApiJobHardwareJobInfoJobStageVolume	constants)TERMINAL_JOB_STAGES)CLIError)logging)_format_size)_split_mount)format_durationparse_duration)
EnvFileOptEnvOptSecretsFileOpt
SecretsOpt
SoftChoiceSshDryRunOptSshIdentityFileOptTokenOptexec_ssh
get_hf_apiparse_env_mapparse_volumestyper_factory)ArgumentOption)_dataclass_to_dictoutc          	      z    V ^8  d   QhR\         R\         R,          R\        \         \         R,          3,          /# )   job_id	namespaceNreturn)strtuple)formats   "q/Users/ahmed/devFolder/Ultron/claude-voice/gateway/.venv/lib/python3.14/site-packages/huggingface_hub/cli/jobs.py__annotate__r3   :   s5     . . .t .cSVY]S]oH^ .    c                *   V '       g   \        R4      hV P                  R4      ^8  d   \        RV  R24      hRV 9  d   W3# V P                  R^4      w  r#V'       d	   V'       g   \        RV  R24      hVe   W8w  d   \        RV RV R24      hW23# )a  Extract namespace from job_id if provided in 'namespace/job_id' format.

Allows users to pass job IDs copied from the Hub UI (e.g. 'username/job_id')
instead of only bare job IDs. If the namespace is also provided explicitly via
--namespace and conflicts, a CLIError is raised.
zJob ID cannot be empty./z<Job ID must be in the form 'job_id' or 'namespace/job_id': 'z'.z(Conflicting namespace: got --namespace='z ' but job ID implies namespace='')r   countsplit)r,   r-   extracted_namespaceparsed_job_ids   &&  r2   _parse_namespace_from_job_idr<   :   s     011||C1UV\U]]_`aa
&  )/c1)=&mUV\U]]_`aa!A6ykAabuavvwx
 	
 --r4   c          	          V ^8  d   QhR\         \        ,          R,          R\        R\        R,          R\         \        ,          R,          /# )r+   volumesNapir-   r.   )listr/   r   r   )r1   s   "r2   r3   r3   V   sB     ) )#Y)',)9<t)	&\D)r4   c               l   V '       g   R# . pV  EF   pVP                  \        P                  4      '       d(   TP                  \	        V.4      ;'       g    . 4       KP  \        WDR7      w  rVpVf   \        RV R24      h\        V4      P                  4       P                  4       '       g   \        RV R24      hTP                  TTVe   TMRVR7      pVP                  R	J d7   \        P                  ! R
V RVP                   RVP                   RV 24       VP!                  V4       EK#  	  V# )zParse `-v` specs for Jobs commands.

Same as [`parse_volumes`] but the source side can also be a local directory: it is synced to a
bucket via [`HfApi.sync_job_volume`] and the resulting bucket subfolder is mounted (read-only
unless ':rw' is specified).
N)rawz#Missing mount path in volume spec 'zC'. Expected 'LOCAL_DIR:/MOUNT_PATH[:ro|:rw]' (e.g. './data:/data').zVolume source 'z' is not an existing local directory. To mount a repo or bucket instead, use the 'hf://' syntax (e.g. 'hf://buckets/my-org/my-bucket:/data').T)	read_onlyr-   FzVolume 'zg' is mounted read-write. Once the job is over, pull back its data with:
  hf buckets sync hf://buckets/r6    )
startswithr   HF_PROTOCOLextendr$   r   r   r   
expanduseris_dirsync_job_volumerC   r)   hintsourcepathappend)	r>   r?   r-   resultraw_specrL   
mount_pathrC   volumes	   &$$      r2   _parse_and_sync_job_volumesrS   V   sK    Fy4455MM-
399r: )5X(L%I5hZ  @C  D  F|&&(//11!& *z z  $$#,#8id	 % 
 u$HH:, '228--&++aPVxY 	f7 8 Mr4   g?zThe Docker image to use.helpz.Use a custom Docker image with `uv` installed.zcFlavor for the hardware. Run 'hf jobs hardware' to list available flavors. Defaults to `cpu-basic`.)rU   
click_type-l--labelz3Set labels. E.g. --label KEY=VALUE or --label LABELzPMax duration: int with s (seconds, default), m (minutes), h (hours) or d (days).z-dz--detachz3Run the Job in the background and print the Job ID.zVThe namespace where the job will be running. Defaults to the current user's namespace.z--exposezExpose a container port through the jobs proxy. Repeat the flag for multiple ports (e.g. `--expose 8000 --expose 8001`). Each exposed port is reachable on the public jobs domain; access requires an HF token with read access to the job's namespace.z--sshzMake the job's container reachable over SSH. Connect with `hf jobs ssh <job_id>`. Requires an SSH public key registered on https://huggingface.co/settings/keys.z--withz%Run with the given packages installedz-pz--pythonz5The Python interpreter to use for the run environmentz!Suspend (pause) the scheduled Jobz8Allow multiple instances of this Job to run concurrentlyzWOne of annually, yearly, monthly, weekly, daily, hourly, or a CRON schedule expression.z$UV script to run (local file or URL)zArguments for the scriptzThe command to run.zJob ID (or 'namespace/job_id')zJob IDs (or 'namespace/job_id')z2Scheduled Job ID (or 'namespace/scheduled_job_id')z-vz--volumea  Mount one or more volumes. Format: hf://[TYPE/]SOURCE:/MOUNT_PATH[:ro|:rw] or LOCAL_DIR:/MOUNT_PATH[:ro|:rw]. TYPE is one of: models, datasets, spaces, buckets. TYPE defaults to models if omitted. models, datasets and spaces are always mounted read-only. buckets are read+write by default. A local directory source is first synced to a bucket and mounted read-only by default. E.g. -v hf://datasets/org/ds:/data or -v hf://buckets/org/b:/mnt:ro or -v ./inputs:/inputszRun and manage Jobs on the Hub.c                4    V ^8  d   QhR\         R\        RR/# )r+   r?   jobr.   N)r   r   )r1   s   "r2   r3   r3   .  s!     	* 	*u 	*7 	*t 	*r4   c                r   V P                  VP                  VP                  P                  RR7       F  p\        P
                  ! V4       K  	  V P                  VP                  VP                  P                  R7      pVP                  P                  \        P                  8w  dj   VP                  P                  '       d   RVP                  P                   2MRp\        RVP                   RVP                  P                   RV 24      h\        P
                  ! RVP                   R	24       R
# )zcStream Job logs until the Job ends, then fail the command if the Job did not complete successfully.T)r,   r-   followr,   r-   z:  zJob z finished with stage 'r7   z
 completedN)fetch_job_logsidownernamer)   textwait_for_jobstatusstager   	COMPLETEDmessager   )r?   rZ   logfinalrh   s   &&   r2   _stream_logs_and_check_statusrk   .  s    !!399>>RV!W X CFFciinnEE||X///161E1E1EBu||++,-2ehhZ'=ell>P>P=QQRSZR[\]]HHtEHH:Z()r4   runignore_unknown_optionsT)context_settingsexamplesc                     V ^8  d   QhR\         R\        R\        R\        R\        R\
        R\        R\        R	\        R
\        R\        R\        R\        R\        R\        RR/# )r+   imagecommandenvsecretslabelrR   env_filesecrets_fileflavortimeoutdetachexposesshr-   tokenr.   N)ImageArg
CommandArgr   r   	LabelsOptJobVolumesOptr   r   	FlavorOpt
TimeoutOpt	DetachOpt	ExposeOptSshEnabledOptNamespaceOptr    )r1   s   "r2   r3   r3   E  s     ., .,.,., 
., 	.,
 ., ., ., !., ., ., ., ., 
., ., .,  
!.,r4   c                   \        W&4      p\        W74      p\        VR7      pVP                  V VVV\        V4      \	        VVVR7      VV	VVVR7      p\
        P                  ! RVP                  VP                  R7       \        VP                  P                  \        4      '       dF   RP                  R VP                  P                   4       4      p\
        P                  ! RV 24       \        VP                  P                  \         4      '       d<   \
        P                  ! R	VP"                  P$                   R
VP                   R24       V
'       d_   VP"                  P$                   R
VP                   2p\
        P                  ! RV RV R24       \
        P                  ! RV R24       R# \'        VV4       R# )z
Run a Job.r}   r?   r-   )rq   rr   rs   rt   labelsr>   rx   ry   r{   r|   r-   Job startedr`   url
c              3   ,   "   T F
  pR V 2x  K  	  R# 5iz  N .0r   s   & r2   	<genexpr>jobs_run.<locals>.<genexpr>j       F/E2cU/E   SExposed ports are reachable at (requires an HF token with read access to the job):
Use `hf jobs ssh r6   &` to open an SSH session into the job.Use `hf jobs logs -f &` to stream logs, or `hf jobs inspect ` to check status.Use `hf jobs wait ` to block until it finishes.N)r#   r"   run_job_parse_labels_maprS   r)   rO   r`   r   
isinstancere   expose_urlsr@   joinrK   ssh_urlr/   ra   rb   rk   )rq   rr   rs   rt   ru   rR   rv   rw   rx   ry   rz   r{   r|   r-   r}   env_mapsecrets_mapr?   rZ   urlsjob_refs   &&&&&&&&&&&&&&&      r2   jobs_runr   :  sn   : C*G6K
5
!C
++ '+FyQ  C JJ}SWW5#**(($//yyFszz/E/EFFghlgmno#**$$c**$SYY^^$4AcffX=cdeYY^^$AcffX.(	1WX_W``rst%gY.KLM!#s+r4   logs)ro   c                    V ^8  d   QhR\         R\        \        \        RRRR7      3,          R\        \        R,          \        R	R
RR7      3,          R\
        R\        RR/# )r+   r,   r\   -fz--followzqFollow log output (stream until the job completes). Without this flag, only currently available logs are printed.rT   tailNz-nz--tailzvNumber of lines to show from the end of the logs. When combined with --follow, starts streaming from the last N lines.r-   r}   r.   )JobIdArgr   boolr'   intr   r    )r1   s   "r2   r3   r3     s     &x &x&x E	
	&x d
 J	
	&x$ %&x& '&x( 
)&xr4   c                   \        W4      w  r\        VR7      pVP                  WWR7      pV F  p\        P                  ! V4       K  	  V'       d.   V'       d   V RV  2MT p\        P
                  ! RV R24       R# R# )a  Fetch the logs of a Job.

By default, prints currently available logs and exits (non-blocking).
Use --follow/-f to stream logs in real-time until the job completes.
Use --tail/-n to limit the number of lines returned (server-side when supported).

Note: following exits when the log stream ends, regardless of whether the Job
succeeded or failed. Run `hf jobs inspect <job_id>` to check the final status.
r   )r,   r-   r\   r   r6   z#Stream ended. Run `hf jobs inspect z6` to check the final status (e.g. COMPLETED or ERROR).N)r<   r"   r_   r)   rc   rK   )	r,   r\   r   r-   r}   r?   r   ri   r   s	   &&&&&    r2   	jobs_logsr   v  sy    N 5VGF
5
!CV[D -6YKq)F6wi?uvw r4   c                    V ^8  d   QhR\         \        \        3,          R\        \        \        \        \        3,          ,          R\        /# )r+   job_propertiesfiltersr.   )dictr/   r@   r0   r   )r1   s   "r2   r3   r3     s;      T#s(^ d5cSVCW>X ]a r4   c                    V Fr  w  r#pV P                  V4      pVf   VR8X  d   K$   R# \        VP                  4       VP                  4       4      pVR8X  d	   V'       d   VR8X  g   Kg  V'       g   Kq   R# 	  R# )z5Check if scheduled job matches all specified filters.!=F=T)getr   lower)r   r   keyop_strpatternvaluematchs   &&     r2   _matches_filtersr     sf     'W""3'=~w}}7cM%Vt^ !( r4   c                (    V ^8  d   QhR\         RR/# )r+   nr.   N)r   )r1   s   "r2   r3   r3     s     ' '3 '4 'r4   c                 J    R pRp\        V 4       F  p\        WR7       K  	  R# )z[1Az[2K)endN)rangeprint)r   LINE_UP
LINE_CLEARis   &   r2   _clear_liner     s"    GJ1Xg& r4   c                   V ^8  d   QhR\         R\        \        \         \        3,          ,          R\        \         ,          R\        \
        \        \         \        \        \         \        ,          ,          ,          3,          ,          /# )r+   r,   metrics_streamtable_headersr.   )r/   r   r   r	   r@   r0   r   r   )r1   s   "r2   r3   r3     s[      !)$sCx.!9JNs)eD#tDsO4456r4   c              #     "   V EF  pV VR ,           R2\        VR,          R,          ^4      \        ^dVR,          ,          VR,          ,          ^4       R2\        VR,          4       R\        VR,          4       R2\        VR,          4       R	\        VR
,          4       R2.pVR,          '       d   \        VR,          \        4      '       d   V.R.\	        V4      ,          .\	        VR,          4      ^,
          ,          ,           p\        V\        VR,          4      4       Fz  w  rFVR,          V,          pVVR,           R2\        ^dVR,          ,          VR,          ,          ^4       R2\        VR,          4       R\        VR,          4       R2.,          pK|  	  M-VR.\	        V4      \	        V4      ,
          ,          ,          pV.pRW3x  EK  	  RV . 3x  R# 5i)cpu_usage_pct%cpu_millicoresg     @@memory_used_bytesmemory_total_byteszB / Brx_bpszbps / tx_bpsbpsgpusr^   utilizationN/AFTN)roundr   r   r   lenzipsorted)r,   r   r   metricsrowrowsgpu_idgpus   &&&     r2   _get_jobs_stats_rowsr     s     "'(*'*+f4a8S7#677'BV:WWYZ[\\]^G$789:$|GThLi?j>kklmGH-./vl78CT6U5VVYZ
 6??z'&/4@@5RD3s8O,GFO0Dq0HIID"4)@Afof-=)*!,S3':#;;cBV>WWYZ[\\]^#C(;$<=>d<PSThPiCjBkklm   B E7c-03s8;<<C5DV!!+ ", 
s   G(G*statszhf jobs stats <job_id>c                @    V ^8  d   QhR\         R\        R\        RR/# )r+   job_idsr-   r}   r.   N)	JobIdsArgr   r    )r1   s   "r2   r3   r3     s6     A' A'A'A' A' 
	A'r4   c                p   V e,   . pV  F!  p\        WA4      w  rAVP                  V4       K#  	  Tp \        VR7      pVf   VP                  4       R,          pV f]   VP	                  VR7       Uu. uF@  pVP
                  '       d   VP
                  P                  MRR9   g   K4  VP                  NKB  	  p p\        V 4      ^ 8X  d   \        P                  ! R4       R# . ROp\        P                  P                  \        V 4      4      ;_uu_ 4       p/ p	V  F:  pV.p
YR,           Uu. uF  pRV9   g   R	V9   d   R
MRNK  	  up,          p
V
.W&   K<  	  \        P                  ! 4       pV	 UU
u. uF  qIV,           F  qNK  	  K  	  ppp
\        \!        WR7      4       V  Uu. uF  pRVRVP#                  WAR7      RV/NK  	  pp\%        V\&        VR7       F  w  rpV'       d   V	P)                  VR4       MVW&   \        P                  ! 4       pVV,
          \*        8  g   KN  \-        ^\        V4      ,           4       V	 UU
u. uF  qIV,           F  qNK  	  K  	  ppp
\        \!        WR7      4       TpK  	  RRR4       R# u upi u upi u up
pi u upi u up
pi   + '       g   i     R# ; i)z7Fetch the resource usage statistics and metrics of JobsNr   rb   r-   UNKNOWNzNo running jobs found:   NNr6   USAGEz-- / --z--)headersr,   r   r]   r   )kwargs_list)RUNNINGUPDATING)	zJOB IDzCPU %zNUM CPUzMEM %z	MEM USAGEzNET I/Oz
GPU UTIL %z	GPU MEM %zGPU MEM USAGE)r<   rN   r"   whoami	list_jobsre   rf   r`   r   r)   rc   multiprocessingpool
ThreadPooltimer   	_tabulatefetch_job_metricsiflatmap_unorderedr   popSTATS_UPDATE_MIN_INTERVALr   )r   r-   r}   
parsed_idsr,   r?   rZ   r   r   rows_per_job_idr   headerlast_update_time
total_rowsr   doner   nows   &&&               r2   
jobs_statsr    s    
F <V OFf%  
5
!CJJL(	 }}y}9
9$'JJJ

  IBYY CFF9 	 

 7|q()
M 
			(	(W	6	6$<>F$*8Cln^op^oTZ#-7f3DI4O^oppC'*eO#   99;(7[fSYCZCZCcCZc
[ 	i
:; "
 "	 & #"7"7v"7"[
 " 	 
 #5T;O]h"iD$##FD1*.'))+C%%)BBAJ/00?cf[aKbKbCcKbc
ci
BC#&  #j) 
7	6'
. q \

  d9 
7	6	6s[   /J	J	%J	J$)J,J$0J
	J$%!JAJ$( J$J!J$J$$J5	zlist | ls | psc                   V ^8  d   QhR\         \        \        RRRR7      3,          R\         \        \        ,          R,          \        R\        \        4      R	R
7      3,          R\         \        \        ,          R,          \        RRRR7      3,          R\         \        \        RRR7      3,          R\        R\        R\         \        \        ,          R,          \        RRRR7      3,          RR/# )r+   all-a--allzWShow all Jobs (default shows running and scheduling). Cannot be combined with --status.rT   re   Nz--statuszfOnly show Jobs with the given status. Comma-separated or repeated, e.g. `--status running,scheduling`.)rV   rU   ru   rW   rX   z{Only show Jobs with the given `key=value` label. Repeat to require several labels, e.g. `--label env=prod --label team=ml`.limitz--limitzCMaximum number of Jobs to display. Set to 0 to show all (no limit).r-   r}   filterr   --filterz2(Deprecated) Use `--status` and `--label` instead.r.   )
r   r   r'   r@   r/   r   r   r   r   r    )r1   s   "r2   r3   r3   (  s,    xa xa	j	
	
xa S	D!(+y	
	xa" S	D O	
	#xa2 V	
	3xa@ AxaB CxaD S	DE	
	ExaT 
Uxar4   c                   \        VR7      pV'       d   \        P                  ! RV R24       V '       d   V'       d   \        R4      h. pT;'       g    .  F*  p	VP	                  R V	P                  R4       4       4       K,  	  V'       d   Tp
M?V '       d   Rp
M4\        P                  P                  \        P                  P                  .p
/ pT;'       g    .  F0  pRV9  d   \        R	V R
24      hVP                  R4      w  rWV&   K2  	  TP                  YJT;'       g    RR7      pRpV^ 8  d?   \        \        P                  ! W^,           4      4      p\        V4      V8  d   RpVRV pM\        V4      p. pV EF.  p\        V4      pVP!                  R4      ;'       g    / pVP!                  R4      ;'       g    . pVP!                  RR4      VR&   VP!                  R4      ;'       g    RVR&   V'       d   RP#                  V4      MRVR&   VP!                  R4      '       d!   VR,          R,          P%                  RR4      MRVR&   VP!                  R4      ;'       g    / P!                  RR4      VR&   \'        VP!                  R4      4      VR&   VP)                  V4       EK1  	  \        P*                  ! V. R(ORR 7       V'       d   \        P,                  ! R!V R"24       V'       g   V'       g	   V'       dM   R#P#                  . R$ V 4       OR% VP/                  4        4       O4      p\        P0                  ! R&V 24       R# V '       g   \        P,                  ! R'4       R# R# R# ))zList Jobs.

Use `--status` to filter by status (see [`JobStage`] for possible values) and `--label` to filter by `key=value`
labels. A Job must match every filter to be listed.
r   zIgnoring filter 'zc'. `-f`/`--filter` is deprecated and will be removed in a future release. Use `--status`/`--label`.z0`-a`/`--all` cannot be combined with `--status`.c              3   p   "   T F,  qP                  4       '       g   K  VP                  4       x  K.  	  R # 5iN)strip)r   parts   & r2   r   jobs_ps.<locals>.<genexpr>f  s"     V5ETLDJJLL5Es   66,Nr   zInvalid label filter 'z"': must be in the form 'key=value')r-   re   r   FT	durationsrr   r`   r^   r,   docker_imager   image/spacerD   
created_atN   NTcreatedre   rf   r   running_secsruntimer   id_keyzOutput truncated to z4 Jobs. Use `--limit 0` to show all (or `--limit N`)., c              3   ,   "   T F
  pR V 2x  K  	  R# 5i)zstatus=Nr   )r   ss   & r2   r   r    s     7,QWQC=,r   c              3   6   "   T F  w  rR V RV 2x  K  	  R# 5i)zlabel=r   Nr   )r   kvs   &  r2   r   r    s#     :gXfPTPQVA3as;KXf   zNo jobs matched filters: zHNo running jobs. Use `-a`/`--all` to include finished (and failed) jobs.)r,   r  rr   r  re   r  )r"   r)   warningr   rG   r9   r   r   r   
SCHEDULINGr   r@   	itertoolsislicer   r(   r   r   replacer   rN   tablerK   itemsrc   )r	  re   ru   r  r-   r}   r  r?   raw_statusesr   server_statusesr   itemr   	jobs_iter	truncatedjobs	job_itemsrZ   job_itemr  cmdfilters_msgs   &&&&&&&                r2   jobs_psr:    s   t 5
!Cx (p p	

 vIJJ !L2VU[[5EVV  &	#++1183F3F3L3LM  Fd?3D69[\]]ZZ_
s	  	RXR`R`\`aI IqyI$$Y	:;t9uI<DI ')I%c*LL-33	ll9%++%\\$3"*,,~">"G"G%/2chhsmOW||\hOiOih|4S9AA#sKot&ll84::??S-immN.KL"  IIT
 'w.bcd6))h7,7h:gX^XdXdXf:ghK HH0>?HH_`  r4   hardwarezhf jobs hardwarec                    V ^8  d   QhRR/# )r+   r.   Nr   )r1   s   "r2   r3   r3     s     ] ]t ]r4   c                    \        4       p V P                  4       p. pV EF  pRpVP                  '       dH   VP                  P                   RVP                  P                   RVP                  P
                   R2pVP                  '       d   RVP                  R 2MRpVP                  '       d   RVP                  ^<,          R 2MRpVP                  R	VP                  R
VP                  RVP                  RVP                  RVP                  RVRVRV/4       EK  	  \        P                  ! V4       \        P                  ! R4       R# )z(List available hardware options for Jobsr^   zx  ()$z.4ffreez.2frb   zpretty namecpuramstorageacceleratorzcost/minz	cost/hourzLUse `hf jobs run --flavor <name> ...` to request a specific hardware flavor.N)r"   list_jobs_hardwarerE  quantitymodelvramunit_cost_usdrN   rb   pretty_namerB  rC  ephemeral_storager)   r.  rK   )r?   hardware_listr/  hwaccelerator_infocost_min	cost_hours          r2   jobs_hardwarerR    s*    ,C**,ME>>>"$.."9"9!:"R^^=Q=Q<RRTUWUcUcUhUhTiijk131A1A1AQr'',-v797G7G7Ga((2-c23V	r~~rvvrvv2///HY		
 $ IIeHH[\r4   inspectzhf jobs inspect <job_id>c                    V ^8  d   QhR\         \        \        ,          \        RR7      3,          R\        R\
        RR/# )r+   r   z*Job IDs to inspect (or 'namespace/job_id')rT   r-   r}   r.   Nr   r@   r/   r&   r   r    )r1   s   "r2   r3   r3     sN     9 9S	=	
	9 9 9 
9r4   c                &   . pV  F!  p\        WA4      w  rAVP                  V4       K#  	  Tp \        VR7      pV  Uu. uF  qEP                  WAR7      NK  	  pp\        P
                  ! V Uu. uF  p\        V4      NK  	  up4       R# u upi u upi )z0Display detailed information on one or more Jobsr   r]   N)r<   rN   r"   inspect_jobr)   r.  r(   )r   r-   r}   r   r,   r?   r5  rZ   s   &&&     r2   jobs_inspectrX    s     J8K&!  G
5
!CNUVgFOO6O?gDVII$7$3!#&$78 W7s   B	,Bcancelzhf jobs cancel <job_id>c                @    V ^8  d   QhR\         R\        R\        RR/# )r+   r,   r-   r}   r.   N)r   r   r    )r1   s   "r2   r3   r3     s0     	+ 	+	+	+ 	+ 
		+r4   c                    \        W4      w  r\        VR7      pVP                  WR7       \        P                  ! RV R7       R# )zCancel a Jobr   r]   zJob cancelledr`   N)r<   r"   
cancel_jobr)   rO   )r,   r-   r}   r?   s   &&& r2   jobs_cancelr^    s7     5VGF
5
!CNN&N6JJ6*r4   waitc          
          V ^8  d   QhR\         \        \        ,          \        RR7      3,          R\         \        R,          \	        RR7      3,          R\
        R\        R	R/# )
r+   r   z,Job IDs to wait for (or 'namespace/job_id').rT   ry   NzTMax time to wait: int with s (seconds, default), m (minutes), h (hours) or d (days).r-   r}   r.   )r   r@   r/   r&   r'   r   r    )r1   s   "r2   r3   r3     st     4
 4
S	?	
	4
 d
g	
	4
 4
 4
 
4
r4   c                f   . p\        4       pV  F2  p\        Wb4      w  rxVP                  V4       VP                  V4       K4  	  \	        V4      ^8  d8   \        RRP                  R \        V\        R7       4       4      ,           4      hVP                  4       pVe   \        V4      MRp	\        VR7      p
\        P                  ! R\	        V4       R24      p V
P                  WIVR	7      pTP!                  \	        T4       R24       \        P"                  ! T Uu. uFF  pRTP$                  R\        TP                  P&                  4      RTP                  P(                  /NKH  	  up4       T Uu. uF/  qP                  P&                  \*        P,                  8w  g   K-  TNK1  	  ppT'       dA   \        \	        T4       R\	        T4       R2RP                  R T 4       4      ,           4      hR#   \         d#    TP!                  R
4       \        RT R24      Rhi ; iu upi u upi )a  Wait for one or more Jobs to reach a terminal state.

Blocks until every Job has finished, then exits with code 0 if all Jobs completed
successfully, or a non-zero exit code if any Job was canceled, errored or deleted.

All Jobs must belong to the same namespace.
z0All Job IDs must be in the same namespace, got: r"  c              3   8   "   T F  p\        V4      x  K  	  R # 5ir  )r/   )r   nss   & r2   r   jobs_wait.<locals>.<genexpr>
  s     F*EBB*Es   )r   Nr   zWaiting for z Job(s) to finish...)ry   r-   z
Timed out.zTimed out after z waiting for Job(s) to finish.z Job(s) finished.r`   rf   rh   z of z' Job(s) did not complete successfully: c              3   l   "   T F*  qP                    R VP                  P                   R2x  K,  	  R# 5i)r>  r?  N)r`   re   rf   )r   rZ   s   & r2   r   rd    s*     KFS66("SZZ%5%5$6a8Fs   24)setr<   rN   addr   r   r   r   r/   r   r   r"   r)   re   rd   TimeoutErrorr  r.  r`   rf   rh   r   rg   )r   ry   r-   r}   r   
namespacesr,   	parsed_idparsed_namespacetimeout_secsr?   re   r5  rZ   faileds   &&&&           r2   	jobs_waitrn    s   > JJ&B6&U#	)$'(  :>iiF&*EFFG
 	
  I.5.A>'*tL
5
!CZZ,s:&77KLMF]
IV KK3t9+./0IIhlmhladcffgs3::+;+;'<iI[I[\hlmn!LTcZZ%5%59K9K%KccTFL6{m4D	{*QRiiKFKKL
 	
   ]L!)'2PQRX\\]
 nLs   G9 !AH)8*H.'H.9-H&r   z8hf jobs labels <job_id> --label env=prod --label team=mlzhf jobs labels <job_id> --clearc                    V ^8  d   QhR\         R\        R\        \        \	        RRR7      3,          R\
        R\        R	R
/# )r+   r,   ru   clear--clearzRemove all labels from the job.rT   r-   r}   r.   N)r   r   r   r   r'   r   r    )r1   s   "r2   r3   r3   (  sV     , ,,, T6)2STTU, 	,
 , 
,r4   c                8   V'       g   V'       g   \        R4      hV'       d   V'       d   \        R4      h\        W4      w  r\        V4      ;'       g    / p\        VR7      pVP	                  WVR7      p\
        P                  ! RVP                  R7       R# )z5Update labels on a Job. Replaces all existing labels.OPlease set at least one label with --label. To remove all labels, pass --clear.bCannot set labels and clear them at the same time. Please use either --label or --clear, not both.r   )r,   r   r-   Labels updatedr\  N)r   r<   r   r"   update_job_labelsr)   rO   r`   )r,   ru   rp  r-   r}   r   r?   rZ   s   &&&&&   r2   jobs_labelsrw  !  s}     hiip
 	
 5VGFu%++F
5
!C


v	

RCJJCFF+r4   r|   c                X    V ^8  d   QhR\         R\        R\        R\        R\        RR/# )r+   r,   identity_filedry_runr-   r}   r.   N)r   r   r   r   r    )r1   s   "r2   r3   r3   E  sD     # ##%# # 	#
 # 
#r4   c                   \        W4      w  r\        VR7      pVP                  WR7      pVP                  P                  f   \        R4      hVP                  P                  \        9   d1   \        RVP                   RVP                  P                   R24      hVP                  P                  \        P                  8w  d   \        P                  ! RVP                   R	VP                  P                   R
24      pVP                  VP                  V\        P                  .R7      pVP                  P                  \        P                  8w  dB   VP                  R4       \        RVP                   RVP                  P                   R24      hVP                  R4       \        VP                  P                  4      p\        VP                    RVP"                   2VP$                  VVR7       R# )a  SSH into a running Job.

If the Job is not yet running, waits until it reaches the RUNNING state before
connecting. Requires the Job to be started with SSH enabled (`hf jobs run --ssh ...`)
and your SSH public key to be registered at https://huggingface.co/settings/keys.
r   r]   Nz[SSH is not enabled on this job. Start a job with SSH support using `hf jobs run --ssh ...`.zCannot SSH into job 'z%': job has already finished (stage: 'z').zWaiting for job 'z' to be running (stage: 'z')...)r,   r-   stageszJob finished.z1': job finished before reaching RUNNING (stage: 'zJob is running.@)portry  rz  )r<   r"   rW  re   r   r   rf   r   r`   r   r   r)   rd   r  r   r!   usernamehostnamer~  )	r,   ry  rz  r-   r}   r?   rZ   re   r   s	   &&&&&    r2   jobs_sshr  =  s   * 5VGF
5
!C
///
=C
zz!tuu
zz...svvh6[\_\f\f\l\l[mmpqrr
zz8+++/x7PQTQ[Q[QaQaPbbghicff	8K[K[J\]::x///KK('x/`adakakaqaq`rruv  	%&szz))*G
Ag../0\\#	r4   zFRun UV scripts (Python with inline dependencies) on HF infrastructure.uv)rb   c          &          V ^8  d   QhR\         R\        R\        R\        R\        R\
        R\        R\        R	\        R
\        R\        R\        R\        R\        R\        R\        R\         R\"        RR/# )r+   scriptscript_argsrq   rx   rs   rt   ru   rR   rv   rw   ry   rz   r{   r|   r-   r}   with_pythonr.   N)	ScriptArgScriptArgsArgImageOptr   r   r   r   r   r   r   r   r   r   r   r   r    WithOpt	PythonOpt)r1   s   "r2   r3   r3   z  s     4, 4,4,4, 4, 	4,
 
4, 4, 4, 4, 4, !4, 4, 4, 4, 
4, 4,  !4," #4,$ %4,& 
'4,r4   c                   \        WH4      p\        WY4      p\        VR7      pTP                  T T;'       g    . VVVVV\        V4      \	        VVVR7      VV
VVVR7      p\
        P                  ! RVP                  VP                  R7       \        VP                  P                  \        4      '       dF   RP                  R VP                  P                   4       4      p\
        P                  ! RV 24       \        VP                  P                  \         4      '       d<   \
        P                  ! R	VP"                  P$                   R
VP                   R24       V'       d_   VP"                  P$                   R
VP                   2p\
        P                  ! RV RV R24       \
        P                  ! RV R24       R# \'        VV4       R# )8Run a UV script (local file or URL) on HF infrastructurer   r   )r  r  dependenciesr  rq   rs   rt   r   r>   rx   ry   r{   r|   r-   r   r   r   c              3   ,   "   T F
  pR V 2x  K  	  R# 5ir   r   r   s   & r2   r   jobs_uv_run.<locals>.<genexpr>  r   r   r   r   r6   r   r   r   r   r   r   N)r#   r"   
run_uv_jobr   rS   r)   rO   r`   r   r   re   r   r@   r   rK   r   r/   ra   rb   rk   )r  r  rq   rx   rs   rt   ru   rR   rv   rw   ry   rz   r{   r|   r-   r}   r  r  r   r   r?   rZ   r   r   s   &&&&&&&&&&&&&&&&&&      r2   jobs_uv_runr  o  s   @ C*G6K
5
!C
..%%2 '+FyQ  C  JJ}SWW5#**(($//yyFszz/E/EFFghlgmno#**$$c**$SYY^^$4AcffX=cdeYY^^$AcffX.(	1WX_W``rst%gY.KLM!#s+r4   z,Create and manage scheduled Jobs on the Hub.	scheduledz>hf jobs scheduled run "0 0 * * *" python:3.12 python script.pyc          "          V ^8  d   QhR\         R\        R\        R\        R\        R\
        R\        R\        R	\        R
\        R\        R\        R\        R\        R\        R\        RR/# )r+   schedulerq   rr   suspendconcurrencyrs   rt   ru   rR   rv   rw   rx   ry   r{   r-   r}   r.   N)ScheduleArgr~   r   
SuspendOptConcurrencyOptr   r   r   r   r   r   r   r   r   r   r    )r1   s   "r2   r3   r3     s     'Y 'Y'Y'Y 'Y 	'Y
  'Y 
'Y 'Y 'Y 'Y 'Y !'Y 'Y 'Y 'Y 'Y  !'Y" 
#'Yr4   c                <   \        WY4      p\        Wj4      p\        VR7      pVP                  VVV VVVV\        V4      \	        VVVR7      VVVVR7      p\
        P                  ! RVP                  R7       \
        P                  ! RVP                   R24       R# )	zSchedule a Job.r   r   )rq   rr   r  r  r  rs   rt   r   r>   rx   ry   r{   r-   Scheduled Job createdr\  Use `hf jobs scheduled inspect ` to view its details.N)	r#   r"   create_scheduled_jobr   rS   r)   rO   r`   rK   )r  rq   rr   r  r  rs   rt   ru   rR   rv   rw   rx   ry   r{   r-   r}   r   r   r?   scheduled_jobs   &&&&&&&&&&&&&&&&    r2   scheduled_runr    s    0 C*G6K
5
!C,, '+FyQ - M JJ&=+;+;<HH.}/?/?.@@VWXr4   zhf jobs scheduled lsc                    V ^8  d   QhR\         \        \        RRRR7      3,          R\        R\        R\         \
        \        ,          R	,          \        R
RRR7      3,          RR	/# )r+   r	  r
  r  z1Show all scheduled Jobs (default hides suspended)rT   r-   r}   r  Nr   r  z>Filter output based on conditions provided (format: key=value)r.   )r   r   r'   r   r    r@   r/   )r1   s   "r2   r3   r3     s     Om Om	D	
	
Om Om Om S	DQ	
	Om& 
'Omr4   c           	     8   \        VR7      pVP                  VR7      p. pT;'       g    .  F  pRV9   dg   VP                  R^4      w  rVP                  R4      '       d	   Rp
VRR# pMRp
VP	                  VP                  4       WP                  4       34       Kp  \        P                  ! RV R24       K  	  . pV F  pVP                  ;'       g    R	pV '       g   V'       d   K+  VP                  P                  ;'       g    R
pVP                  P                  ;'       g    . pV'       d   RP                  V4      MR
pRVP                  RVR\        V4      RV/p\        VV4      '       g   K  VP	                  V4       K  	  . pV EF\  p\!        V4      pVP#                  R4      ;'       g    / pVP#                  R4      ;'       g    / pVP#                  R4      pVP#                  R4      ;'       g    . pVP#                  R4      ;'       g    R
VR&   V'       d   RP                  V4      MR
VR&   V'       d8   VP#                  R4      '       d!   VR,          R,          P%                  RR4      MR
VR&   VP#                  R4      '       d!   VR,          R,          P%                  RR4      MR
VR&   VP#                  R4      ;'       g    R	VR&   VP	                  V4       EK_  	  \        P&                  ! V. R$ORR7       V'       g:   V'       d2   RP                  R V 4       4      p\        P(                  ! RV 24       V'       dG   V^ ,          R,          p\        P*                  ! RV R 24       \        P*                  ! R!V R"24       R# R# )%zList scheduled Jobsr   r   r   !r   Nz Ignoring invalid filter format 'z'. Use key=value format.Fr   rD   r`   rq   r  rr   job_specre   last_jobr  r  atr  r  last_runnext_job_run_atnext_runr   r"  c              3   6   "   T F  w  rq1 V V 2x  K  	  R # 5ir  r   )r   r&  or'  s   &   r2   r   scheduled_ps.<locals>.<genexpr>/  s     DGq#aSGr(  z#No scheduled jobs matched filters: r  z(` to view details about a scheduled job.zUse `hf jobs scheduled trigger z)` to trigger a scheduled job immediately.)r`   r  r  rr   r  r  r  )r"   list_scheduled_jobsr9   endswithrN   r   r)   r)  r  r  r  rr   r   r`   r/   r   r(   r   r-  r.  rc   rK   )r	  r-   r}   r  r?   scheduled_jobsr   fr   r   opfiltered_jobsr  r  image_or_spacer8  command_strpropsr/  sjr2  r  status_dictr  r9  first_item_ids   &&&&                      r2   scheduled_psr    s   , 5
!C,,y,AN*,G\\r\!8aJC||C  #2hNNCIIK[[];<KK:1#=UVW  M'''005w&//<<EE$$,,22'*chhsm}''.)SQX\[dfqrw//]+ ( #%E!"%88J'--2hhx(..B??:.ll9%++&ll>:CCe]+.#((3-EYDLQYQ]Q]^bQcQc8D>#.66sC@inZEP__UfEgEgK)*3/77SAmr 	Z ((9-66YT  II_
 WiiDGDD6{mDEa2=/Aijk2=/Ajkl r4   zhf jobs scheduled inspect <id>c                    V ^8  d   QhR\         \        \        ,          \        RR7      3,          R\        R\
        RR/# )r+   scheduled_job_idsz>Scheduled Job IDs to inspect (or 'namespace/scheduled_job_id')rT   r-   r}   r.   NrU  )r1   s   "r2   r3   r3   8  sT     W W S	Q	
	W W W 
Wr4   c                (   . pV  F!  p\        WA4      w  rAVP                  V4       K#  	  Tp \        VR7      pV  Uu. uF  pVP                  WaR7      NK  	  pp\        P
                  ! V Uu. uF  p\        V4      NK  	  up4       R# u upi u upi )z:Display detailed information on one or more scheduled Jobsr   scheduled_job_idr-   N)r<   rN   r"   inspect_scheduled_jobr)   r.  r(   )	r  r-   r}   r   r,   r?   r  r  r  s	   &&&      r2   scheduled_inspectr  7  s     J#8K&! $ #
5
!C !2 1 	!!3C!Y 1   IInUn]!-0nUV	 Vs   B
-Bdeletezhf jobs scheduled delete <id>c                @    V ^8  d   QhR\         R\        R\        RR/# r+   r  r-   r}   r.   NScheduledJobIdArgr   r    )r1   s   "r2   r3   r3   Q  0     	= 	='	=	= 	= 
		=r4   c                    \        W4      w  r\        VR7      pVP                  WR7       \        P                  ! RV R7       R# )zDelete a scheduled Job.r   r  zScheduled Job deletedr\  N)r<   r"   delete_scheduled_jobr)   rO   r  r-   r}   r?   s   &&& r2   scheduled_deleter  P  ?     #??O"[
5
!C.>TJJ&+;<r4   r  zhf jobs scheduled suspend <id>c                @    V ^8  d   QhR\         R\        R\        RR/# r  r  )r1   s   "r2   r3   r3   ^  6     
Q 
Q'
Q
Q 
Q 
	
Qr4   c                    \        W4      w  r\        VR7      pVP                  WR7       \        P                  ! RV R7       \        P
                  ! RV  R24       R# )z Suspend (pause) a scheduled Job.r   r  zScheduled Job suspendedr\  zUse `hf jobs scheduled resume z` to resume it.N)r<   r"   suspend_scheduled_jobr)   rO   rK   r  s   &&& r2   scheduled_suspendr  ]  sW     #??O"[
5
!C/?UJJ(-=>HH-.>-?OPr4   resumezhf jobs scheduled resume <id>c                @    V ^8  d   QhR\         R\        R\        RR/# r  r  )r1   s   "r2   r3   r3   l  r  r4   c                    \        W4      w  r\        VR7      pVP                  WR7       \        P                  ! RV R7       R# )z!Resume (unpause) a scheduled Job.r   r  zScheduled Job resumedr\  N)r<   r"   resume_scheduled_jobr)   rO   r  s   &&& r2   scheduled_resumer  k  r  r4   triggerzhf jobs scheduled trigger <id>c                @    V ^8  d   QhR\         R\        R\        RR/# r  r  )r1   s   "r2   r3   r3   y  r  r4   c                ,   \        W4      w  r\        VR7      pVP                  WR7      p\        P                  ! RVP
                  VP                  R7       \        P                  ! RVP                  P                   RVP
                   R24       R# )	zJTrigger a scheduled Job to run immediately (does not change the schedule).r   r  zScheduled Job triggeredr   r   r6   z` to stream logs.N)
r<   r"   trigger_scheduled_jobr)   rO   r`   r   rK   ra   rb   )r  r-   r}   r?   rZ   s   &&&  r2   scheduled_triggerr  x  st     #??O"[
5
!C

#
#5E
#
[CJJ(SVVAHH$SYY^^$4AcffX=NOPr4   z>hf jobs scheduled labels <id> --label env=prod --label team=mlz%hf jobs scheduled labels <id> --clearc                    V ^8  d   QhR\         R\        R\        \        \	        RRR7      3,          R\
        R\        R	R
/# )r+   r  ru   rp  rq  z)Remove all labels from the scheduled job.rT   r-   r}   r.   N)r  r   r   r   r'   r   r    )r1   s   "r2   r3   r3     sV     6 6'66 T6)2]^^_6 	6
 6 
6r4   c                8   V'       g   V'       g   \        R4      hV'       d   V'       d   \        R4      h\        W4      w  r\        V4      ;'       g    / p\        VR7      pVP	                  WVR7      p\
        P                  ! RVP                  R7       R# )z?Update labels on a scheduled Job. Replaces all existing labels.rs  rt  r   )r  r   r-   ru  r\  N)r   r<   r   r"   update_scheduled_job_labelsr)   rO   r`   )r  ru   rp  r-   r}   r   r?   r  s   &&&&&   r2   scheduled_labelsr    s     hiip
 	
 #??O"[u%++F
5
!C33)I 4 M JJM$4$45r4   z)Schedule UV scripts on HF infrastructure.z.hf jobs scheduled uv run "0 0 * * *" script.pyz<hf jobs scheduled uv run "0 0 * * *" script.py --with pandasc          (          V ^8  d   QhR\         R\        R\        R\        R\        R\
        R\        R\        R	\        R
\        R\        R\        R\        R\        R\        R\        R\         R\"        R\$        RR/# )r+   r  r  r  r  r  rq   rx   rs   rt   ru   rR   rv   rw   ry   r{   r-   r}   r  r  r.   N)r  r  r  r  r  r  r   r   r   r   r   r   r   r   r   r   r    r  r  )r1   s   "r2   r3   r3     s     -O -O-O-O -O 	-O
  -O -O -O 
-O -O -O -O -O !-O -O -O  !-O" #-O$ %-O& '-O( 
)-Or4   c                V   \        W{4      p\        W4      p\        VR7      pTP                  TT;'       g    . V VVVVVVV\        V	4      \	        V
VVR7      VVVVR7      p\
        P                  ! RVP                  R7       \
        P                  ! RVP                   R24       R# )	r  r   r   )r  r  r  r  r  r  r  rq   rs   rt   r   r>   rx   ry   r{   r-   r  r\  r  r  N)	r#   r"   create_scheduled_uv_jobr   rS   r)   rO   r`   rK   )r  r  r  r  r  rq   rx   rs   rt   ru   rR   rv   rw   ry   r{   r-   r}   r  r  r   r   r?   rZ   s   &&&&&&&&&&&&&&&&&&&    r2   scheduled_uv_runr    s    < C*G6K
5
!C

%
%%%2 '+FyQ! & C$ JJ&3662HH.svvh6LMNr4   c                    V ^8  d   QhR\         \        ,          R,          R\        \        \        3,          R,          /# )r+   r   Nr.   )r@   r/   r   )r1   s   "r2   r3   r3     s0      d3i$. 4S>D3H r4   c                v    V '       g   R# / pV  F&  pRV9   d   VP                  R^4      MVR3w  r4WAV&   K(  	  V# )zParse label key-value pairs from CLI arguments.

Args:
    labels: List of label strings in KEY=VALUE format. If KEY only, then VALUE is set to empty string.

Returns:
    Dictionary mapping label keys to values, or None if no labels provided.
Nr   r^   )r9   )r   
labels_map	label_varr   r   s   &    r2   r   r     sH     !#J	03y0@Y__S!,yRTo
3  r4   c                    V ^8  d   QhR\         \         \        \        ,          ,          ,          R\         \        ,          R\        /# )r+   r   r   r.   )r@   r/   r   )r1   s   "r2   r3   r3     s2      DcCi) DI # r4   c           
     L   \        . V OVN5!   Uu. uF  p\        R V 4       4      NK  	  pp\        \        P                  ! 4       P                  \        V4      ^,          4      p\        V4      \        V4      ,           V8  d   VP                  \        V4      4      pW5;;,          ^,          uu&   \        V4      \        V4      ,           V8:  g   Kp  V\        V4      ,
          \        V4      ,
          W5,          ,           W5&   K  R\        V4      ,          P                  ! V!  p. pVP                  VP                  ! V!  4       TP                  VP                  ! V Uu. uF  pRV,          NK  	  up!  4       V  F~  p	\        W4       U
Uu. uFE  w  r\        \        V
4      4      V8  d   \        V
4      RV^,
           R,           M
\        V
4      NKG  	  pp
pVP                  VP                  ! V!  4       K  	  RP                  V4      # u upi u upi u upp
i )zy
Inspired by:

- stackoverflow.com/a/8356620/593036
- stackoverflow.com/questions/9535954/printing-lists-as-tabular-data
c              3   J   "   T F  p\        \        V4      4      x  K  	  R # 5ir  )r   r/   )r   xs   & r2   r   _tabulate.<locals>.<genexpr>  s     /3ac#a&kk3s   !#z{{:{}}} -Nz...r   )r   maxshutilget_terminal_sizecolumnsr   sumindexr1   rN   r/   r   )r   r   col
col_widthsterminal_widthcol_to_minimize
row_formatlineswr   r  	col_widthrow_format_argss   &&           r2   r   r     s    <?;N;Ng;NO;NC#/3//;NJO113;;S\B=NON
g,Z
(>
9$**3z?;#)#w<#j/)^;*83z?*JSQX\*Y\f\w*wJ's7|+33Z@JE	LL""G,-	LL""j$AjS1WWj$ABC !$C 4
 4 033q6{Y/FCF?Y]#e+CPQFR 4 	 
 	Z&&89  99U# P %B
s   H&HAH r  c                    V ^8  d   QhR\         \        ,          R\        R\        \        ,          3,          R\        RR/# )r+   queuefunc.kwargsr.   N)r   r  r   r   r   )r1   s   "r2   r3   r3     s<      U1X Xc8A;>N5O Y] bf r4   c                 F    V! R/ VB  F  pV P                  V4       K  	  R # )Nr   )put)r   r  r  rO   s   &&& r2   _write_generator_to_queuer    s    ..		& !r4   c          	          V ^8  d   QhR\         P                  P                  R\        R\        \
        ,          3,          R\        \        ,          R\        \
        ,          /# )r+   r   r  .r   r.   )r   r   r   r   r   r  r@   r   )r1   s   "r2   r3   r3     sR      



)
)
3#
$ d	
 a[r4   c          	   #    "   \        4       pV Uu. uF  q@P                  \        W1V34      NK  	  pp   VP                  RR7      x  K  u upi   \         dZ    \
        ;QJ d    R T 4       F  '       d   K   RM	  RM! R T 4       4      '       d   TP                  4       '       d    M K}   K  i ; i  \         d     Mi ; i T Uu. uF  qfP                  RR7      NK  	  Mu upi  pR#   \        P                   d     R# i ; i   T Uu. uF  qfP                  RR7      NK  	  Mu upi  pi   \        P                   d     i i ; i; i5i)a#  
Takes a function that returns an iterable of items, and run it in parallel using threads to return the flattened iterable of items as they arrive.

This is inspired by those three `map()` variants, and is the mix of all three:

* `imap()`: like `map()` but returns an iterable instead of a list of results
* `imap_unordered()`: like `imap()` but the output is sorted by time of arrival
* `flatmap()`: like `map()` but given a function which returns a list, `flatmap()` returns the flattened list that is the concatenation of all the output lists
Tg?)ry   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir  )ready)r   async_results   & r2   r   %iflatmap_unordered.<locals>.<genexpr>.  s     N))++s   FN)
r   apply_asyncr  r   r   r	  emptyKeyboardInterruptr   rh  )r   r  r   r   r  async_resultsr
  s   &&$    r2   r   r     s0     gEfqrfq\b%%&?%vAVWfqMriii--	 s
  3NN333NNNNSXS^S^S`S` TaN  	@MNd+N++ 			@MNd+N++ 		s   E AEB8 A 
B8 EB5'B5;B5B5,B8 -D .B8 4B55B8 8CD CD 
C2 C)(C2 0E2DE
DEED7D/.D76E7EEEEE)z3hf jobs run python:3.12 python -c 'print("Hello!")'z1hf jobs run --detach python:3.12 python script.pyz3hf jobs run -e FOO=foo python:3.12 python script.pyz;hf jobs run --secrets HF_TOKEN python:3.12 python script.pyz^hf jobs run -v hf://org/my-model:/data -v hf://buckets/org/b:/mnt python:3.12 python script.py)NNNNNNNNFNFNN)zhf jobs logs <job_id>zhf jobs logs -f <job_id>zhf jobs logs --tail 20 <job_id>z#hf jobs logs -f --tail 100 <job_id>)FNNN)NNN)z
hf jobs lszhf jobs ls -az&hf jobs ls --status running,schedulingz+hf jobs ls --label env=prod --label team=mlz%hf jobs ls --all --label hf-sandbox=1)FNNd   NNN)NN)zhf jobs wait <job_id>z"hf jobs wait <job_id_1> <job_id_2>z"hf jobs ls -q | xargs hf jobs wait)NFNN)zhf jobs ssh <job_id>zhf jobs ssh <job_id> --dry-runz)hf jobs ssh <job_id> -i ~/.ssh/id_ed25519)zhf jobs uv run my_script.pyz$hf jobs uv run --detach my_script.pyz1hf jobs uv run ml_training.py --flavor a10g-smallz+hf jobs uv run --with transformers train.pyzNhf jobs uv run -v hf://org/my-model:/data -v hf://buckets/org/b:/mnt script.py)NNNNNNNNNNFNFNNNN)NNNNNNNNNNNNN)NNNNNNNNNNNNNNNNN)__doc__r+  r   multiprocessing.poolr  r   collections.abcr   r   r   pathlibr   r   r   r   typingr   r	   r
   urllib.parser   huggingface_hubr   r   r   r   r   r   huggingface_hub._jobs_apir   huggingface_hub.errorsr   huggingface_hub.utilsr   $huggingface_hub.utils._cache_managerr   huggingface_hub.utils._hf_urisr   huggingface_hub.utils._parsingr   r   
_cli_utilsr   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   
_frameworkr&   r'   _outputr(   r)   
get_logger__name__loggerr<   rS   r   r/   r~   r  r   r@   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r   r   r   r  r   jobs_clirk   rr   r   r   r   r   r   r  r:  rR  rX  r^  rn  rw  r  uv_app	add_groupr  scheduled_appr  r  r  r  r  r  r  r  scheduled_uv_appr  r   r   r  r  r   r   r4   r2   <module>r)     s   G      .    * * ! T T 9 + ) = 7 J    ) , 
		H	%.8)X    ' $J
= $J
rk*	 I
B	 $J
_
 
B	 $J
e I
 G	 
 p I
4 $J
D	 4K
0
 4K
G f 3	 I' I"
 - I.	 A  I
e	
 ?@	* 
	.5  
.,
.,b 

  &x&xR'8 
'%=$>?A' @A'H 
  	xa	xav 
*(:';<] =]6 
)'A&BC9 D9* 
(&?%@A	+ B	+ 

  4
4
n 
B)  ,,* 
	  ##L 
d	e   6  % 	.5  
4,
4,n #QR   ={  3 	.5NO  
'Y
'YT '3I2JKOm LOmd y,L+MNW OW0 x+J*KL	= M	= y,L+MN
Q O
Q x+J*KL	= M	= y,L+MN
Q O
Q H/  66. !&QR    (t  4 	.58F  -O-Of$6 CL
r4   