wL idZddlZddlZddlZddlZddlmZddlmZm Z m Z ddl m Z ddl mZddlmZmZmZdd lmZej*eZGd d e ZGd d ZdefdZde efdZGddZy)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/huggingface_hub/.env/bin/python args = -m debugpy --listen 5678 --wait-for-client /path/to/huggingface_hub/src/huggingface_hub/commands/huggingface_cli.py lfs-multipart-upload ```N)_SubParsersAction)DictListOptional)BaseHuggingfaceCLICommand)LFS_MULTIPART_UPLOAD_COMMAND) get_sessionhf_raise_for_statuslogging) SliceFileObjc&eZdZdZedefdZy) 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. $ huggingface-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. $ huggingface-cli lfs-multipart-upload This command is called by lfs directly and is not meant to be called by the user. parserc|jdd}|jdtd|jd|jtd }|jd y) Nzlfs-enable-largefilesz:Configure your repository to enable upload of files > 5GB.)helppathz/Local path to repository you want to configure.)typerct|SN)LfsEnableCommandargss b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/huggingface_hub/commands/lfs.pyz1LfsCommands.register_subcommand..? 5Ed5K)funcF)add_helpct|Sr)LfsUploadCommandrs rrz1LfsCommands.register_subcommand..Crr) add_parser add_argumentstr set_defaultsr)r enable_parser upload_parsers rregister_subcommandzLfsCommands.register_subcommand9sr)) #*f*  ""6:k"l""(K"L))*FQV)W ""(K"LrN)__name__ __module__ __qualname____doc__ staticmethodrr(rrrr$s&( M$5 M MrrceZdZdZdZy)rc||_yrrselfrs r__init__zLfsEnableCommand.__init__G  rctjj|jj}tjj |st dt dtjdjd|tjdtjd|t dy)Nz)This does not look like a valid git repo.z G J P P R ;  s%%#H A-H5 H H H  H)rNNrBr.rrr!r!rs R9rr!)r,rFr9r>rHargparsertypingrrrhuggingface_hub.commandsrhuggingface_hub.lfsrutilsr r r utils._lfsr get_loggerr)rYrrrMr[r!r.rrrs$  &''><==%   H %M+MD22,4 (4. V9V9r