/usr/local/lib/python3.6/site-packages/transformers/commands/__pycache__
NameSizeModeActions
add_new_model.cpython-36.pyc65310644editdlrm
add_new_model_like.cpython-36.pyc426880644editdlrm
convert.cpython-36.pyc49430644editdlrm
download.cpython-36.pyc16600644editdlrm
env.cpython-36.pyc26050644editdlrm
lfs.cpython-36.pyc72440644editdlrm
run.cpython-36.pyc33720644editdlrm
serving.cpython-36.pyc67480644editdlrm
train.cpython-36.pyc45890644editdlrm
transformers_cli.cpython-36.pyc12610644editdlrm
user.cpython-36.pyc84530644editdlrm
__init__.cpython-36.pyc7940644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/transformers/commands/__pycache__/lfs.cpython-36.pyc (7244B)
3 Eg @sdZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z ddlZddlmZdd lmZejeZd ZGd d d eZGd ddZe dddZe e dddZGddde ZGdddZdS)a Implementation of a custom transfer agent for the transfer type "multipart" for git-lfs. Inspired by: github.com/cbartz/git-lfs-swift-transfer-agent/blob/master/git_lfs_swift_transfer.py Spec is: github.com/git-lfs/git-lfs/blob/master/docs/custom-transfers.md To launch debugger while developing: ``` [lfs "customtransfer.multipart"] path = /path/to/transformers/.env/bin/python args = -m debugpy --listen 5678 --wait-for-client /path/to/transformers/src/transformers/commands/transformers_cli.py lfs-multipart-upload ```N)ArgumentParser)AbstractContextManager)DictListOptional)logging)BaseTransformersCLICommandzlfs-multipart-uploadc@s"eZdZdZeedddZdS) LfsCommandsu Implementation of a custom transfer agent for the transfer type "multipart" for git-lfs. This lets users upload large files >5GB 🔥. Spec for LFS custom transfer agent is: https://github.com/git-lfs/git-lfs/blob/master/docs/custom-transfers.md This introduces two commands to the CLI: 1. $ transformers-cli lfs-enable-largefiles This should be executed once for each model repo that contains a model file >5GB. It's documented in the error message you get if you just try to git push a 5GB file without having enabled it before. 2. $ transformers-cli lfs-multipart-upload This command is called by lfs directly and is not meant to be called by the user. )parsercCsP|jddd}|jdtdd|jddd |jtd d}|jd dd dS) Nzlfs-enable-largefileszeDeprecated: use `huggingface-cli` instead. Configure your repository to enable upload of files > 5GB.)helppathz/Local path to repository you want to configure.)typer cSst|S)N)LfsEnableCommand)argsrC/usr/local/lib/python3.6/site-packages/transformers/commands/lfs.py>sz1LfsCommands.register_subcommand..)funczgDeprecated: use `huggingface-cli` instead. Command will get called by git-lfs, do not call it directly.cSst|S)N)LfsUploadCommand)rrrrrEs) add_parser add_argumentstr set_defaultsLFS_MULTIPART_UPLOAD_COMMAND)r Z enable_parserZ upload_parserrrrregister_subcommand6szLfsCommands.register_subcommandN)__name__ __module__ __qualname____doc__ staticmethodrrrrrrr $sr c@seZdZddZddZdS)rcCs ||_dS)N)r)selfrrrr__init__IszLfsEnableCommand.__init__cCsptjdtjj|jj}tjj|s6tdtdt j dj d|dt j dt j d|dtddS) NzcManaging repositories through transformers-cli is deprecated. Please use `huggingface-cli` instead.z)This does not look like a valid git repo.r z=git config lfs.customtransfer.multipart.path transformers-cliT)checkcwdz-git config lfs.customtransfer.multipart.args z Local repo set up for largefiles) warningswarnosrabspathrisdirprintexit subprocessrunsplitr)r"Z local_pathrrrr.Ls  zLfsEnableCommand.runN)rrrr#r.rrrrrHsr)msgcCs(tj|d}tjj|tjjdS)z-Write out the message in Line delimited JSON. N)jsondumpssysstdoutwriteflush)r0rrr write_msg_s r8)returncCsVtjtjjj}d|jd|jdfkr0dS|jdd krRtjdtj d|S) z$Read Line delimited JSON from stdin. terminatereventNdownloaduploadzReceived unexpected messager )r<r=) r2loadsr4stdinreadlinestripgetloggercriticalr,)r0rrrread_msgfs  rEc@sLeZdZdZeeedddZddZddZdd d Z d d Z ddZ dS) FileSlicezq File-like object that only reads a slice of a file Inspired by stackoverflow.com/a/29838711/593036 )filepath seek_from read_limitcCs||_||_||_d|_dS)Nr)rGrHrIn_seen)r"rGrHrIrrrr#|szFileSlice.__init__cCs t|jd|_|jj|j|S)Nrb)openrGfseekrH)r"rrr __enter__szFileSlice.__enter__cCs$tj|jjj}t|j||jS)N)r(fstatrMfilenost_sizeminrIrH)r" total_lengthrrr__len__szFileSlice.__len__r cCsP|j|jkrdS|j|j}|jj|dkr.|nt||}|jt|7_|S)Nr)rJrIrMreadrSlen)r"nZremaining_amountdatarrrrWs   zFileSlice.readccs|jddVdS)Ni)rYii@)rW)r"rrr__iter__szFileSlice.__iter__cGs|jjdS)N)rMclose)r"rrrr__exit__szFileSlice.__exit__N)r_) rrrr rintr#rOrUrWr\r^rrrrrFus rFc@seZdZddZddZdS)rcCs ||_dS)N)r)r"rrrrr#szLfsUploadCommand.__init__cCshtjtjjj}|jddko.|jddksLtdddditjd tix t }|dkrptjd |d }|d }|d d}|d d}t |j d}t |j }g} x~t|D]r\} } t|| ||dR} tj| | d} | j| j| jjd| d dtd|| d ||dWdQRXqWtj||| dd} | jtd|dqXWdS)Nr;initZ operationr=error zWrong lfs init operation)codemessager roidractionhrefheader chunk_size)rHrI)rZetag)rkZ partNumberprogress)r;rfZ bytesSoFarZbytesSinceLast)rfparts)r2Zcomplete)r;rf)r2r>r4r?r@rArBr8r,rEr`poplistvalues enumeraterFrequestsputraise_for_statusappendheaderspost)r"Zinit_msgr0rfrGZcompletion_urlrirjZpresigned_urlsrmiZ presigned_urlrZrrrrr.sD        zLfsUploadCommand.runN)rrrr#r.rrrrrsr)r r2r(r-r4r&argparser contextlibrtypingrrrrrutilsrr get_loggerrrCrr rr8rErFrrrrr s&     $%