
    Y jҔ                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKJr  SSKJr  SSKJrJrJrJr  SSKrSSKJr  SSKJr  SSKJr  SS	KJrJr  SS
KJrJ r   SSK!J"r"J#r#J$r$J%r%  SSK&J'r'  SSK(J)r)J*r*J+r+  SSK,J-r-  SSK.J/r/  SSK0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArAJBrB  SSKCJDrD  SSKEJFrF  SrG\H" \" \)5      5      rI\" \+5      rJ\R                  " S\J V s0 s H  o U _M     sn \LS9rM\\LS-  \R                  " SSR                  \I5       S3\?" \I5      S94   rP\B" SS9rQ\B" SS9rR\B" SS9rS\B" SS9rT\QR                  \RS S!9  \QR                  \SS"S!9  \QR                  \TS#S!9  \QR                  S$/ S%QS&9SSSSS\1SS'S'S'SS4S(\\LS-  \R                  " S)S94   S*\8S+\2S,\5S-\\MS-  \R                  " S.S94   S/\6S0\PS1\\X\R                  " S2S3S4S94   S5\\X\R                  " S6S7S94   S8\\X\R                  " S9S:S;S94   S<\7S=\;S>S4S? jj5       rY\QR                  S@SASB/S&9   SSC\\L\R                  " SDS94   S<\7S0\PS=\;S>S4
SE jj5       rZ\QR                  SF/ SGQS&9   SSC\\L\R                  " SDS94   SH\\X\R                  " SISJS94   SK\\X\R                  " SLSMS94   S=\;S>S4
SN jj5       r[\QR                  S*/ SOQS&9      SSP\\L\R                  " SQS94   S,\5SR\\\\L   S-  \R                  " SSS94   ST\\X\R                  " SUS94   SV\\X\R                  " SWS94   S/\6S=\;S>S4SX jj5       r]\QR                  SYSZ/S&9  SSC\\L\R                  " SDS94   S[\\X\R                  " S\S94   S=\;4S] jj5       r^\QR                  S^S_/S&9 SSC\\L\R                  " SDS94   S=\;S>S4S` jj5       r_\QR                  SaSbSc/S&9  SSC\\L\R                  " SDS94   Sd\\X\R                  " SeSfS94   S=\;S>S4Sg jj5       r`\QR                  ShSi/S&9SS=\;S>S4Sj jj5       ra\QR                  SkSlSm/S&9   SSC\\L\R                  " SDS94   Sn\\bS-  \R                  " SoSpS94   Sh\\S-  \R                  " SqSrS94   S=\;S>S4
Ss jj5       rc\QR                  St/ SuQS&9    SSC\\L\R                  " SDS94   Sv\\X\R                  " SwSxS94   Sy\\X\R                  " SzS{S|S94   S}\\bS-  \R                  " S~SSS94   S=\;S>S4S jj5       rd\QR                  S/ SQS&9     SSC\\L\R                  " SDS94   S\\LS-  \R                  " SS94   S\\S-  \R                  " SSzSS94   S\\X\R                  " SS94   S\\X\R                  " SS94   S=\;S>S4S jj5       reS\*SC\LS\LS-  S\LS\LS\LS=\LS-  S>S4S jrfSrg\R                  S>\LS-  4S j5       riS\LS>\b\S   -  4S jrj\RR                  S$S/S&9 SSC\\L\R                  " SDS94   S=\;S>S4S jj5       rk\RR                  SSS/S&9  SSC\\L\R                  " SDS94   S\<S=\;S>S4S jj5       rl\RR                  SSS/S&9  SSC\\L\R                  " SDS94   S\\X\R                  " SSSS94   S=\;S>S4S jj5       rm\SR                  S$S/S&9 SSC\\L\R                  " SDS94   S=\;S>S4S jj5       rn\SR                  S/ SQS&9   SSC\\L\R                  " SDS94   S"\:S\9S=\;S>S4
S jj5       ro\SR                  SSS/S&9  SSC\\L\R                  " SDS94   S\\L\R                  " SS94   S\\X\R                  " SSSS94   S=\;S>S4
S jj5       rp\TR                  S$S/S&9 SSC\\L\R                  " SDS94   S=\;S>S4S jj5       rq\TR                  S/ SQS&9   SSC\\L\R                  " SDS94   S\4S\3S=\;S>S4
S jj5       rr\TR                  SSS/S&9  SSC\\L\R                  " SDS94   S\\L\R                  " SS94   S\\X\R                  " SSSS94   S=\;S>S4
S jj5       rsgs  sn f )a  Contains commands to interact with spaces on the Hugging Face Hub.

Usage:
    # list spaces on the Hub
    hf spaces ls

    # list spaces with a search query
    hf spaces ls --search "chatbot"

    # get info about a space
    hf spaces info enzostvs/deepsite
    N)deque)Path)TYPE_CHECKING	AnnotatedLiteralget_args)version)assert_never)multi_replica_reload_events)ApiGetReloadEventSourceDataReloadRegion)SpaceHardware
SpaceStage)CLIErrorRemoteEntryNotFoundErrorRepositoryNotFoundErrorRevisionNotFoundError)hf_hub_download)ExpandSpaceProperty_THfApiSpaceSort_T)	SpaceCard)disable_progress_bars   )REPO_LIST_DEFAULT_LIMIT	AuthorOpt
EnvFileOptEnvOpt	FilterOptLimitOptRevisionOpt	SearchOptSecretsFileOpt
SecretsOptTokenOpt
VolumesOptapi_object_to_dict
get_hf_apimake_expand_properties_parserparse_env_mapparse_volumestyper_factory)list_repo_files_cmd)outz6.1.0SpaceSortEnum)typezComma-separated properties to return. When used, only the listed properties (and id) are returned. Example: '--expand=likes,tags'. Valid: , .)helpcallbackz Interact with spaces on the Hub.)r3   z&Manage volumes for a Space on the Hub.z&Manage secrets for a Space on the Hub.z4Manage environment variables for a Space on the Hub.volumes)namesecrets	variablesz	list | ls)zhf spaces ls --limit 10z4hf spaces ls --search "chatbot" --author huggingfacezhf spaces ls victor/deepsitezhf spaces ls victor/deepsite -Rz&hf spaces ls victor/deepsite --tree -h)examplesFrepo_idzRSpace ID (e.g. `username/repo-name`) to list files from. If omitted, lists spaces.searchauthorfiltersortzSort results.limitexpandhuman_readablez--human-readablez-hz=Show sizes in human readable format (only for listing files).as_treez--treez3List files in tree format (only for listing files).	recursivez--recursivez-Rz0List files recursively (only for listing files).revisiontokenreturnc           
         U b  Ub  [         R                  " S5      eUb  [         R                  " S5      eUb  [         R                  " S5      eUb  [         R                  " S5      eU[        :w  a  [         R                  " S5      eUb  [         R                  " S5      e[        U SUUU	U
US	9$ U(       a  [         R                  " S
5      eU	(       a  [         R                  " S5      eU(       a  [         R                  " S5      eU
b  [         R                  " S5      e[	        US9nU(       a  UR
                  OSnUR                  UUUUUUS9 Vs/ s H  n[        U5      PM     nn[        R                  " U5        gs  snf )zList spaces on the Hub, or files in a space repo.

When called with no argument, lists spaces on the Hub.
When called with a space ID, lists files in that space repo.
Nz'Cannot use --search when listing files.z'Cannot use --author when listing files.z'Cannot use --filter when listing files.z%Cannot use --sort when listing files.z&Cannot use --limit when listing files.z'Cannot use --expand when listing files.space)r:   	repo_typerA   rB   rC   rD   rE   z&Cannot use --tree when listing spaces.z+Cannot use --recursive when listing spaces.z0Cannot use --human-readable when listing spaces.z*Cannot use --revision when listing spaces.rE   )r=   r<   r;   r>   r?   r@   )
typerBadParameterr   r-   r(   valuelist_spacesr'   r.   table)r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   apisort_key
space_inforesultss                   k/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/huggingface_hub/cli/spaces.py	spaces_lsrU   g   s   X $$%NOO$$%NOO$$%NOO$$%LMM++$$%MNN$$%NOO")
 	
   !IJJ  !NOO  !STT  !MNN
5
!C!tzztH // * 


J 	:&
  
 IIg
s   Finfoz hf spaces info enzostvs/deepsitez>hf spaces info gradio/theme_builder --expand sdk,runtime,likesspace_idz)The space ID (e.g. `username/repo-name`).c                     [        US9n UR                  XUS9n[
        R                  " U5        g! [         a  n[        SU  S35      UeSnAf[         a  n[        SU SU  S35      UeSnAff = f)	z"Get info about a space on the Hub.rJ   )r:   rD   r@   zSpace 'z' not found.Nz
Revision 'z' not found on ''.)r(   rR   r   r   r   r.   dict)rW   rD   r@   rE   rP   rV   es          rT   spaces_infor\      s     5
!CS~~h&~Q
 HHTN	 # @
,78a?  SH:-=hZrJKQRRSs    2 
A1AA1A,,A1card)zhf spaces card mteb/leaderboardz*hf spaces card mteb/leaderboard --metadataz8hf spaces card mteb/leaderboard --metadata --format jsonz&hf spaces card mteb/leaderboard --textmetadataz
--metadataz'Output only the metadata from the card.textz--textz(Output only the text body (no metadata).c                    U(       a  U(       a  [        S5      e[        R                  " XS9nU(       a/  [        R                  " UR
                  R                  5       5        gU(       a!  [        R                  " UR                  5        g[        R                  " UR                  5        [        R                  " SU  S35        g)z3Get the Space card (README) for a Space on the Hub.z---metadata and --text are mutually exclusive.rJ   zUse `hf spaces card z/ --metadata` to extract only the card metadata.N)
r   r   loadr.   rZ   datato_dictr_   contenthint)rW   r^   r_   rE   r]   s        rT   spaces_cardrf      sy      DFGG>>(0D""$%	'z1`ab    )z!hf spaces search "generate image"zFhf spaces search "identify objects in pictures" --sdk gradio --limit 5zDhf spaces search "remove background from photo" --description --jsonqueryzSearch query.sdkz,Filter by SDK (e.g. gradio, docker, static).include_non_runningz&Include non-running spaces in results.descriptionzShow AI-generated descriptions.c                 <   [        US9nUR                  U UUUUS9n/ n	[        R                  " X5       H  n
U
R                  U
R
                  U
R                  U
R                  U
R                  (       a  U
R                  R                  OSU
R                  U
R                  b  [        U
R                  S5      OSS.nU(       a  U
R                  US'   U	R                  U5        M     [        R                   " U	5        U(       d  [        R"                  " S5        gg)z/Search spaces on the Hub using semantic search.rJ   )rh   r=   ri   rj   rE   N   )idtitleri   likesstagecategoryscorerk   z4Use --description to show AI-generated descriptions.)r(   search_spaces	itertoolsislicern   ro   ri   rp   runtimerq   ai_categorysemantic_relevancy_scoreroundai_short_descriptionappendr.   rO   re   )rh   r=   ri   rj   rk   r?   rE   rP   rS   itemsritems               rT   spaces_searchr      s    $ 5
!C/   G Eg-$$WW55WW()		QYY__t=>=W=W=cU155q9im
 "#"8"8DT . IIeGH rg   zdev-modez(hf spaces dev-mode my-user-name/deepsitestopzStop dev mode.c                 b   [        US9nU(       a!  UR                  U 5        [        SU  S35        gUR                  U 5        UR	                  U 5      n[        UR                  SUR                  S:X  a  SOS5      nU(       a  S	U 3OSn[        S
UR                   35        [        R                  S[        R                  S[        R                  S[        R                  S0n[        R                  " 5       n UR	                  U 5      nUR                   c  [        S5        gUR                   R"                  U;  a  O?UR%                  XtR                   R"                     5        [&        R(                  " S5        M  UR                   R"                  [        R*                  :w  a*  UR-                  SUR                   R"                   S35        gUR-                  S5        [        S5        [        S5        [        S5        SUR                   S3n	U(       a  U	SU 3-  n	UR.                   S3n
[        SU	 35        [        S5        [        S5        [        S5        [        SU
 S35        [        S5        [        SU
 U 35        [        SU
 U 35        [        S5        [        S 5        g)!a`  
Enable or disable dev mode on a Space.

Spaces Dev Mode eases the debugging of your application and makes iterating on Spaces faster by allowing you to
restart your application without stopping the Space container itself. This feature is available as part of a PRO
or Team & Enterprise plan.

See docs: https://huggingface.co/docs/hub/spaces-dev-mode
rJ   zDev mode disabled for ''Nzdev-mode-folderdocker z/home/user/appzfolder=zWDev mode is currently building, track the progress here: https://huggingface.co/spaces/zbuilding...zapp starting...z Runtime of the space unavailabler   zDev mode is not ready (stage='z')zDev mode ready!zConnect to dev environment:zWeb:zhttps://huggingface.co/spaces/z/dev-mode/vscode-web?z@ssh.hf.spacez  * VSCode: zLocal:z;1. Add your SSH key to https://huggingface.co/settings/keysz2. SSH with `ssh -i <your_key> `z
   Or openz.  * VSCode: vscode://vscode-remote/ssh-remote+z.  * Cursor: cursor://vscode-remote/ssh-remote+zXPS: Dev mode stops after 48h of inactivity, don't forget to save your changes regularly.)r(   disable_space_dev_modeprintenable_space_dev_moderR   getattr	card_datari   rn   r   BUILDINGRUNNING_BUILDINGAPP_STARTINGRUNNING_APP_STARTINGr.   statusrw   rq   updatetimesleepRUNNINGdone	subdomain)rW   r   rE   rP   rV   folderfolder_query_param"intermediate_statuses_and_messagesr   vscode_web_urlssh_hosts              rT   dev_moder   #  sY   ( 5
!C""8,'z34h'>>(#DT^^%6dhh(>RXhiF/576(+2	cdhdkdkcl
mn]##]!2''):	*& ZZ\F
~~h'<<45<<%GG89K9KLM

1  ||Z///4T\\5G5G4HKL
KK!"	
'(	"I	&M5dggY>RSNA0122..!/H	L(
)*	"I	(O	
GH	+H:Q
78	,	:8*VH
MN	:8*VH
MN	"I	
derg   pausez!hf spaces pause username/my-spacec                     [        US9nUR                  U 5      n[        R                  " SXR                  S9  [        R
                  " SU  S35        [        R
                  " SU  S35        g)	zPause a Space.rJ   zSpace paused)rW   rq   zUse `hf spaces restart z` to restart it.QMount a Volume or bucket to persist data across restarts: `hf spaces volumes set  -v hf://...`N)r(   pause_spacer.   resultrq   re   )rW   rE   rP   rw   s       rT   spaces_pauser   h  s`     5
!Cooh'GJJ~FHH&xj0@ABHH
[\d[eersrg   restartz#hf spaces restart username/my-spacez4hf spaces restart username/my-space --factory-rebootfactory_rebootz--factory-rebootz=Rebuild the Space from scratch without using the build cache.c                     [        US9nUR                  XS9n[        R                  " SU UR                  US9  [        R
                  " SU  S35        [        R
                  " SU  S35        g	)
zRestart a Space.rJ   )r   zSpace restart triggered)rW   rq   r   Use `hf spaces info z` to monitor the runtime stage.r   r   N)r(   restart_spacer.   r   rq   re   )rW   r   rE   rP   rw   s        rT   spaces_restartr   |  sq    & 5
!CHGJJ!mm%	 HH#H:-LMNHH
[\d[eersrg   hardwarezhf spaces hardwarec                 l   [        U S9nUR                  5       n/ nU H  nUR                  (       aG  UR                  R                   SUR                  R                   SUR                  R
                   S3OSnUR                  (       a  SUR                  S 3OSnUR                  (       a  SUR                  S	-  S
 3OSnUR                  UR                  UR                  UR                  UR                  UUUS.5        M     [        R                  " U5        [        R                  " S5        g)z+List available hardware options for Spaces.rJ   zx z ()N$z.4ffree<   z.2f)r6   zpretty namecpuramacceleratorzcost/minz	cost/hourzVUse `hf spaces settings <space_id> --hardware <name>` to request hardware for a Space.)r(   list_spaces_hardwarer   quantitymodelvramunit_cost_usdr|   r6   pretty_namer   r   r.   rO   re   )rE   rP   hardware_listr}   hwr   cost_min	cost_hours           rT   spaces_hardwarer     s	    5
!C,,.ME\^\j\jr~~&&'r"..*>*>)?r"..BUBUAVVWXpt 	 241A1AQr'',-v797G7Ga((2-c23V	!~~vvvv*$&
	
 " IIeHHefrg   settingsz5hf spaces settings username/my-space --sleep-time 300z9hf spaces settings username/my-space --hardware t4-medium
sleep_timez--sleep-timezuIdle time in seconds after which the Space goes to sleep. Use -1 to never sleep. Only available on upgraded hardware.z
--hardwarezrSpace hardware flavor (e.g. 'cpu-basic', 't4-medium', 'l4x4'). Run 'hf spaces hardware' to list available options.c                    [        US9nUb  UR                  XUS9nOUb  UR                  XS9nO[        S5      e[        R
                  " SU UR                  UR                  S9  [        R                  " SU  S	35        g)
zUpdate the settings of a Space.rJ   N)r   r   )r   z'Specify at least one setting to update.zSpace settings updated)rW   r   r   r   z&` to verify the runtime configuration.)	r(   request_space_hardwareset_space_sleep_timer   r.   r   requested_hardwarer   re   )rW   r   r   rE   rP   rw   s         rT   spaces_settingsr     s    4 5
!C,,XU_,`		**8*K@AAJJ ++%%	 HH#H:-STUrg   logs)z hf spaces logs username/my-spacez(hf spaces logs username/my-space --buildz#hf spaces logs -f username/my-spacez&hf spaces logs -n 50 username/my-spacebuildz--buildzdFetch the container build logs instead of the run logs. Useful when a Space is stuck in BUILD_ERROR.followz-fz--followz|Follow log output (stream until the server closes the stream). Without this flag, only currently available logs are printed.tailz-nz--tailz1Number of lines to show from the end of the logs.c                 D   U(       a  Ub  [        S5      e[        US9nUR                  XUS9nUb	  [        XcS9nSnU H4  nUR	                  5       n	[
        R                  " U	5        U	(       d  M2  SnM6     U(       d#  U(       d  [
        R                  " SU  S	35        ggg)
a(  Fetch the run or build logs of a Space.

By default, prints currently available run logs and exits (non-blocking, like
`docker logs`). Use --follow/-f to stream until the server closes the stream.
Use --build to see the container build logs instead (useful when a Space is
stuck in BUILD_ERROR).
NzcCannot use --follow and --tail together. Use --follow to stream logs or --tail to show recent logs.rJ   )r   r   )maxlenFTzNo run logs found for space z2. Try passing --build to fetch build logs instead.)r   r(   fetch_space_logsr   stripr.   r_   re   )
rW   r   r   r   rE   rP   r   
found_logsline
clean_lines
             rT   spaces_logsr     s    V $"q
 	
 5
!CfEDT'JZZ\
:J	 
 e/z9klm $:rg   z
hot-reload)zihf spaces hot-reload username/repo-name app.py     # Open an interactive editor to the remote app.py filezohf spaces hot-reload username/repo-name -f app.py  # Take local version from ./app.py and patch app.py remotelyzchf spaces hot-reload username/repo-name app.py -f src/app.py # Take local version from ./src/app.pyfilenamez~Path to the Python file in the Space repository. Can be omitted when --local-file is specified and path in repository matches.
local_filez--local-filez<Path of local file. Interactive editor mode if not specifiedskip_checksz%Skip hot-reload compatibility checks.skip_summaryz2Skip summary display after hot-reload is triggeredc           
         [         R                  " S[         R                  R                  S9  [	        US9nU(       d  UR                  U 5      nUR                  S:w  a  [        SUR                   S35      eUR                  =nc  [        SU  35      eUR                  =n	c  [        S	U  S
35      e[        R                  " U	5      [        R                  " [        5      :  a  [        S[         SU	 S35      eUR                  =n
c  [        SU  35      eOSn
U(       a"  [        U5      nUc  UR!                  5       OUnGOoU(       Ga\  U(       d   UR#                  SU SS9  [&        R(                  " 5       n[*        R,                  R/                  UR0                  U5      n[3        5           [5        SXUR0                  S9  SSS5        [9        U5      nUS:X  a  [&        R:                  " 5       n[<        R>                  " UR0                  USS9  [*        R,                  R/                  X5      n[         R                  " S5        [         R                  " SU 35        [         R                  " SU  SU SU S35        gUS:X  a  [        S5      eUS :w  a  [        S!U 35      eO[        S"5      eURA                  SU UUU
SS#9nUbq  URC                  5       RE                  [F        RH                  " 5       5      (       a:  [         R                  " S$URJ                   S%35        [         R                  " S&5        U(       d9  [         R                  " S'5        [M        UU U
URJ                  U(       a  UOUUUS(9  gg! [$         a  n[        SU  S35      UeSnAff = f! [6         a4    [         R                  " U S3[         R                  R                  S9   GNf = f! , (       d  f       GN!= f))u  
Hot-reload any Python file of a Space without a full rebuild + restart.

⚠ This feature is experimental ⚠

Only works with Gradio SDK (6.1+)
Opens an interactive editor unless --local-file/-f is specified.

This command patches the live Python process using https://github.com/breuleux/jurigged
(AST-based diffing, in-place function updates, etc.), integrated with Gradio's native hot-reload support
(meaning that Gradio demo object changes are reflected in the UI)

The command creates a remote commit.
If you are working from a local clone, run `git pull --autostash` afterwards
to bring the commit back and keep your local git state in sync.
z2This feature is experimental and subject to changefgrJ   gradioz5Hot-reloading is only available on Gradio SDK. Found z SDKNz"Unable to read cardData for Space z Unable to read sdk_version from z	 cardDataz!Hot-reloading requires Gradio >= z (found r   z(Unexpected `None` running SHA for Space rH   T)rI   r:   writezWrite access check to z8 repository failed. Make sure that you are authenticated)rI   r:   r   	local_dirz2 not found in remote repository. Assuming new fileno-tty)dirs_exist_okz*No TTY detected. Non-interactive fallback:z- Edit z- Run `hf spaces hot-reload  z -f r   	no-editorzONo editor found in local environment. Use -f flag to hot-reload from local pathr   z>Editor returned a non-zero exit code while attempting to edit z4Either filename or --local-file/-f must be specified)rI   r:   path_or_fileobjpath_in_repoparent_commit_hot_reloadzCreated commit z in remote Space repository.z]Consider running `git pull --autostash` to stay synced if you are working from a local clone.zHot-reload summary:)rP   rW   current_sha
commit_sha
local_pathr   rE   )'rK   sechocolorsBRIGHT_BLACKr(   rR   ri   r   r   sdk_versionr	   parseVersionHOT_RELOADING_MIN_GRADIOshastras_posix
auth_checkr   tempfileTemporaryDirectoryospathjoinr6   r   r   r   _editor_openmkdtempshutilcopytreeupload_fileresolveis_relative_tor   cwdoid_spaces_hot_reload_summary)rW   r   r   r   r   rE   rP   rR   r   r   r   r   r[   temp_dir
editor_respersistent_temp_dircommit_infos                    rT   spaces_hot_reloadr  %  s   d 
KKDIbIbc
5
!C^^H-
>>X%RS]SaSaRbbfghh#---I6?zJKK$000K9=hZyQRR==%8P(QQ>?W>XX`al`mmnopp%>>)K2EhZPQQ 3 _
,4,<:&&((		%$   ..0WW\\(--:
"$'8bjbobop % "*-
!"*"2"2"4OOHMM+>dS&9DJKKDEKK'*./KK6xj(4PZ|[\]^$lmm?[\f[ghii  MNN//"! " K *"4"4"6"E"Edhhj"Q"Qokoo%66RSTst)*"#"%/zX	
 W + ,XJ6no , j RSX]XdXdXqXq %$sB   M< .O0N<
NNN:OOOO
O.rP   r   r   r   c                   ^^^ U R                  U5      =nR                  U:X  ap  Ub  X#:X  a  Og[        R                  " S[        R                  R
                  SS9  [        R                  " S5        U R                  U5      =nR                  U:X  a  Mp  UR                  U:w  a  [        SU SUR                   35      eUR                  =nc  [        SU S35      eUR                  =n	c  [        S	U S
35      eU	R                  S:w  a%  [        R                  " SU	R                  < 35        g UR                  =n
c  [        S5      eUR                  =nc  [        S5      eS[         S["        4U4S jjmS[$        SS 4UU4S jjn['        UU
UU	R                   VVs/ s H  u  pUPM	     snnUS9 H  nUS   S:X  a  U" US   5        M  US   S:X  a  [        R                  " SUS    S35        MA  US   S:X  a  [        R                  " S5        Mb  US   S:X  a5  [        R                  " SUS    3[        R                  R
                  S9  M  [)        U5        M     g s  snnf ) Nz"Waiting for up-to-date Space infosT)r   errrm   zExpected SHA z after hot-reload but got z!Unable to read SpaceRuntime from z infoszSpace z2 current running version has not been hot-reloadedcreatedzDFailed creating hot-reloaded commit. hot_reloading.replica_statuses=z)Unexpected None host on hotReloaded Spacez.Unexpected None subdomain on hotReloaded SpaceregionrF   c                 r   > T S3nU S   U S   :X  a  USU S   S-
   3-  nU$ USU S   S-
   SU S    3-  nU$ )Nr1   	startLineendLinezline r   zlines - )r	  resr   s     rT   render_region1_spaces_hot_reload_summary.<locals>.render_region  ss    B+&"33U6+.2344C 
 VF;/!34AfY6G5HIIC
rg   eventc                 z  > U S   S   S:X  a1  [         R                  " SSS9  [         R                  " U S   S   SS9  g U S   S   S	:X  a@  [         R                  " S
T" U S   S   5       3SS9  [         R                  " U S   S   SS9  g U S   S   S:X  a(  [         R                  " SU S   S    SU S   S    3SS9  g U S   S   S:X  a(  [         R                  " SU S   S    SU S   S    3SS9  g U S   S   S:X  a(  [         R                  " SU S   S    SU S   S    3SS9  g U S   S   S:X  a@  [         R                  " ST" U S   S   5       3SS9  [         R                  " U S   S   SS9  g U S   S   S:X  a9  U S   S   (       a  [         R                  " SSS9  g [         R                  " SSS9  g U S   S   S:X  aA  U S   S   (       a  [         R                  " ST S3SS9  g [         R                  " ST S 3SS9  g [         R                  " S!U < 35        [        (       a  [        U S   S   5        g g )"Nrb   kinderroru"   ✘ Unexpected hot-reloading errorT)bold	traceback)italic	exceptionu   ✘ Exception at r	  addu   ✔︎ Created 
objectNamer   
objectTypedeleteu   ∅ Deleted r   u   ✔︎ Updated runu   ▶ Run 	codeLinesuiupdatedu   ⟳ UI updatedu   ∅ UI untouchedfiler  u   ✔︎ z createdz updatedu    ❓ Unknown update event: event=)rK   r   r   r
   )r  r   r  s    rT   display_event1_spaces_hot_reload_summary.<locals>.display_event  sP   = G+KK<4HKKfk24@6]6"k1KK+M%-:Q,R+ST[_`KKfk24@6]6"e+KK/%-*E)FafVbHcGdelpq6]6"h.KK,uV}\'B&C1U6]S_E`Dabimn6]6"h.KK/%-*E)FafVbHcGdelpq6]6"e+KK(=vx1H#I"JKRVWKKfk24@6]6"d*V}Y',48.T:6]6"f,V}Y'ghZx8tDghZx8tDKK;UH=>}U6]623 rg   )r   hostr   replica_hashesrE   r  replicaHashz---- Replica hashz ----	fullMatchu   ✔︎ Same as first replicawarningu   ⚠ messager   )rR   r   rK   r   r   r   r   r   r   rw   hot_reloadingr   echoreplica_statusesr%  r   r   r   r   r   r
   )rP   rW   r   r   r   r   rE   rR   rw   r,  
space_hostspace_subdomainr#  r(  _replica_stream_eventr  s       ``          @rT   r   r     sX    11:
6
6+
E+";8U\\=V=V\`a

1	 11:
6
6+
E
 ~~#zl2LZ^^L\]^^%%%.:8*FKLL ...7z)[\]]y(

Z=;Y;Y:[\] oo%
.BCC%///8GHHl s 48 4T 4 4> !<!,9,J,JK,J,JK!  '72.w78!&)]:KK-(<V(D'EUKL!&)[8JJ56!&)Y6KK$3I>?@U\\E^E^_-.!! Ls   !I&))codezcode --wait)nvimr4  )nanor5  )vimr6  )vir7  c                      S H3  n [         R                  " U S5      R                  5       =n(       d  M1  Us  $    [         H   u  p#[        R
                  " U5      c  M  Us  $    g )N)	HF_EDITORVISUALEDITORr   )r   getenvr   PREFERRED_EDITORSr   which)envcommandbinary_patheditor_commands       rT   _get_editor_commandrC    sY    0iiR(..0070N 1 (9#<<$0!! (9 rg   )r   r   c                 "   [         R                  R                  5       (       a#  [         R                  R                  5       (       d  g[	        5       =nc  g/ [
        R                  " U5      QU Pn[        R                  " USS9nUR                  $ )Nr   r   T)start_new_session)
sysstdinisattystdoutrC  shlexsplit
subprocessr  
returncode)r   rB  r@  r  s       rT   r   r     sm    II3::#4#4#6#6-//88N+8Z8G
..D
9C>>rg   z&hf spaces volumes ls username/my-spacec                 N   [        US9nUR                  U 5      nUR                  c  [        SU  S35      eUR                  R                  =(       d    / nU Vs/ s H  n[        U5      PM     nn[        R                  " U5        [        R                  " SU  S35        gs  snf )z List volumes mounted in a Space.rJ   Nz!Runtime not available for Space 'rY   Use `hf spaces volumes set I -v hf://<repo_type>/<repo_id>:/<mount_path>` to set volumes for a Space.)	r(   rR   rw   r   r5   r'   r.   rO   re   )rW   rE   rP   rV   r5   vr}   s          rT   
volumes_lsrR  "  s     5
!C>>(#D||:8*BGHHll""(bG,34Gq"GE4IIeHH
%hZ/xy 5s   B"setzPhf spaces volumes set username/my-space -v hf://models/username/my-model:/modelszhf spaces volumes set username/my-space -v hf://buckets/username/my-bucket:/data -v hf://datasets/username/my-dataset:/datasets:rovolumec           	         [        U5      nU(       d  [        S5      e[        US9nUR                  XS9  [        R
                  " SX Vs/ s H  oUR                  5       PM     snS9  [        R                  " SU  S35        gs  snf )	z"Set (replace) volumes for a Space.z7At least one volume must be specified with -v/--volume.rJ   )r5   zVolumes set)rW   r5   zUse `hf spaces volumes ls z` to list volumes for a Space.N)r+   r   r(   set_space_volumesr.   r   to_hf_handlere   )rW   rT  rE   r5   rP   rQ  s         rT   volumes_setrX  9  s|     F#GPQQ
5
!C(4JJ}xT[9\T[q..:JT[9\]HH)(3QRS :]s   Br  z*hf spaces volumes delete username/my-spacez0hf spaces volumes delete username/my-space --yesyesz-yz--yesz#Answer Yes to prompt automatically.c                     [         R                  " SU  S3US9  [        US9nUR                  U 5        [         R                  " SU S9  [         R
                  " SU  S35        g	)
z Remove all volumes from a Space.z0You are about to remove all volumes from Space ''. Proceed?rY  rJ   zVolumes deleted)rW   rO  rP  N)r.   confirmr(   delete_space_volumesr   re   )rW   rY  rE   rP   s       rT   volumes_deleter_  O  s]    ( KKB8*KX^ab
5
!CX&JJ 84HH
%hZ/xyrg   z&hf spaces secrets ls username/my-spacec                     [        US9nUR                  U 5      nUR                  5        Vs/ s H  n[        U5      PM     nn[        R
                  " U5        [        R                  " SU  S35        gs  snf )zHList secrets for a Space. Secret values are write-only and not returned.rJ   Use `hf spaces secrets add z) -s KEY=VALUE` to add secrets to a Space.N)r(   get_space_secretsvaluesr'   r.   rO   re   )rW   rE   rP   r7   sr}   s         rT   
secrets_lsre  l  si     5
!C##H-G,3NN,<=,<q",<E=IIeHH*8*4]^_ >   A5r  )z3hf spaces secrets add username/my-space -s HF_TOKENz\hf spaces secrets add username/my-space -s OPENAI_API_KEY=sk-... -s ANTHROPIC_API_KEY=sk-...zChf spaces secrets add username/my-space --secrets-file .env.secretssecrets_filec                 &   [        X5      nU(       d  [        S5      e[        US9nUR                  5        H  u  pgUR	                  XU=(       d    SS9  M      [
        R                  " SU [        U5      S9  [
        R                  " SU  S35        g	)
z"Add or update secrets for a Space.zJAt least one secret must be specified with -s/--secrets or --secrets-file.rJ   r   keyrM   zSecrets addedrW   keyszUse `hf spaces secrets delete z( <key>` to remove a secret from a Space.N)	r*   r   r(   r}   add_space_secretr.   r   listre   )rW   r7   rg  rE   secrets_maprP   rj  rM   s           rT   secrets_addrp  |  s      6Kcdd
5
!C!'')
XekrB *JJ[8IJHH-hZ7_`arg   z3hf spaces secrets delete username/my-space HF_TOKENz9hf spaces secrets delete username/my-space HF_TOKEN --yesrj  zName of the secret to remove.c                     [         R                  " SU SU  S3US9  [        US9nUR                  XS9  [         R                  " SXS9  [         R
                  " S	U  S
U S35        g)zRemove a secret from a Space.z You are about to remove secret '' from Space 'z*'. The value cannot be recovered. Proceed?r\  rJ   rj  zSecret deletedrW   rj  ra  z -s z(=<value>` to re-add a secret to a Space.N)r.   r]  r(   delete_space_secretr   re   rW   rj  rY  rE   rP   s        rT   secrets_deleterw    so    * KK
*3%~hZGqr 5
!CH.JJ(<HH*8*D=efgrg   z(hf spaces variables ls username/my-spacec                     [        US9nUR                  U 5      nUR                  5        Vs/ s H  n[        U5      PM     nn[        R
                  " U5        [        R                  " SU  S35        gs  snf )z'List environment variables for a Space.rJ   zUse `hf spaces variables add z+ -e KEY=VALUE` to add variables to a Space.N)r(   get_space_variablesrc  r'   r.   rO   re   )rW   rE   rP   r8   rQ  r}   s         rT   variables_lsrz    sl     5
!C''1I,5,<,<,>?,>q",>E?IIeHH,XJ6abc @rf  )z4hf spaces variables add username/my-space -e DEBUG=1zLhf spaces variables add username/my-space -e MODEL_ID=gpt2 -e MAX_TOKENS=512z9hf spaces variables add username/my-space --env-file .envr?  env_filec                 &   [        X5      nU(       d  [        S5      e[        US9nUR                  5        H  u  pgUR	                  XU=(       d    SS9  M      [
        R                  " SU [        U5      S9  [
        R                  " SU  S35        g	)
z0Add or update environment variables for a Space.zDAt least one variable must be specified with -e/--env or --env-file.rJ   r   ri  zVariables addedrk  Use `hf spaces variables ls z ` to list variables for a Space.N)	r*   r   r(   r}   add_space_variabler.   r   rn  re   )rW   r?  r{  rE   env_maprP   rj  rM   s           rT   variables_addr    s|     C*G]^^
5
!Cmmo
xD &JJ 8$w-HHH+H:5UVWrg   z2hf spaces variables delete username/my-space DEBUGz8hf spaces variables delete username/my-space DEBUG --yeszName of the variable to remove.c                     [         R                  " SU SU  S3US9  [        US9nUR                  XS9  [         R                  " SXS9  [         R
                  " S	U  S
35        g)z,Remove an environment variable from a Space.z"You are about to remove variable 'rr  r[  r\  rJ   rs  zVariable deletedrt  r}  z*` to list remaining variables for a Space.N)r.   r]  r(   delete_space_variabler   re   rv  s        rT   variables_deleter    sh    * KK
,SEzU 5
!Ch0JJ!H>HH+H:5_`arg   )NNN)FFN)NNFF
   N)FN)N)FFNN)NNFFN)NN)t__doc__enum	functoolsru   r   rJ  r   rL  rF  r   r   collectionsr   pathlibr   typingr   r   r   r   rK   	packagingr	   typing_extensionsr
   "huggingface_hub._hot_reload.clientr   !huggingface_hub._hot_reload.typesr   r   huggingface_hub._space_apir   r   huggingface_hub.errorsr   r   r   r   huggingface_hub.file_downloadr   huggingface_hub.hf_apir   r   r   huggingface_hub.repocardr   huggingface_hub.utilsr   
_cli_utilsr   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   _file_listingr-   _outputr.   r   sorted_EXPAND_PROPERTIES_SORT_OPTIONSEnumr   r/   Optionr   	ExpandOpt
spaces_clivolumes_clisecrets_clivariables_cli	add_typerr@  ArgumentboolrU   r\   rf   rn  r   r   r   r   r   intr   r   r  r   r=  cacherC  r   rR  rX  r_  re  rp  rw  rz  r  r  )rd  s   0rT   <module>r     s8      	    
     > >   * J W @ u u 9 L L . 7    ( /  #  H%:;< %		/-+H-QqD-+HsS $J	LL Z  [_  [d  [d  ew  [x  Zy  yz  {./AB	  BC
!IJ!IJ#YZ 
  [y  1 
  [y  1 
  ]  5   	 	 	- 	 	 	 7Nd
pq	sN
 N N N /*	,N N N '4st	vN$ X$YZ	\%N, ]D/ab	d-N4 5N6 7N8 
9N	Nb 
*H   !	U^^1\]]^  	
 
" 
   mrej	cU^^1\]]^cell<>ghhic D%,,x6`aa
bc 	c
 
cc&    jnhmY^"IS%..o>>?"I"I 
49t#U\\7e%ff	g"I #4;c)d#de	"I
 43T!UUV"I "I "I 
"I"IJ 2   BG<fU^^1\]]^<f
D%,,,<==
><f <f<f~ +   U^^1\]]^ 
 ->   	U^^1\]]^P	
	  
4   g8 gt gg4 ?C   	 	! VU^^1\]]^ Vd
 I	
	 V  F	
	 V  ! V" 
# V VF 
  " 	 	 	32nU^^1\]]^2nw	
	2n  P	
	2n" d
D	
	#2n2 32n4 
52n2nj   ( 	 	_dmr/}
<	
	}
 d
 R	
	}
 tO	
	}
* 43Z![[\+}
, D%,,4h"iij-}
. /}
0 
1}
}
@T/	T/T/ tT/ 	T/
 T/ T/ :T/ 
T/n  S4Z  S S73H+I%I  0   U^^1\]]^ 
" 	Z 	M   TU^^1\]]^TT T 
	TT 4:    	U^^1\]]^	6	
	
  
, 67   	`U^^1\]]^	`	` 
	`		` 	   #'	bU^^1\]]^bb !b 	b
 
bb" =C  " 	hU^^1\]]^h	3,KLL	Mh 
6	
	
h h 
hh0 89   	dU^^1\]]^	d	d 
	d		d 	   	XU^^1\]]^X	X X 	X
 
XX" <B  " 	bU^^1\]]^b	3,MNN	Ob 
6	
	
b b 
bbc ,Is   .a
