+
    –°³j J  ã                   ó`  € R t ^ RIt^ RIt^ RIHt ^ RIHtHtHt ^ RI	t	^ RI
HtHtHtHtHtHtHtHtHtHtHt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"H#t#H$t$H%t%H&t& ^RI'H(t(H)t) ^R	I*H+t+ ^R
I,H-t-H.t.H/t/H0t0 ]&! RR7      t1]&! RR7      t2]1Pg                  ]2RR7       ]&! RR7      t4]1Pg                  ]4RR7       ]]5](! RR7      3,          t6]R R l4       t7]1Pq                  R. RBOR7      RCR R ll4       t9]1Pq                  RRR/RR.R7      RDR R  ll4       t:]1Pq                  R!RR/R"R#.R7      RER$ R% ll4       t;]1Pq                  R&R'R(.R7      RFR) R* ll4       t<]1Pq                  R+. RGOR7      RHR, R- ll4       t=]2Pq                  R. RIOR7      RR]RRRR3R. R/ ll4       t>]2Pq                  R0R1.R7      RFR2 R3 ll4       t?]2Pq                  R4R5.R7      RJR6 R7 ll4       t@R8 R9 ltAR: R; ltB]4Pq                  R0R<.R7      RFR= R> ll4       tC]4Pq                  R+R?.R7      RFR@ RA ll4       tDR# )KzCContains commands to run and manage sandboxes on Hugging Face Jobs.N)Úcontextmanager)Ú	AnnotatedÚAnyÚIterator)ÚDEFAULT_IDLE_TIMEOUTÚDEFAULT_IMAGEÚDEFAULT_SANDBOXES_PER_HOSTÚ
MODE_LABELÚ	MODE_POOLÚ
POOL_LABELÚSANDBOX_LABELÚSHARED_ID_SEPÚSandboxÚSandboxPoolÚSandboxProcessÚ_split_sandbox_id)Údelete_pool_cache)ÚCLIErrorÚSandboxError)
Ú
EnvFileOptÚEnvOptÚSecretsFileOptÚ
SecretsOptÚTokenOptÚ
VolumesOptÚ
get_hf_apiÚparse_env_mapÚparse_volumesÚtyper_factory)ÚArgumentÚOption)Úout)Ú	FlavorOptÚ	LabelsOptÚNamespaceOptÚ_parse_labels_mapz;Run and manage experimental sandboxes on Hugging Face Jobs.©ÚhelpzhWarm host VM pools and spawn experimental shared sandboxes for workloads within the same trust boundary.Úpool)Únamez8List and stop background processes running in a sandbox.Úprocessz1The sandbox id as printed by `hf sandbox create`.c          	      óz   € V ^8„  d   QhR\         R\         R,          R\         R,          R\        \        ,          /# )é   Ú
sandbox_idÚ	namespaceNÚtokenÚreturn)Ústrr   r   )Úformats   "Ú\/home/luca/screen-checking/.venv/lib/python3.14/site-packages/huggingface_hub/cli/sandbox.pyÚ__annotate__r4   E   s6   € ÷ ñ œð ¬C°$­Jð ¼sÀT½zð ÌhÔW^ÕN_ñ ó    c             #  ó’   "  € \         P                  ! WVR7      p Vx € VP                  4        R#   TP                  4        i ; i5i)zIReattach to a sandbox and close the HTTP client when the command is done.©r.   r/   N)r   ÚconnectÚclose)r-   r.   r/   Úsandboxs   &$$ r3   Ú_connectr;   D   s3   é € ô �oŠo˜jÀUÔK€GðØŠà�‰Žøˆ�‰�üs   ‚Aœ2  A²AÁAÚcreate)Úexamplesc                óž  € V ^8„  d   QhR\         \        R,          \        RR7      3,          R\         \        R,          \        RRR7      3,          R\        R	\         \        R,          \        R
R7      3,          R\
        R\        R\        R\        R\        R\        R\        R\         \        \        RRR7      3,          R\        RR/# )r,   ÚimageNzDocker image (needs /bin/sh).r&   r(   z--poolzJSpawn a cheap shared sandbox in this pool (from `hf sandbox pool create`).ÚflavorÚidle_timeoutzTAuto-terminate the sandbox after this much inactivity (e.g. '10m'). Defaults to 10m.ÚenvÚsecretsÚlabelÚenv_fileÚsecrets_fileÚvolumer.   Úforward_hf_tokenz--forward-hf-tokenz0Inject your HF token as HF_TOKEN in the sandbox.r/   r0   )r   r1   r   r    r"   r   r   r#   r   r   r   r$   Úboolr   )r2   s   "r3   r4   r4   X   s  € ÷ FCñ FCÜ”S˜4•Z¤Ð/NÔ!OÐOÕPðFCä
Üˆd�
ÜˆxÐjÔkð	mõðFCô ðFCô Üˆd�
ÜÐjÔkð	mõðFCô 
ðFCô ðFCô ðFCô ðFCô !ðFCô  ð!FCô" ð#FCô$  ÜŒfÐ)Ð0bÔcÐcõð%FCô* ð+FCð, 
ñ-FCr5   c                óx  € \         P                   ! 4       pVe   TM\        pVEe   V f   Vf	   V	'       d   \        R4      hV'       g	   V'       d   \        R4      hV'       d   \        R4      h\        P                  ! WVR7      P                  \        WG4      VVR7      p\        P                  ! RVP                  VP                  V\         P                   ! 4       V,
          R R	2R
7       \        P                  ! RVP                   R24       \        P                  ! RVP                   R24       R# \        P
                  ! T ;'       g    \        T;'       g    RV\        WG4      \        WX4      \        V	4      V
V\        V4      VR7
      pVP!                  4        \        P                  ! RVP                  VP"                  \         P                   ! 4       V,
          R R	2R7       \        P                  ! RVP                   R24       \        P                  ! RVP                   R24       R# )a~  Create a sandbox: a dedicated VM by default, or a cheap shared one with `--pool`.

Env and idle-timeout apply to the sandbox in both modes. With `--pool`, the image and
flavor come from the pool, so passing them here is an error; `--secrets` is also
rejected since pooled sandboxes have no encrypted-secrets channel (use `--env`). Define
a pool first with `hf sandbox pool create`.
NzQ--pool fixes the image/flavor (and volumes aren't supported); drop those options.zÚ--pool has no encrypted-secrets channel. Pass the values with --env/--env-file: on a pooled sandbox they are delivered to the host at creation and are not stored in the job metadata, but they are not encrypted at rest.z2--label is only supported for dedicated sandboxes.r7   )rB   rA   rH   zSandbox readyú.1fÚs)ÚidÚhostr(   Úelapsedz$Run a command with `hf sandbox exec z -- echo hello`.z#Terminate it with `hf sandbox kill ú`.ú	cpu-basic)
r?   r@   rA   rB   rC   Úvolumesr.   rH   Úlabelsr/   )rM   r?   rO   )Útimer   r   r   r8   r<   r   r!   ÚresultrM   Úhost_idÚhintr   r   r   r%   r9   r?   )r?   r(   r@   rA   rB   rC   rD   rE   rF   rG   r.   rH   r/   ÚstartÚidleÚsbxr:   s   &&&&&&&&&&&&&    r3   Úsandbox_creater[   N   sÉ  € ôP �IŠI‹K€EØ'Ò3‰<Ô9M€DàÓØÒ Ò 2·fÜÐnÓoÐoß—lÜð6óð ÷
 ÜÐOÓPÐPÜ×!Ò! $À5ÔI×PÑPÜ˜cÓ,ØØ-ð Qó 
ˆô
 	�
Š
�? s§v¡v°C·K±KÀdÔW[×W`ÒW`ÓWbÐejÕWjÐknÐVoÐopÐTqÕrÜ�ŠÐ7¸¿¹°xÐ?OÐPÔQÜ�ŠÐ6°s·v±v°h¸bÐAÔBÙä�nŠnØ×$Ð$”}Ø×$Ð$˜ØÜ˜#Ó(Ü˜gÓ4Ü˜fÓ%ØØ)Ü  Ó'Øô€Gð ‡M�M„OÜ‡J‚Jˆ 7§:¡:°W·]±]ÌtÏyÊyË{Ð]bÕObÐcfÐNgÐghÐLiÕjÜ‡H‚HÐ3°G·J±J°<Ð?OÐPÔQÜ‡H‚HÐ2°7·:±:°,¸bÐAÖBr5   ÚexecÚignore_unknown_optionsTz5hf sandbox exec <sandbox_id> -- python -c "print(42)"z1hf sandbox exec -w /app <sandbox_id> -- pytest -x)Úcontext_settingsr=   c                ó>  € V ^8„  d   QhR\         R\        \        \        ,          \	        RR7      3,          R\        \        R,          \        RRR	R7      3,          R
\        R\        R\        \        R,          \        RRR7      3,          R\        R\        RR/	# )r,   r-   ÚcommandzThe command to run.r&   ÚworkdirNú-wú	--workdirúWorking directory.rB   rE   Úexec_timeoutz	--timeoutz)Kill the command after this many seconds.r.   r/   r0   )ÚSandboxIdArgr   Úlistr1   r   r    r   r   Úfloatr$   r   )r2   s   "r3   r4   r4   ©   s²   € ÷ )bñ )bÜð)bä”tœC•y¤(Ð0EÔ"FÐFÕGð)bô ”s˜T•z¤6¨$°ÐBVÔ#WÐWÕXð)bô 
ð	)bô
 ð)bô Ü��”f˜[Ð/ZÔ[Ð[õð)bô ð)bô ð)bð 
ñ)br5   c                ó6  € R R lpR R lp	\        WVR7      ;_uu_ 4       p
V
P                  \        V4      \        W44      VVVV	RRR7      pRRR4       XP                  '       dO   \
        P                  ! R	V R
24       \        P                  P                  VP                  ;'       g    ^|R7      hVP                  ^ 8w  d@   \        P                  P                  VP                  e   VP                  R7      h^R7      hR#   + '       g   i     LÂ; i)z¸Run a command in a sandbox, streaming output. Exits with the command's exit code.

To start a long-running command in the background instead of waiting for it, use
`hf sandbox spawn`.
c                ó(   € V ^8„  d   QhR\         RR/# ©r,   Údatar0   N©r1   )r2   s   "r3   r4   Ú"sandbox_exec.<locals>.__annotate__»   ó   € ÷ ñ œ3ð  4ñ r5   c                 ó€   € \         P                  P                  V 4       \         P                  P                  4        R # ©N)ÚsysÚstdoutÚwriteÚflush©rl   s   &r3   Úwrite_stdoutÚ"sandbox_exec.<locals>.write_stdout»   ó$   € Ü�
‰
×Ñ˜ÔÜ�
‰
×ÑÖr5   c                ó(   € V ^8„  d   QhR\         RR/# rk   rm   )r2   s   "r3   r4   rn   ¿   ro   r5   c                 ó€   € \         P                  P                  V 4       \         P                  P                  4        R # rq   )rr   Ústderrrt   ru   rv   s   &r3   Úwrite_stderrÚ"sandbox_exec.<locals>.write_stderr¿   ry   r5   r7   F)rB   ÚcwdÚtimeoutÚ	on_stdoutÚ	on_stderrÚcapture_outputÚcheckNzCommand timed out after zs.)Úcode)r;   Úrunrg   r   Ú	timed_outr!   ÚerrorÚclickÚ
exceptionsÚExitÚ	exit_code)r-   r`   ra   rB   rE   re   r.   r/   rw   r}   r:   rU   s   &&&&&&&&    r3   Úsandbox_execr�   ¡   s÷   € õ4õô 
�*¸×	?Õ	?À7Ø—‘Ü�‹MÜ˜cÓ,ØØ Ø"Ø"Ø Øð ó 	
ˆ÷ 
@ð ××ÐÜ�	Š	Ð,¨\¨N¸"Ð=Ô>Ü×Ñ×#Ñ#¨×)9Ñ)9×)@Ð)@¸SÐ#ÓAÐAØ×Ñ˜1ÔÜ×Ñ×#Ñ#¸V×=MÑ=MÒ=Y¨×)9Ñ)9Ð#ÓaÐaÐ_`Ð#ÓaÐañ ÷ 
@×	?ús   ¢,DÄD	Úspawnz;hf sandbox spawn <sandbox_id> -- python -m http.server 8000z8hf sandbox spawn -w /app <sandbox_id> -- uvicorn app:appc                óô   € V ^8„  d   QhR\         R\        \        \        ,          \	        RR7      3,          R\        \        R,          \        RRR	R7      3,          R
\        R\        R\        R\        RR/# )r,   r-   r`   z%The command to run in the background.r&   ra   Nrb   rc   rd   rB   rE   r.   r/   r0   )
rf   r   rg   r1   r   r    r   r   r$   r   )r2   s   "r3   r4   r4   Ý   sŽ   € ÷ Tñ TÜðTä”tœC•y¤(Ð0WÔ"XÐXÕYðTô ”s˜T•z¤6¨$°ÐBVÔ#WÐWÕXðTô 
ð	Tô
 ðTô ðTô ðTð 
ñTr5   c           	     ó~  € \        WVR7      ;_uu_ 4       pVP                  \        V4      \        W44      VRR7      pRRR4       \        P
                  ! RV XP                  R7       \        P                  ! RV  R24       \        P                  ! R	V  R
VP                   R24       R#   + '       g   i     Lv; i)z¶Start a long-running command in the background and return its pid (don't wait).

List a sandbox's processes with `hf sandbox process ls` and stop one with
`hf sandbox process kill`.
r7   T)rB   r   Ú
backgroundNzProcess started©r:   Úpidz+List processes with `hf sandbox process ls rP   z&Stop it with `hf sandbox process kill Ú )r;   r†   rg   r   r!   rU   r“   rW   )	r-   r`   ra   rB   rE   r.   r/   r:   r*   s	   &&&&&&&  r3   Úsandbox_spawnr•   Õ   s�   € ô, 
�*¸×	?Õ	?À7Ø—+‘+œd 7›m´¸sÓ1MÐSZÐgk�+Ólˆ÷ 
@ä‡J‚JÐ ¨*¸'¿+¹+ÕFÜ‡H‚HÐ:¸:¸,ÀbÐIÔJÜ‡H‚HÐ5°j°\ÀÀ7Ç;Á;À-ÈrÐRÖS÷	 
@×	?ús   –(B,Â,B<	Úcpz2hf sandbox cp data.csv <sandbox_id>:/data/data.csvz7hf sandbox cp <sandbox_id>:/app/result.json result.jsonc          
      ó¨   € V ^8„  d   QhR\         \        \        RR7      3,          R\         \        \        RR7      3,          R\        R\        RR	/# )
r,   Úsrcz,Source: a local path or <sandbox_id>:<path>.r&   Údstz1Destination: a local path or <sandbox_id>:<path>.r.   r/   r0   N)r   r1   r   r$   r   )r2   s   "r3   r4   r4   ù   sZ   € ÷ +ñ +Ü	”3œÐ&TÔUÐUÕ	Vð+ä	”3œÐ&YÔZÐZÕ	[ð+ô ð+ô ð	+ð
 
ñ+r5   c                óÜ  € R R lpV! V 4      w  rVV! V4      w  rxVRJ VRJ 8X  d   \        R4      hVe;   \        WRVR7      ;_uu_ 4       p	V	P                  P                  Wh4       RRR4       M?Vf   Q h\        WrVR7      ;_uu_ 4       p	V	P                  P	                  Wh4       RRR4       \
        P                  ! RWR7       R#   + '       g   i     L*; i  + '       g   i     L=; i)zCCopy a file between the local machine and a sandbox (docker-style).c                ó`   € V ^8„  d   QhR\         R\        \         R,          \         3,          /# )r,   Úrefr0   N)r1   Útuple)r2   s   "r3   r4   Ú sandbox_cp.<locals>.__annotate__  s'   € ÷ ñ ”3ð œ5¤ t¥¬S Õ1ñ r5   c                 ó”   € R V 9   d?   V P                  R4      '       g(   V P                  R ^4      w  r\        V4      ^8”  d   W3# RV 3# )Ú:N)Ú.Ú/Ú~)Ú
startswithÚsplitÚlen)rœ   r-   Úpaths   &  r3   ÚparseÚsandbox_cp.<locals>.parse  sK   € ð �#Œ:˜cŸn™n¨_×=Ò=Ø"Ÿy™y¨¨aÓ0ÑˆJÜ�:‹ Ô"Ø!Ð'Ð'Ø�SˆyÐr5   NzHExactly one of SRC and DST must be a sandbox path (<sandbox_id>:<path>).r7   ÚCopied)r˜   r™   )r   r;   ÚfilesÚdownloadÚuploadr!   rU   )
r˜   r™   r.   r/   r¨   Úsrc_sandboxÚsrc_pathÚdst_sandboxÚdst_pathr:   s
   &&&&      r3   Ú
sandbox_cpr²   ò   sÆ   € õñ " #›JÑ€KÙ! #›JÑ€KØ�tÐ °Ð!4Ô5ÜÐaÓbÐbØÒÜ�k¸e×DÕDÈØ�M‰M×"Ñ" 8Ô6÷ EÐDð Ò&Ð&Ð&Ü�k¸e×DÕDÈØ�M‰M× Ñ  Ô4÷ Eä‡J‚Jˆx˜S×*÷ E×Dú÷ E×Dús   Á
CÂ
CÃC	ÃC+	Úkillc                óö   € V ^8„  d   QhR\         \        R,          \        RR7      3,          R\         \        \	        RRR7      3,          R\         \        \	        R	R
RR7      3,          R\
        R\        RR/# )r,   r-   Nz$The sandbox or host id to terminate.r&   Úall_z--allz2Terminate every sandbox and host in the namespace.Úyesú-yú--yesú$Answer Yes to prompts automatically.r.   r/   r0   ©r   r1   r   rI   r    r$   r   )r2   s   "r3   r4   r4   !  s~   € ÷ /4ñ /4Üœ# �*¤hÐ4ZÔ&[Ð[Õ\ð/4ä
”Dœ& Ð/cÔdÐdÕ
eð/4ô 
”4œ  gÐ4ZÔ[Ð[Õ	\ð/4ô ð	/4ô
 ð/4ð 
ñ/4r5   c                ón  € \        VR7      pV'       dÈ   \        VP                  RR.\        R/VR7      4      pV'       g   \        P
                  ! R4       R# \        P                  ! R\        V4       R	2VR
7       V F4  pVP                  VP                  VP                  P                  R7       K6  	  \        P                  ! R\        V4      R7       R# V f   \        R4      h\        W4      w  r‰\        V9   dJ    \!        WVR7      ;_uu_ 4       p
V
P#                  4        RRR4       \        P                  ! RT R7       R# VP)                  W‰R7      pVP*                  ;'       g    / P-                  \.        4      \0        8X  dh   \        P                  ! RV R2VR
7       VP                  VP                  VP                  P                  R7       \        P                  ! RVR7       R#  \!        WVR7      ;_uu_ 4       p
V
P#                  4        RRR4       \        P                  ! RT R7       R#   + '       g   i     EL; i  \$         d   p\        \'        T4      4      ThRp?ii ; i  + '       g   i     Lf; i  \$         d   p\        \'        T4      4      ThRp?ii ; i)z@Terminate a sandbox, a whole shared host, or everything (--all).©r/   ÚRUNNINGÚ
SCHEDULINGÚ1©ÚstatusrS   r.   zNo running sandboxes.Nú
Terminate zA sandbox job(s) (including shared hosts and all their sandboxes)?©r¶   ©Újob_idr.   Ú
Terminated)Újobsz*Provide a sandbox id, a host id, or --all.r7   zSandbox terminated)rM   zTerminate shared host z and all of its sandboxes?zHost terminated)r   rg   Ú	list_jobsr   r!   ÚtextÚconfirmr¦   Ú
cancel_jobrM   Úownerr)   rU   r   r   r   r;   r³   r   r1   Úinspect_jobrS   Úgetr	   r
   )r-   rµ   r¶   r.   r/   ÚapirÇ   ÚjobÚsidÚnsr:   Úes   &&&&&       r3   Úsandbox_killrÔ     s  € ô  ˜5Ô
!€CçÜ�C—M‘M¨)°\Ð)BÌMÐ[^ÐK_Ðkt�MÓuÓvˆßÜ�HŠHÐ,Ô-ÙÜ�Š�j¤ T£ Ð+lÐmÐsvÕwÛˆCØ�N‰N #§&¡&°C·I±I·N±NˆNÖCñ ä�
Š
�<¤c¨$£iÕ0ÙàÒÜÐCÓDÐDä 
Ó6�G€CÜ˜Ôð	*Ü˜*À×GÕGÈ7Ø—‘”÷ Hô 	�
Š
Ð'¨JÕ7Ùð �/‰/ ˆ/Ó
3€CØ�
‰
×Ð�b×ÑœjÓ)¬YÔ6Ü�ŠÐ,¨S¨EÐ1KÐLÐRUÕVØ�‰˜cŸf™f°·	±	·±ˆÔ?Ü�
Š
Ð$¨Õ-Ùð&Ü�j¸U×CÕCÀwØ�L‰LŒN÷ Dô ‡J‚JÐ#¨
×3÷' H×GÐGûäô 	*Üœ3˜q›6Ó"¨Ð)ûð	*ú÷ D×Cûäô &Ü”s˜1“vÓ AÐ%ûð&úsl   ÄI ÄI Ä*I Ç8J ÈI<ÈJ É I	ÉI ÉI ÉI9ÉI4É4I9É<J	ÊJ ÊJ ÊJ4ÊJ/Ê/J4c                ój  € V ^8„  d   QhR\         \        R,          \        RR7      3,          R\        R\         \        \        R^R\         R	2R
7      3,          R\         \        R,          \        R^RR
7      3,          R\         \        R,          \        RR7      3,          R\        R\        RR/# )r,   r?   Nz+Docker image for the hosts (needs /bin/sh).r&   r@   Úper_hostz
--per-hostz&Sandboxes packed per host VM (default z).)Úminr'   Ú	max_hostsz--max-hostsz'Optional cap on the number of host VMs.rA   zZShut a host down once it has had no sandboxes for this long (e.g. '10m'). Defaults to 10m.r.   r/   r0   )	r   r1   r   r"   Úintr    r   r$   r   )r2   s   "r3   r4   r4   [  sÓ   € ÷ (Zñ (ZÜ”S˜4•Z¤Ð/\Ô!]Ð]Õ^ð(Zäð(Zô ÜÜˆ| Ð+QÔRlÐQmÐmoÐ)pÔqð	sõð(Zô Üˆd�
”F˜=¨aÐ6_Ô`Ð`õð(Zô Üˆd�
ÜÐpÔqð	sõð(Zô ð(Zô ð(Zð  
ñ!(Zr5   c           
     óÊ  € \         P                   ! 4       pT ;'       g    \        p \        T T;'       g    RTTVe   TM\        VVR7      pVP                  p	VP
                  p
\        P                  ! RT	T T;'       g    RV
^ ,          \         P                   ! 4       V,
          R R2R7       \        P                  ! RV	 R	24       \        P                  ! R
V	 R	24       R# )zRWarm a pool: boot one host VM now, tagged so it can be found later by its pool id.rQ   N)r?   r@   Úsandboxes_per_hostrØ   rA   r.   r/   zPool createdrK   rL   )rM   r?   r@   rN   rO   z/Spawn a sandbox with `hf sandbox create --pool rP   z=Delete the pool (and its hosts) with `hf sandbox pool delete )	rT   r   r   r   r)   Úhost_idsr!   rU   rW   )r?   r@   rÖ   rØ   rA   r.   r/   rX   r(   Úpool_idrÜ   s   &&&&&&&    r3   Úpool_createrÞ   S  sÍ   € ô4 �IŠI‹K€EØ×"Ð"”]€EÜØØ×$Ð$˜Ø#ØØ%1Ò%=‘\ÔCWØØô€Dð �i‰i€GØ�}‰}€HÜ‡J‚JØØØØ×$Ð$˜Ø�a�[Ü—9’9“; Õ& sÐ+¨1Ð-õô ‡H‚HÐ>¸w¸iÀrÐJÔKÜ‡H‚HÐLÈWÈIÐUWÐXÖYr5   z	ls | listzhf sandbox pool lsc                ó4   € V ^8„  d   QhR\         R\        RR/# )r,   r.   r/   r0   N)r$   r   )r2   s   "r3   r4   r4   ‡  s+   € ÷ Jñ JÜðJäðJð 
ñJr5   c                óÎ  € \        VR7      p/ pVP                  R\        \        /V R7       FÍ  pVP                  ;'       g    / P                  \        4      pV'       g   K6  \        VP                  \        4      '       d   VP                  M/ pTP                  TRTRVP                  ;'       g    VP                  RVP                  RVP                  RR	4      R
^ /4      pVR
;;,          ^,          uu&   KÏ  	  \        VP                  4       4      p\         P"                  ! VRR7       V'       g   \         P$                  ! R4       R# \         P$                  ! R4       R# )z9List running sandbox pools (grouped from their host VMs).r¼   r½   rÀ   rM   r?   r@   rÖ   ÚSBX_CAPACITYÚ Úhosts©Úid_keyz)Create one with `hf sandbox pool create`.z5Spawn a sandbox with `hf sandbox create --pool <id>`.N)r   rÈ   r	   r
   rS   rÎ   r   Ú
isinstanceÚenvironmentÚdictÚ
setdefaultÚdocker_imageÚspace_idr@   rg   Úvaluesr!   ÚtablerW   )	r.   r/   rÏ   ÚpoolsrÐ   r“   rB   ÚinfoÚrowss	   &&       r3   Úpool_lsrñ   †  s  € ô ˜5Ô
!€CØ')€EØ�}‰} I´zÄ9Ð6MÐYbˆ}ÖcˆØ�z‰z×Ð˜R×$Ñ$¤ZÓ0ˆßÙÜ!+¨C¯O©O¼T×!BÒ!Bˆc�oŠoÈˆØ×ÑØà�cØ˜×)Ñ)×9Ð9¨S¯\©\Ø˜#Ÿ*™*Ø˜CŸG™G N°BÓ7Ø˜ðó	
ˆð 	ˆW�˜Õ�ñ dô  �—‘“Ó€DÜ‡I‚Iˆd˜4Õ ßÜ�ŠÐ<Ö=ä�ŠÐHÖIr5   zdelete | rmz hf sandbox pool delete <pool_id>c                ó¬   € V ^8„  d   QhR\         \        \        RR7      3,          R\         \        \	        RRRR7      3,          R\
        R	\        R
R/# )r,   rÝ   zPool id to delete.r&   r¶   r·   r¸   r¹   r.   r/   r0   Nrº   )r2   s   "r3   r4   r4   ª  se   € ÷ Hñ HÜ”sœHÐ*>Ô?Ð?Õ@ðHä	”4œ  gÐ4ZÔ[Ð[Õ	\ðHô ðHô ð	Hð
 
ñHr5   c           	     óø  € \        VR7      p\        VP                  RR.\        \        \
        V /VR7      4      pV'       g(   \        V 4       \        P                  ! RV  R24       R# \        P                  ! R\        V4       R	V  R
2VR7       V F4  pVP                  VP                  VP                  P                  R7       K6  	  \        V 4       \        P                  ! RV \        V4      R7       R# )zDTerminate every host VM of a pool (and therefore all its sandboxes).r¼   r½   r¾   rÀ   zNo running hosts for pool 'z'.NrÂ   z host(s) of pool 'z' (and all their sandboxes)?rÃ   rÄ   zPool deleted)rM   Úhosts_terminated)r   rg   rÈ   r	   r
   r   r   r!   rÉ   rÊ   r¦   rË   rM   rÌ   r)   rU   )rÝ   r¶   r.   r/   rÏ   rã   rÐ   s   &&&&   r3   Úpool_deleterõ   ¦  sÌ   € ô ˜5Ô
!€CÜØ�‰Ø˜|Ð,Ü¤	¬:°wÐ?Øð 	ó 	
ó€E÷ Ü˜'Ô"Ü�ŠÐ.¨w¨i°rÐ:Ô;ÙÜ‡K‚K�*œS ›Z˜LÐ(:¸7¸)ÐC_Ð`ÐfiÕjÛˆØ�‰˜cŸf™f°·	±	·±ˆÖ?ñ ä�gÔÜ‡J‚Jˆ~ '¼CÀ»J×Gr5   c                ó\   € V ^8„  d   QhR\         \        \         ,          ,          R\         /# )r,   Úcmdr0   )r1   rg   )r2   s   "r3   r4   r4   Ä  s"   € ÷ :ñ :”#œœS�	•/ð :¤cñ :r5   c                 óT   € \        V \        4      '       d   V # R P                  V 4      # )r”   )ræ   r1   Újoin)r÷   s   &r3   Ú_fmt_cmdrú   Ä  s!   € Ü˜S¤#×&Ò&ˆ3Ð9¨C¯H©H°S«MÐ9r5   c                ó0   € V ^8„  d   QhR\         R\        /# )r,   r*   r0   )r   r1   )r2   s   "r3   r4   r4   È  s   € ÷ Vñ Vœð V¬Cñ Vr5   c                 ój   € V P                   '       d   R # V P                  f   R# RV P                   R2# )ÚrunningÚexitedzexited (Ú))rý   rŒ   )r*   s   &r3   Ú_fmt_statusr   È  s5   € Ø‡‡€ÙØ×(Ñ(Ò0ˆ8ÐU¸À×ARÑARÐ@SÐSTÐ6UÐUr5   z"hf sandbox process ls <sandbox_id>c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# )r,   r-   r.   r/   r0   N)rf   r$   r   )r2   s   "r3   r4   r4   Ï  s6   € ÷ Qñ QÜðQäðQô ðQð 
ñ	Qr5   c                ó¸  € \        WVR7      ;_uu_ 4       pVP                  4       pRRR4       X Uu. uF1  pRVP                  R\        V4      R\	        VP
                  4      /NK3  	  pp\        P                  ! VRR7       V'       g   \        P                  ! RV  R24       R# \        P                  ! R	V  R
24       R#   + '       g   i     L¥; iu upi )zUList the background processes running in a sandbox (started with `hf sandbox spawn`).r7   Nr“   rÁ   r÷   rä   z!Start one with `hf sandbox spawn z -- <cmd>`.z'Stop one with `hf sandbox process kill z <pid>`.)	r;   Ú	processesr“   r   rú   r÷   r!   rí   rW   )r-   r.   r/   r:   r  Úprð   s   &&&    r3   Ú
process_lsr  Î  s¤   € ô 
�*¸×	?Õ	?À7Ø×%Ñ%Ó'ˆ	÷ 
@áV_Ó`ÑV_ÐQRˆU�A—E‘E˜8¤[°£^°U¼HÀQÇUÁU»OÓLÑV_€DÐ`Ü‡I‚Iˆd˜5Õ!ßÜ�ŠÐ4°Z°LÀÐLÖMä�ŠÐ:¸:¸,ÀhÐOÖP÷ 
@×	?üâ`s   –C³7CÃC	z*hf sandbox process kill <sandbox_id> <pid>c          
      óz   € V ^8„  d   QhR\         R\        \        \        RR7      3,          R\        R\
        RR/# )	r,   r-   r“   z.The pid as printed by `hf sandbox process ls`.r&   r.   r/   r0   N)rf   r   rÙ   r   r$   r   )r2   s   "r3   r4   r4   à  sJ   € ÷ ?ñ ?Üð?ä	”3œÐ&VÔWÐWÕ	Xð?ô ð?ô ð	?ð
 
ñ?r5   c           	     ó0  a€ \        WVR7      ;_uu_ 4       p\        V3R lVP                  4        4       R4      pVf   \        RS RV  R24      hVP	                  4        RRR4       \
        P                  ! RV SR7       R#   + '       g   i     L+; i)	z/Stop a background process running in a sandbox.r7   c              3   óL   <"  € T F  qP                   S8X  g   K  Vx € K  	  R # 5irq   )r“   )Ú.0r  r“   s   & €r3   Ú	<genexpr>Úprocess_kill.<locals>.<genexpr>è  s   øé € ÐGÑ#6˜a¿%¹%À3¹,ŸšÓ#6ùs   ƒ$š
$NzNo process with pid z in sandbox r¡   zProcess stoppedr’   )r;   Únextr  r   r³   r!   rU   )r-   r“   r.   r/   r:   r*   s   &f&&  r3   Úprocess_killr  ß  s{   ø€ ô 
�*¸×	?Õ	?À7ÜÔG 7×#4Ñ#4Ô#6ÓGÈÓNˆØŠ?ÜÐ1°#°°lÀ:À,ÈaÐPÓQÐQØ�‰Œ÷	 
@ô
 ‡J‚JÐ ¨*¸#×>÷ 
@×	?ús   —ABÂB	)zhf sandbox createzhf sandbox create ubuntu:24.04z%hf sandbox create --flavor a10g-smallz/hf sandbox create --label controller-run=run-42z@hf sandbox create --pool pool-ab12cd34ef56 --env LOG_LEVEL=debug)NNNNNNNNNNNFN)NNNNNN)NNNNN)NN)zhf sandbox kill <sandbox_id>zKhf sandbox kill <host_id>   # kills a whole shared host (all its sandboxes)zhf sandbox kill --all)NFFNN)zhf sandbox pool createz5hf sandbox pool create python:3.12 --flavor cpu-basicz7hf sandbox pool create --per-host 50 --idle-timeout 30m)FNN)EÚ__doc__rr   rT   Ú
contextlibr   Útypingr   r   r   r‰   Úhuggingface_hub._sandboxr   r   r   r	   r
   r   r   r   r   r   r   r   Úhuggingface_hub._sandbox_cacher   Úhuggingface_hub.errorsr   r   Ú
_cli_utilsr   r   r   r   r   r   r   r   r   r   Ú
_frameworkr   r    Ú_outputr!   rÇ   r"   r#   r$   r%   Úsandbox_cliÚpool_cliÚ	add_groupÚprocess_clir1   rf   r;   r`   r[   r�   r•   r²   rÔ   rÞ   rñ   rõ   rú   r   r  r  © r5   r3   Ú<module>r     sÝ  ðñ Jã 
Û Ý %ß +Ñ +ã ÷÷ ÷ ó õ =ß 9÷÷ ÷ ÷ )Ý ß GÓ Gñ Ð!^Ô_€ÙØ	sô€ð × Ñ �h VÐ Ô ,ÙÐ![Ô\€Ø × Ñ �k¨	Ð Ô 2à˜™hÐ,_Ô`Ð`Õa€ð ôó ðð ×ÑØòð ó 	öFCó	ðFCðR ×ÑØ
Ø.°Ð5à?Ø;ðð ó ö)bóð)bðX ×ÑØØ.°Ð5àEØBðð ó öTóðTð* ×ÑØà<ØAðð ó ö+óð+ð@ ×ÑØ
òð ó ö/4óð/4ðd 
×ÑØòð ó ð bfØð 	#ð 	ð 	Ø"Øö(Zóð(ZðV 
×Ñ�+Ð)=Ð(>ÐÓ?öJó @ðJð> 
×ÑØØ0Ð1ð ó öHó	ðHõ4:õVð ×Ñ�[Ð,PÐ+QÐÓRöQó SðQð  ×Ñ�VÐ'SÐ&TÐÓUö?ó Vò?r5   