wL i8dZddlZddlZddlZddlmZmZddlmZm Z ddl m Z ddl m Z ddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZe j6eZGd deZy)aContains command to upload a repo or file with the CLI. Usage: # Upload file (implicit) hf upload my-cool-model ./my-cool-model.safetensors # Upload file (explicit) hf upload my-cool-model ./my-cool-model.safetensors model.safetensors # Upload directory (implicit). If `my-cool-model/` is a directory it will be uploaded, otherwise an exception is raised. hf upload my-cool-model # Upload directory (explicit) hf upload my-cool-model ./models/my-cool-model . # Upload filtered directory (example: tensorboard logs except for the last run) hf upload my-cool-model ./model/training /logs --include "*.tfevents.*" --exclude "*20230905*" # Upload with wildcard hf upload my-cool-model "./model/training/*.safetensors" # Upload private dataset hf upload Wauplin/my-cool-dataset ./data . --repo-type=dataset --private # Upload with token hf upload Wauplin/my-cool-model --token=hf_**** # Sync local Space with Hub (upload new files, delete removed files) hf upload Wauplin/space-example --repo-type=space --exclude="/logs/*" --delete="*" --commit-message="Sync local Space with Hub" # Schedule commits every 30 minutes hf upload Wauplin/my-cool-model --every=30 N) Namespace_SubParsersAction)ListOptional)logging)CommitScheduler)BaseHuggingfaceCLICommand)HF_HUB_ENABLE_HF_TRANSFER)RevisionNotFoundError)HfApi)disable_progress_barsenable_progress_bars)is_xet_availablecFeZdZedefdZdeddfdZd dZde fdZ y) UploadCommandparserc|jdd}|jdtd|jddd |jd dd |jd gddd|jdtd|jddd|jddtd|jddtd|jddtd|jd td!|jd"td#|jd$dd%|jd&td'|jd(td)|jd*dd+|j t ,y)-NuploadzLUpload a file or a folder to the Hub. Recommended for single-commit uploads.)helprepo_idzz)UploadCommand.__init__..s.]qDOO/C.]s)r#r[zICannot set `--include` when passing a `local_path` containing a wildcard..zLCannot set `path_in_repo` when passing a `local_path` containing a wildcard.'zD' is not a local file or folder. Please set `local_path` explicitly.)r repo_typerevisionprivateincludeexcludedeletecommit_messagecommit_description create_prr r1apiquietevery ValueErrorsplitranyrospathisfileisdirbasename)selfr. repo_names ` r+__init__zUploadCommand.__init__sM LL (,'+}} !\\ ,0LL ,0LL +/;; -1-@-@151H1H#~~djj?PQ::  :: !djjAoFtzzlRTUV V&*jj ++C04   ?? &3.]_.]+]||' !lmm  ,1B1Bc1I !opp!DO??DL #D  __ $ )B'DO )D  __ $y)A'DO #D  __ $q +opq q    &277>>$//+J"ooDO " 0 0 AD     &"ooDO #D #ooDO $ 1 1D r-c|jr`ttj5tjdt |j dddtytjt |j tjy#1swYtyxYw)Nignore) rFr warningscatch_warnings simplefilterprint_uploadrrset_verbosity_infoset_verbosity_warning)rPs r+runzUploadCommand.runs} :: ! #((* &%%h/dlln% & ! "  & & ( $,,. !  ) ) + & ! "s /B//Cc  tjj|jr|j-t |jdkDrt jd|j-t |jdkDrt jd|j-t |jdkDrt jdtststjd|jtjj|jrtjj|j}|j j#|jr#|j dt |j n |j }|jg}g}nq|j}|j }|jxsg}|jxsg}|j-t |jdkDrt jdt%||j&|j(|j*||||j,|j|j. }t1d|jd |j&d  t3j4d tjj|jsBtjj;|jst=d|jd|j.j?|j&|j(d |j,|j(dk(rdndj&}|j*?|j@s3 |j.jC||j(|j*tjj|jri|j.jI|j|j ||j(|j*|jJ|jL|j@S|j.jO|j|j ||j(|j*|jJ|jL|j@|j|j|j S#t6$r|j9Yy wxYw#tD$rZtjd|j*d|j.jG||j(|j*d YwxYw)Nrz5Ignoring `--include` since a single file is uploaded.z5Ignoring `--exclude` since a single file is uploaded.z4Ignoring `--delete` since a single file is uploaded.zConsider using `hf_transfer` for faster uploads. This solution comes with some limitations. See https://huggingface.co/docs/huggingface_hub/hf_transfer for more details.z:Ignoring `--delete` when uploading with scheduled commits.) folder_pathrr<r=allow_patternsignore_patternsrr>rGhf_apizScheduling commits every z minutes to r:TdzStopped scheduled commits.zNo such file or directory: 'z'.rgradio)rr<exist_okr> space_sdk)rr<r=zBranch 'z' not found. Creating it...)rr<branchrd)path_or_fileobjrrr<r=rBrCrD) r^rrr<r=rBrCrDr_r`delete_patterns)(rKrLrMrr?lenrUwarnr@rArr loggerinforGdirnamerendswithrrr<r=r>rErXtimesleepKeyboardInterruptstoprNFileNotFoundError create_reporD repo_infor create_branch upload_filerBrC upload_folder)rPr^rr_r` schedulerrs r+rYzUploadCommand._uploads! 77>>$// *||'C ,=,A UV||'C ,=,A UV{{&3t{{+;a+? TU!*C KK]  :: !ww~~doo. ggoodoo> ((11$//B%%&=T__)=(=>** #'//!2"$"oo #00 !%!3"&,,"4";;*s4;;/?!/CMM"^_'' ..- /) jjxx I -djj\iFWFWEXXYZ [ 4JJsOww~~doo.rww}}T__7U#&B4??BSSU$VW W((&&LLnnLL"&..G";h '  '  == $T^^ w""7dnnW[WdWd"e 77>>$// *88'' $!....#22#'#:#:..(  88)) OO!....#22#'#:#:..#|| $ $ *  S% 4 3 4*) w ht}}o5PQR&&w$..Y]YfYfqu&v ws%&S(2T(TTAU*)U*)r/N) __name__ __module__ __qualname__ staticmethodrr,rrRr\r'rYr-r+rrDsGE7$5E7E7N92Y92492v ,hhr-r)__doc__rKrorUargparserrtypingrrhuggingface_hubr!huggingface_hub._commit_schedulerrhuggingface_hub.commandsr huggingface_hub.constantsr huggingface_hub.errorsr huggingface_hub.hf_apir huggingface_hub.utilsr rhuggingface_hub.utils._runtimer get_loggerrzrkrr~r-r+rsW D 1!#=>?8(M;   H %x-xr-