wL i DddlZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z mZmZmZmZmZddlmZddlmZddlmZmZdd lmZmZdd lmZdd lm Z m!Z!m"Z"m#Z#m$Z$m%Z%dd l&m'Z'e"jPe)Z*Gd dZ+dee,e fde-fdZ.dee,e fde,de-fdZ/dee,e fde-fdZ0dee,e fde-fdZ1dee,e fde-fdZ2d"de,dee,e dfdee,fdZ3dee,e fde-fdZ4d#dee,e fdee,de5fdZ6GddeZ7edZ8Gd d!Z9y)$N)contextmanager)Path)CallableDictIteratorListOptionalTuple TypedDictUnion)urlparse) constants) metadata_load metadata_save)HfApirepo_type_and_id_from_hf_id)LFS_MULTIPART_UPLOAD_COMMAND)SoftTemporaryDirectory get_tokenloggingrun_subprocesstqdmvalidate_hf_hub_args)_deprecate_methodc eZdZdZ ddedededejdeef dZ e d e fd Z e d e fd Ze d e fd Ze d efd Ze d efdZdZy)CommandInProgressz= Utility to follow commands launched asynchronously. Ntitleis_done_method status_methodprocess post_methodcf||_||_||_||_d|_d|_||_y)N)r_is_done_status_process_stderr_stdout _post_method)selfrrr r!r"s `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/huggingface_hub/repository.py__init__zCommandInProgress.__init__$s6 & $    'returncp|j}|r#|j|jd|_|S)z. Whether the process is done. N)r%r*)r+results r,is_donezCommandInProgress.is_done4s6  d''3     $D  r.c"|jS)z The exit code/status of the current action. Will return `0` if the command has completed successfully, and a number between 1 and 255 if the process errored-out. Will return -1 if the command is still ongoing. )r&r+s r,statuszCommandInProgress.statusAs||~r.c |jdkDS)z2 Whether the process errored-out. r)r5r4s r,failedzCommandInProgress.failedLs {{Qr.c|jj7|xj|jjjz c_|jS)zC The current output message on the standard error. )r'stderrr(readr4s r,r9zCommandInProgress.stderrS? ==   + LLDMM00557 7L||r.c|jj7|xj|jjjz c_|jS)zD The current output message on the standard output. )r'stdoutr)r:r4s r,r=zCommandInProgress.stdout\r;r.c |j}|dk(rd}d|jd|d|jsdndd|jjd S) Nrunning[z command, status code: z, z in progress.z finished.z PID: ])r5rr2r'pid)r+r5s r,__repr__zCommandInProgress.__repr__es` R<F |26(;&*ll DE !!"! % r.N)__name__ __module__ __qualname____doc__strr subprocessPopenr r-propertyboolr2intr5r7r9r=rDr.r,rrs+/ ((!( ( !! ( h' (       r.rfolderr/c(tjjtjj|d}t j dj |tjtj}|xr|jdk(S)a Check if the folder is the root or part of a git repository Args: folder (`str`): The folder in which to run the command. Returns: `bool`: `True` if the repository is part of a repository, `False` otherwise. z.gitz git branch)cwdr=r9r) ospathexistsjoinrKrunsplitPIPE returncode)rQ folder_exists git_branchs r, is_git_repor^rscGGNN277<<#?@M 2 2 4&akapapqJ  7Z22a77r. remote_urlct|sytd|j}tjdd|}|j Dcgc]}tjdd|}}||vScc}w)am Check if the folder is a local clone of the remote_url Args: folder (`str` or `Path`): The folder in which to run the command. remote_url (`str`): The url of a git repository. Returns: `bool`: `True` if the repository is a local clone of the remote repository specified, `False` otherwise. Fz git remote -v https://.*@https://)r^rr=resubrY)rQr_remotesremotes r,is_local_clonergsl v _f5<  T)openr: bytearraysetrangerN translateUnicodeDecodeError)rhfcontent text_charss r,is_binary_filers  (D ! -Qff^,G - 83uT5?Q;RVZU[;[[\ G%%dJ788  - - s( A6A*A A6*A3/A66 BBpatterncF tdj|gz|}t|jj r+|jj jd}|Sg} |S#t j $r}t|jd}~wwxYw)aQ Returns a list of filenames that are to be staged. Args: pattern (`str` or `Path`): The pattern of filenames to check. Put `.` to get all files. folder (`str` or `Path`): The folder in which to run the command. Returns: `List[str]`: List of files that are to be staged. z#git ls-files --exclude-standard -mormN) rrYrtr=rqrKrrEnvironmentErrorr9)rrQrxfilesrzs r,files_to_be_stagedrs+ @FFHG9TV\ ] qxx~~ HHNN$**40E L E L  ( (+szz**+sA*A3.A33B BB c td|y#tj$r#}d|jvr t dYd}~yd}~wwxYw)a Check if the current checked-out branch is tracked upstream. Args: folder (`str` or `Path`): The folder in which to run the command. Returns: `bool`: `True` if the current checked-out branch is tracked upstream, `False` otherwise. z4git rev-parse --symbolic-full-name --abbrev-ref @{u}THEADzNo branch checked outNF)rrKrrr9rs)rQrzs r,is_tracked_upstreamr sFMvV  ( ( SZZ 12 2 s AAAupstreamc td|xsd|}t|jjddz S#tj $r}t |jd}~wwxYw)a Check the number of commits that would be pushed upstream Args: folder (`str` or `Path`): The folder in which to run the command. upstream (`str`, *optional*): The name of the upstream repository with which the comparison should be made. Returns: `int`: Number of commits that would be pushed upstream were a `git push` to proceed. zgit cherry -v r$rmrN)rrtr=rYrKrrrr9)rQrr1rzs r,commits_to_pushr sc+.R0@ A6J6==&&t,-11  ( (+szz**+s9<A)A$$A)c"eZdZUeed<eed<y)PbarTbar past_bytesN)rFrGrHr__annotations__rOrPr.r,rr6s IOr.rc#6Ktjtjk\r dydt j fd}tjjdd}t5}tjj|dtjd<tjdtjdt j }t j||fd }|j d|j!|j|tjd< dddy#t$rYywxYw#|j!|j|tjd<wxYw#1swYyxYww) zv This is a context manager that will log the Git LFS progress of cleaning, smudging, pulling and pushing. Nstopping_eventc 2ifddttffd }tjj tj ds^j rytjdtjj tj ds^|tj dD]} |j\}}}}|jd|}|jd \} } t| } t| } j||f} | $t|| | d d d d t| d||f<| dj| | dz | | d<y#t$r}td||d}~wwxYw)zl To be launched as a separate thread with an event meaning it should stop the tail. cjD]O}|dj|dj|dz |dj|dj Qy)Nrr)rwupdatetotalrefreshclose)pbarpbarss r, close_pbarsz?_lfs_log_progress..output_progress..close_pbarsRs^  $U ""4;#4#4tL7I#IJU ##%U !!# $r.r/c3JKt|d5}d} jrna|j}|9t|j dk(s||z }|j dr|d}nt jdy dddy#1swYyxYww)z Creates a generator to be iterated through, which will return each line one by one. Will stop tailing the file if the stopping_event is set. rr$Nrrmr)ris_setreadlinertrqendswithtimesleep)rhfile current_lineline_bitrrs r, tail_filez=_lfs_log_progress..output_progress..tail_fileXs h$ &! %,,.# #}}H+C8H4IQ4N$0 '006"..+-L 1   & & &s B#A=B B#B B#GIT_LFS_PROGRESSNz!Cannot unpack LFS progress line: z file /BTizhuggingface_hub.lfs_upload)descinitialrunit unit_scale unit_divisorrp)rrrr)rrJrTrUrVenvironrrrrY ValueError capitalizerOgetrr)rrlinestate file_progress byte_progressrherror description current_bytes total_bytescurrent_bytes_inttotal_bytes_intrrrs` @@r,output_progressz*_lfs_log_progress..output_progressJs /1 $  &8C= &0''..,>!?@$$&  JJqM ''..,>!?@bjj);<= 7D Y@D =}mX#--/0xjAK)6)<)Z.d?e-ddfd@Z/edAZ0edBZ1dCZ2y)O RepositoryaE Helper class to wrap the git and git-lfs commands. The aim is to facilitate interacting with huggingface.co hosted model or dataset repos, though not a lot here (if any) is actually specific to huggingface.co. > [!WARNING] > [`Repository`] is deprecated in favor of the http-based alternatives implemented in > [`HfApi`]. Given its large adoption in legacy code, the complete removal of > [`Repository`] will only happen in release `v1.0`. For more details, please read > https://huggingface.co/docs/huggingface_hub/concepts/git_vs_http. command_queuez1.0zPlease prefer the http-based alternatives instead. Given its large adoption in legacy code, the complete removal is only planned on next major release. For more details, please read https://huggingface.co/docs/huggingface_hub/concepts/git_vs_http.)versionmessageN local_dir clone_from repo_typetokengit_user git_emailrevisionskip_lfs_filesclientc t|tr t|}tj|dtj j tj||_||_ g|_ ||_ | | n t|_ |jt|tr||_n|durd|_nt!|_||j#|n6t%|jrt&j)dn t+d|jO||K|jj-|j} || j/d}|| j/d }|||j1|||j3|j5||j7|d t9j:|j<y) a Instantiate a local clone of a git repo. If `clone_from` is set, the repo will be cloned from an existing remote repository. If the remote repo does not exist, a `EnvironmentError` exception will be thrown. Please create the remote repo first using [`create_repo`]. `Repository` uses the local git credentials by default. If explicitly set, the `token` or the `git_user`/`git_email` pair will be used instead. Args: local_dir (`str` or `Path`): path (e.g. `'my_trained_model/'`) to the local directory, where the `Repository` will be initialized. clone_from (`str`, *optional*): Either a repository url or `repo_id`. Example: - `"https://huggingface.co/philschmid/playground-tests"` - `"philschmid/playground-tests"` repo_type (`str`, *optional*): To set when cloning a repo from a repo_id. Default is model. token (`bool` or `str`, *optional*): A valid authentication token (see https://huggingface.co/settings/token). If `None` or `True` and machine is logged in (through `hf auth login` or [`~huggingface_hub.login`]), token will be retrieved from the cache. If `False`, token is not sent in the request header. git_user (`str`, *optional*): will override the `git config user.name` for committing and pushing files to the hub. git_email (`str`, *optional*): will override the `git config user.email` for committing and pushing files to the hub. revision (`str`, *optional*): Revision to checkout after initializing the repository. If the revision doesn't exist, a branch will be created with that revision name from the default branch's current HEAD. skip_lfs_files (`bool`, *optional*, defaults to `False`): whether to skip git-LFS files or not. client (`HfApi`, *optional*): Instance of [`HfApi`] to use when calling the HF Hub API. A new instance will be created if this is left to `None`. Raises: [`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError) If the remote repository set in `clone_from` does not exist. T)exist_okNF)repo_urlz [Repository] is a valid git repozNIf not specifying `clone_from`, you need to pass Repository a valid git clone.emailfullnamecreate_branch_ok) isinstancerrJrTmakedirsrUrWgetcwdr _repo_typerrrrcheck_git_versionshuggingface_tokenrrr^rrrwhoamirgit_config_username_and_emaillfs_enable_largefilesgit_credential_helper_store git_checkoutatexitregisterwait_for_commands) r+rrrrrrrrrusers r,r-zRepository.__init__sF i &II I-biik9=#, & 2f  ! eS !49D " e^%)D "&/[D "  ! OOZO 04>>* ?@ !qrr  ! ! -93DHX;;%%d&<&<=D  HHW- 88J/  9#8  . .x C ""$ ((*     h  > ../r.r/c td|jjj}|S#tj $r}t |jd}~wwxYw)zz Returns the current checked out branch. Returns: `str`: Current checked out branch. zgit rev-parse --abbrev-ref HEADNrrr=rqrKrrrr9)r+r1rzs r,current_branchzRepository.current_branch0sU /#$Et~~V]]cceF ,, /"3::. . /s.2AAAcV td|jjj} td|jjj}t j|dz|zy#t$r t dwxYw#t$r t dwxYw)z Checks that `git` and `git-lfs` can be run. Raises: [`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError) If `git` or `git-lfs` are not installed. z git --versionz9Looks like you do not have git installed, please install.zgit-lfs --versionzLooks like you do not have git-lfs installed, please install. You can install from https://git-lfs.github.com/. Then run `git lfs install` (you only have to do this once).rmN)rrr=rqFileNotFoundErrorrrinfo)r+ git_version lfs_versions r,rzRepository.check_git_versions?s `($..IPPVVXK () [!TIP] > Raises the following error: > > - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) > if an organization token (starts with "api_org") is passed. Use must use > your own personal access token (see https://hf.co/settings/tokens). > > - [`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError) > if you are trying to clone the repository in a non-empty folder, or if the > `git` operations raise errors. FNapi_orgzgYou must use your personal access token, not an Organization token (see https://hf.co/settings/tokens).httprr)hub_urlz://z://user:@z(https?)://.*@z\1://zgit lfs installrzCloning z into local empty directory.GIT_LFS_SKIP_SMUDGE1z git clonez git lfs clone z .)envzPTried to clone a repository in a non-empty folder that isn't a git repository ('z7'). If you really want to do this, do it manually: cd z && git init && git remote add origin && git pull origin main or clone repo to a new folder and move your existing files there afterwards.z is already a clone of z?. Make sure you pull the latest changes with `repo.git_pull()`.zgit remote get-url originrzTried to clone zn in an unrelated git repository. If you believe this is an error, please add a remote with the following URL: .rarbz' Local path has its origin defined as: )%rrJr startswithrrendpointrtrYrrrREPO_TYPES_URL_PREFIXESr schemereplacercrdrrrTlistdirrwarningrrcopyrrr^rrgr[r=rKrrr9)r+rrrr namespace repo_namerepo_idr#clean_repo_urlroutput error_msgclean_local_remote_urlrzs r,rzRepository.clone_fromVs@F%% E>++   !1!1)!<8  ++&& h 6#9c(..QTBU>VZ[>[.I(\c.d +Iy)4=4I 1YK0yG$"+}H)"C"CCI==dooNN !(+22#++vhcNvhhugUV>2*//3~~.>?::>..9IJ''"$..(;NN>>**A.AQR.. ,,G_deF*.)9:==K># #,, /"3::. . /s/2AAAc td|j}|jj}t j dd|S#t j$r}t|jd}~wwxYw)zp Get URL to origin remote. Returns: `str`: The URL of the `origin` remote. z"git config --get remote.origin.urlrarbN) rrr=rqrcrdrKrrrr9)r+rxurlrzs r,git_remote_urlzRepository.git_remote_urls` /CT^^TA((.."C66.*c: :,, /"3::. . /sAA A6A11A6c||j}|j}|jdr|dd}|d|S)z Get URL to last commit on HEAD. We assume it's been pushed, and the url scheme is the same one as for GitHub or HuggingFace. Returns: `str`: The URL to the current checked-out commit. rNr?z/commit/)r2r5r)r+shar4s r,git_head_commit_urlzRepository.git_head_commit_url sH  "!!# << cr(Chse$$r.c td|jjj}t|dk(rgS|jdDcgc]}|j}}|Dcgc]}d|jdvs|}}|Dcgc]#}|jdj%}}|S#tj $r}t |jd}~wwxYwcc}wcc}wcc}w)z Returns a list of the files that are deleted in the working directory or index. Returns: `List[str]`: A list of files that have been deleted in the working directory or index. z git status -sNrrmDr? rrr=rqrKrrrr9rtrY)r+ git_statusrzr5modified_files_statusesdeleted_files_statuses deleted_filess r,list_deleted_fileszRepository.list_deleted_filess /'HOOUUWJ z?a IAK@P@PQU@V"Wf6<<>"W"W8O!kVRUY_YeYeYghiYjRj&!k!kCYY+113Y Y-,, /"3::. . /#X"lZs/.CC10C6 C6(C;C.C))C.patternsrhct|tr|g} |D]"}td|rdndd||j$y#tj $r}t |jd}~wwxYw)a9 Tell git-lfs to track files according to a pattern. Setting the `filename` argument to `True` will treat the arguments as literal filenames, not as patterns. Any special glob characters in the filename will be escaped when writing to the `.gitattributes` file. Args: patterns (`Union[str, List[str]]`): The pattern, or list of patterns, to track with git-lfs. filename (`bool`, *optional*, defaults to `False`): Whether to use the patterns as literal filenames. zgit lfs track z --filenamer$rN)rrJrrrKrrrr9)r+rArhrrzs r, lfs_trackzRepository.lfs_track<st h $ zH /# $X\2$FayQNN  ,, /"3::. . /s'=A*A%%A*ct|tr|g} |D]*}tdj|gz|j,y#t j $r}t|jd}~wwxYw)z Tell git-lfs to untrack those files. Args: patterns (`Union[str, List[str]]`): The pattern, or list of patterns, to untrack with git-lfs. zgit lfs untrackN) rrJrrYrrKrrrr9)r+rArrzs r, lfs_untrackzRepository.lfs_untrackUso h $ zH /# V0668G9DdnnU V,, /"3::. . /s/AA2A--A2c d}t|d|jt|dt|jy#tj$r}t |j d}~wwxYw)zI HF-specific. This enables upload support of files >5GB. z'git config lfs.customtransfer.multipartz.path hfz.args N)rrrrKrrrr9)r+ lfs_configrzs r,rz Repository.lfs_enable_largefilesesg /BJ j\2DNN C ,f%A$BC ,, /"3::. . /s:=A*A%%A*rcg}|j}t||jD]}||vrtjj tj |j|}t|rQt|r]tjj|dz }|dk\rtjdt|}|s|j||j||j||S)aH Automatically track binary files with git-lfs. Args: pattern (`str`, *optional*, defaults to "."): The pattern with which to track files that are binary. Returns: `List[str]`: List of filenames that are now tracked due to being binary files rQrzParsing a large file to check if binary or not. Tracking large files using `repository.auto_track_large_files` is recommended so as to not load the full file in memory.)r@rrrTrUrWrr~rgetsizerr&rrCappendrE)r+rfiles_to_be_tracked_with_lfsr?rh path_to_file size_in_mb is_binarys r,auto_track_binary_filesz"Repository.auto_track_binary_filesss(*$//1 *74>>J BH=(77<< T^^XNL' 5 9UWW__\:kJ #NNR +<8 NN8,077A) B. '++r.cg}|j}t||jD]}||vrtjj tj |j|}tjj|dz }|dk\smt|ryt|r|j||j||j||S)ap Automatically track large files (files that weigh more than 10MBs) with git-lfs. Args: pattern (`str`, *optional*, defaults to "."): The pattern with which to track files that are above 10MBs. Returns: `List[str]`: List of filenames that are now tracked due to their size. rIrJr) r@rrrTrUrWrrKr~rrCrLrE)r+rrMr?rhrNrOs r,auto_track_large_filesz!Repository.auto_track_large_filess(*$//1 *74>>J >H=(77<< T^^XNL6+FJR(;L(IR`amRnx(,33H= > '++r.c t5td|rdnd|j}tj |j dddy#1swYyxYw#t j$r}t|jd}~wwxYw)a git lfs prune Args: recent (`bool`, *optional*, defaults to `False`): Whether to prune files even if they were referenced by recent commits. See the following [link](https://github.com/git-lfs/git-lfs/blob/f3d43f0428a84fc4f1e5405b76b5a73ec2437e65/docs/man/git-lfs-prune.1.ronn#recent-files) for more information. zgit lfs prune z--recentr$N rrrrrr=rKrrrr9)r+recentr1rzs r, lfs_prunezRepository.lfs_prunesx /"$ +'.vSU8V(WY]YgYgh FMM* + + +,, /"3::. . /s4 A=A AAAAB 1BB rebasernc(|sdnd}|r|dz } t5t||j}tj |j dddy#1swYyxYw#t j$r}t|jd}~wwxYw)a7 git pull Args: rebase (`bool`, *optional*, defaults to `False`): Whether to rebase the current branch on top of the upstream branch after fetching. lfs (`bool`, *optional*, defaults to `False`): Whether to fetch the LFS files too. This option only changes the behavior when a repository was cloned without fetching the LFS files; calling `repo.git_pull(lfs=True)` will then fetch the LFS file from the remote repository. zgit pullz git lfs pullz --rebaseNrU)r+rXrncommandr1rzs r,git_pullzRepository.git_pulls%(*^  { "G /"$ +'@ FMM* + + +,, /"3::. . /s4 A$6AA$A!A$!A$$B7B  Bauto_lfs_trackc|rL|j|}|j|j||rtj d|d t dj |gz|j}tjd|jdy#tj$r}t|jd}~wwxYw)a7 git add Setting the `auto_lfs_track` parameter to `True` will automatically track files that are larger than 10MB with `git-lfs`. Args: pattern (`str`, *optional*, defaults to "."): The pattern with which to add files to staging. auto_lfs_track (`bool`, *optional*, defaults to `False`): Whether to automatically track large and binary files with git-lfs. Any file over 10MB in size, or in binary format, will be automatically tracked. z!Adding files tracked by Git LFS: z5. This may take a bit of time if the files are large.z git add -vzAdding to index: rmN)rSextendrQrr&rrYrrr=rKrrrr9)r+rr\ tracked_filesr1rzs r,git_addzRepository.git_adds  77@M  !=!=g!F G7 G;;  /#L$6$6$8G9$DdnnUF KK,V]]O2> ?,, /"3::. . /sA BC /CC commit_messagecV tdj|gz|j}tj d|j dy#t j$rG}t|jdkDrt|jt|j d}~wwxYw)z git commit Args: commit_message (`str`, *optional*, defaults to "commit files to HF hub"): The message attributed to the commit. zgit commit -v -mz Committed: rmrN) rrYrrrr=rKrrrtr9r)r+rar1rzs r, git_commitzRepository.git_commit s 3#$6$<$<$>.AQ$QSWSaSabF KK,v}}oR8 9,, 33::"&szz22&szz22  3sA AB(!AB##B(rblockingauto_lfs_prunec d}|r|d|z }t|j|}|dkDr0tjd|d|rtjd t 5t j |jt jt jd|j |rx j\}} j} jt|rtj||r#t j| j|| d d d |sS fd } t#d fd | |r |j$nd } |j&j)| |j+| fS|r|j%|j+S#1swYxYw#t j$r} t| j d } ~ wwxYw)a% git push If used without setting `blocking`, will return url to commit on remote repo. If used with `blocking=True`, will return a tuple containing the url to commit and the command object to follow for information about the process. Args: upstream (`str`, *optional*): Upstream to which this should push. If not specified, will push to the lastly defined upstream or to the default one (`origin main`). blocking (`bool`, *optional*, defaults to `True`): Whether the function should return only when the push has finished. Setting this to `False` will return an `CommandInProgress` object which has an `is_done` property. This property will be set to `True` when the push is finished. auto_lfs_prune (`bool`, *optional*, defaults to `False`): Whether to automatically prune files once they have been pushed to the remote. zgit pushz --set-upstream rzSeveral commits (z) will be pushed upstream.z$The progress bars may be unreliable.zutf-8)r9r=encodingrS)r,r9Nc.j}|y|S)Nr?poll)r5r!s r,r z*Repository.git_push..status_method^s >!Mr.pushc(jduSrEri)r!sr,z%Repository.git_push..gsw||~T'Ar.)rr r!r")rrrr&rrKrLrYrZ communicaterjkillrtrrrrr9rrWrrLr8) r+rrdrerZnumber_of_commitsr=r9 return_coderzr command_in_progressr!s @r,git_pushzRepository.git_pushs8  )(4 4G+DNNHE q NN./@.AA[\ ]EF /"$ u$**MMO%??%??$ %,%8%8%:NFF"),,.KLLN6{v."(;;K^dmstt% u. "#4A+.OF NN\(6$:M:M9NaP Q NN6== ),, 7#&szz227+.>xj,I4>>ZFNN$XJ.`ai`jjlmNN6==1!447*3::6672 7s=AA!!D4D AC! D!D4D  DDDtag_namerfc|r@ td||jjj}t|dk7S td|jjj}|jd}||vS#tj $r}t |jd}~wwxYw#tj $r}t |jd}~wwxYw)aw Check if a tag exists or not. Args: tag_name (`str`): The name of the tag to check. remote (`str`, *optional*): Whether to check if the tag exists on a remote. This parameter should be the identifier of the remote. Returns: `bool`: Whether the tag exists. zgit ls-remote origin refs/tags/Nrzgit tagrmr;)r+rurfr1rzgit_tagss r, tag_existszRepository.tag_existss  3'*I((TVZVdVdellrrtv;!# # 3))T^^DKKQQS ~~d+Hx' '00 3&szz22 300 3&szz22 3s/1B.B7B4B//B47C$ CC$cd}d}|j|sd}|j||sd}|r3 tddd|g|jjj |r8|r6 td|d ||jjj yy#t j $r}t|jd}~wwxYw#t j $r}t|jd}~wwxYw) a Delete a tag, both local and remote, if it exists Args: tag_name (`str`): The tag name to delete. remote (`str`, *optional*): The remote on which to delete the tag. Returns: `bool`: `True` if deleted, `False` if the tag didn't exist. If remote is not passed, will just be updated locally TF)rfgitr}z-dN git push z --delete ) rxrrr=rqrKrrrr9)r+rurfdelete_locallydelete_remotelyrzs r, delete_tagzRepository.delete_tagsx("Nx7#O  3udH=t~~NUU[[] o 36(*XJGX__eeg00 3&szz22 3 00 3&szz22 3s/2B'4C C 0CC  C: C55C:rc|r ddd|d|g}ndd|g} t||jjj|r6 td|d||jjjyy#tj $r}t |jd}~wwxYw#tj $r}t |jd}~wwxYw)a[ Add a tag at the current head and push it If remote is None, will just be updated locally If no message is provided, the tag will be lightweight. if a message is provided, the tag will be annotated. Args: tag_name (`str`): The name of the tag to be added. message (`str`, *optional*): The message that accompanies the tag. The tag will turn into an annotated tag if a message is passed. remote (`str`, *optional*): The remote on which to add the tag. rzr}z-az-mNr{rr)r+rurrftag_argsrzs r,add_tagzRepository.add_tags$ udHdGDHuh/H / 8T^^ 4 ; ; A A C  36(!H:>OVV\\^ ,, /"3::. . / 00 3&szz22 3s/.A94B)9B& B!!B&)C<CCc td|jjj}t|dk(S#tj $r}t |jd}~wwxYw)z Return whether or not the git status is clean or not Returns: `bool`: `True` if the git status is clean, `False` otherwise. zgit status --porcelainNr) rrr=rqrKrrrr9rt)r+r<rzs r, is_repo_cleanzRepository.is_repo_cleans_ /'(@$..QXX^^`J:!##,, /"3::. . /s.>A+A&&A+clean_okc|r&|jrtjdy|jd|j ||j d|j ||S)aF Helper to add, commit, and push files to remote repository on the HuggingFace Hub. Will automatically track large files (>10MB). Args: commit_message (`str`): Message to use for the commit. blocking (`bool`, *optional*, defaults to `True`): Whether the function should return only when the `git push` has finished. clean_ok (`bool`, *optional*, defaults to `True`): If True, this function will return None if the repo is untouched. Default behavior is to fail because the git command fails. auto_lfs_prune (`bool`, *optional*, defaults to `False`): Whether to automatically prune files once they have been pushed to the remote. z*Repo currently clean. Ignoring push_to_hubNTr\origin rrdre)rrrr`rcrsr)r+rardrres r, push_to_hubzRepository.push_to_hub si2 **, KKD E D ) '}}t2234)  r.branchtrack_large_filesc#0Ktd|j}t|rFt|dkDrt|dddddzn t|}tj d|d||j |d t|jr(tjd |jd n#tjd |jdtj}tjtjj||j ||j!| |j#| |j'd|j||tj|y#t$$r} dt| vr| Yd} ~ Ud} ~ wwxYw#t$$r } dt| vr t%d| | d} ~ wwxYw#|j!| |j#|n%#t$$r} dt| vr| Yd} ~ nd} ~ wwxYw |j'd|j||n,#t$$r } dt| vr t%d| | d} ~ wwxYwtj|wxYww)a Context manager utility to handle committing to a repository. This automatically tracks large files (>10Mb) with git-lfs. Set the `track_large_files` argument to `False` if you wish to ignore that behavior. Args: commit_message (`str`): Message to use for the commit. branch (`str`, *optional*): The branch on which the commit will appear. This branch will be checked-out before any operation. track_large_files (`bool`, *optional*, defaults to `True`): Whether to automatically track large files or not. Will do so by default. blocking (`bool`, *optional*, defaults to `True`): Whether the function should return only when the `git push` has finished. auto_lfs_prune (`bool`, defaults to `True`): Whether to automatically prune files once they have been pushed to the remote. Examples: ```python >>> with Repository( ... "text-files", ... clone_from="/text-files", ... token=True, >>> ).commit("My first file :)"): ... with open("file.txt", "w+") as f: ... f.write(json.dumps({"hey": 8})) >>> import torch >>> model = torch.nn.Transformer() >>> with Repository( ... "torch-model", ... clone_from="/torch-model", ... token=True, >>> ).commit("My cool model :)"): ... torch.save(model.state_dict(), "model.pt") ``` rrINr?z, ...]zPThere exists some updated files in the local repository that are not committed: z|. This may lead to errors if checking out a branch. These files and their modifications will be added to the current commit.TrzPulling changes ...)rXz@The current branch has no upstream branch. Will push to 'origin 'rznothing to commitrrzcould not read UsernamezCCouldn't authenticate user for push. Did you set `token` to `True`?)rrrtrJrrr rr&r[rrTrchdirrUrWr`rcrsrs) r+rarrrdrefiles_to_stage files_in_msgcurrent_working_directoryes r,commitzRepository.commit-svn,CG ~ FI.FY\]F]3~bq123B7(BcfgucvL LL+n-##      ft  < t~~ . NN0 1 MMM & NN]^b^q^q]rrst u$&IIK! 7HI 0J LL(9L : /  &t':':&;<%#1 HH. /% &c!f4G5  ,A6!"ghnooG   LL(9L : / &c!f4G5   &t':':&;<%#1  ,A6!"ghnooG   HH. /sD/J2G#6J F!F7<J F4F/*J/F44J7 G GG  J#J7H J H+H&!J&H++J/!IJ I:I55I::JJctjj|jtj }tjj |r t|SyrE)rTrUrWrr REPOCARD_NAMEisfiler)r+filepaths r,repocard_metadata_loadz!Repository.repocard_metadata_loads>77<< 0G0GH 77>>( # * *r.datacttjj|jt j |SrE)rrTrUrWrrr)r+rs r,repocard_metadata_savez!Repository.repocard_metadata_saves)RWW\\$..):Q:QRTXYYr.c`|jDcgc]}|jdkDs|c}Scc}w)z@ Returns the asynchronous commands that failed. r)rr5r+cs r,commands_failedzRepository.commands_faileds(  -->aA>>>s++cZ|jDcgc]}|jr|c}Scc}w)zS Returns the asynchronous commands that are currently in progress. )rr2rs r,commands_in_progresszRepository.commands_in_progresss$  --?aQYY???s((cd}|jD][}tjd|jd|jj dtj|j ]|jrS|dzdk(r#tjd|jd|dz }tjd|jrRy y ) zr Blocking method: blocks all subsequent execution until all commands have been processed. rzThe z command with PID z failed.rzCWaiting for the following commands to finish before shutting down: rrN) rrrrr'rCr9rr&rr)r+indexcommand_faileds r,r zRepository.wait_for_commandss "22 0N LL4 4 455GH_H_HcHcGddlm n LL.. / 0''rzQYZ^ZsZsYttuv QJE JJqM''r.)NNTNNNFNrE)NN)F)r)FF)rF)commit files to HF hub)NTF)rTTF)NTTF)3rFrGrHrIrrrrrr rJrr rNrr-rMrrrrrr2r5r8r@rCrErrQrSrWr[r`rcr rsr rxr~rrrrrrrrrrr rPr.r,rrs )** Q%)#'"&"&#'"&$"&j0d#j0SMj0C= j0 T3Y j0 3- j0C=j03-j0j0j0j0X   6.z/3z/uT3_/Ez/z/x/hsm/W_`cWd/&/ /s / / / %S %!DI!F/%T#Y"7/4/2/E#tCy.$9/ /),s),T#Y),V,c,DI,B/$/t/$/0 /s /$ /D33&#'$ X*3-X*X* X* sE#0011 2 X*t7S7D7@(3( ((<#3# ##J 3 3hsm 3HUXM 3D $t $ 7$ " " "  "  " tS%%6 677 8 " H!%"&$ f0f0 f0 f0  f0  f0f0P Z4ZDZ?? @@ r.r)rNrE):r rTrcrKrr contextlibrpathlibrtypingrrrrr r r r urllib.parser huggingface_hubrhuggingface_hub.repocardrrhf_apirrrnrutilsrrrrrrutils._deprecationr get_loggerrFrrrJrNr^rgr~rrrrrOrrrrrPr.r,rs  %TTT!%A6-2   H %P P f8c4i(8T8"!5d+!!!2"'%T "2"'t"'JU39-$2U39-$.5dD3IUYZ]U^2c4i 0T,+E#t),+ +QT+,I jHjHZUUr.