Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- ckpts/llama-3b/global_step100/bf16_zero_pp_rank_160_mp_rank_01_optim_states.pt +3 -0
- ckpts/llama-3b/global_step100/bf16_zero_pp_rank_246_mp_rank_02_optim_states.pt +3 -0
- ckpts/llama-3b/global_step100/layer_29-model_01-model_states.pt +3 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/__init__.py +27 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/_cli_utils.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/delete_cache.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/download.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/env.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/huggingface_cli.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/lfs.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/scan_cache.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/upload.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/user.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/_cli_utils.py +64 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/delete_cache.py +428 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/download.py +215 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/env.py +36 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/huggingface_cli.py +53 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/lfs.py +199 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/scan_cache.py +139 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/upload.py +298 -0
- venv/lib/python3.10/site-packages/huggingface_hub/commands/user.py +188 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__init__.py +115 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/audio_classification.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/audio_to_audio.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/automatic_speech_recognition.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/base.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/chat_completion.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/depth_estimation.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/document_question_answering.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/feature_extraction.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/fill_mask.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/image_classification.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/image_segmentation.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/image_to_image.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/image_to_text.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/object_detection.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/question_answering.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/sentence_similarity.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/summarization.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/table_question_answering.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/text2text_generation.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/text_classification.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/text_generation.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/text_to_audio.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/text_to_image.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/token_classification.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/translation.cpython-310.pyc +0 -0
ckpts/llama-3b/global_step100/bf16_zero_pp_rank_160_mp_rank_01_optim_states.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:179d1ed1c7e1c869578a9c215acadb6b3bdc32b9ca0b36904058c42f24ca0442
|
3 |
+
size 41830148
|
ckpts/llama-3b/global_step100/bf16_zero_pp_rank_246_mp_rank_02_optim_states.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:236817bcd78c5159bc5e6f66895defe217b11eba45accc0a410985fdbdc3ce31
|
3 |
+
size 41830340
|
ckpts/llama-3b/global_step100/layer_29-model_01-model_states.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:427f9304deb973b37942df0ff847d672c3d270e067578690a8456aab87159bbe
|
3 |
+
size 116407086
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/__init__.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2020 The HuggingFace Team. All rights reserved.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
|
15 |
+
from abc import ABC, abstractmethod
|
16 |
+
from argparse import _SubParsersAction
|
17 |
+
|
18 |
+
|
19 |
+
class BaseHuggingfaceCLICommand(ABC):
|
20 |
+
@staticmethod
|
21 |
+
@abstractmethod
|
22 |
+
def register_subcommand(parser: _SubParsersAction):
|
23 |
+
raise NotImplementedError()
|
24 |
+
|
25 |
+
@abstractmethod
|
26 |
+
def run(self):
|
27 |
+
raise NotImplementedError()
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (831 Bytes). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/_cli_utils.cpython-310.pyc
ADDED
Binary file (2.22 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/delete_cache.cpython-310.pyc
ADDED
Binary file (13.5 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/download.cpython-310.pyc
ADDED
Binary file (6.17 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/env.cpython-310.pyc
ADDED
Binary file (1.23 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/huggingface_cli.cpython-310.pyc
ADDED
Binary file (1.34 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/lfs.cpython-310.pyc
ADDED
Binary file (5.76 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/scan_cache.cpython-310.pyc
ADDED
Binary file (4.04 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/upload.cpython-310.pyc
ADDED
Binary file (8 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/__pycache__/user.cpython-310.pyc
ADDED
Binary file (6.27 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/_cli_utils.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2022 The HuggingFace Team. All rights reserved.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
"""Contains a utility for good-looking prints."""
|
15 |
+
|
16 |
+
import os
|
17 |
+
from typing import List, Union
|
18 |
+
|
19 |
+
|
20 |
+
class ANSI:
|
21 |
+
"""
|
22 |
+
Helper for en.wikipedia.org/wiki/ANSI_escape_code
|
23 |
+
"""
|
24 |
+
|
25 |
+
_bold = "\u001b[1m"
|
26 |
+
_gray = "\u001b[90m"
|
27 |
+
_red = "\u001b[31m"
|
28 |
+
_reset = "\u001b[0m"
|
29 |
+
|
30 |
+
@classmethod
|
31 |
+
def bold(cls, s: str) -> str:
|
32 |
+
return cls._format(s, cls._bold)
|
33 |
+
|
34 |
+
@classmethod
|
35 |
+
def gray(cls, s: str) -> str:
|
36 |
+
return cls._format(s, cls._gray)
|
37 |
+
|
38 |
+
@classmethod
|
39 |
+
def red(cls, s: str) -> str:
|
40 |
+
return cls._format(s, cls._bold + cls._red)
|
41 |
+
|
42 |
+
@classmethod
|
43 |
+
def _format(cls, s: str, code: str) -> str:
|
44 |
+
if os.environ.get("NO_COLOR"):
|
45 |
+
# See https://no-color.org/
|
46 |
+
return s
|
47 |
+
return f"{code}{s}{cls._reset}"
|
48 |
+
|
49 |
+
|
50 |
+
def tabulate(rows: List[List[Union[str, int]]], headers: List[str]) -> str:
|
51 |
+
"""
|
52 |
+
Inspired by:
|
53 |
+
|
54 |
+
- stackoverflow.com/a/8356620/593036
|
55 |
+
- stackoverflow.com/questions/9535954/printing-lists-as-tabular-data
|
56 |
+
"""
|
57 |
+
col_widths = [max(len(str(x)) for x in col) for col in zip(*rows, headers)]
|
58 |
+
row_format = ("{{:{}}} " * len(headers)).format(*col_widths)
|
59 |
+
lines = []
|
60 |
+
lines.append(row_format.format(*headers))
|
61 |
+
lines.append(row_format.format(*["-" * w for w in col_widths]))
|
62 |
+
for row in rows:
|
63 |
+
lines.append(row_format.format(*row))
|
64 |
+
return "\n".join(lines)
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/delete_cache.py
ADDED
@@ -0,0 +1,428 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022-present, the HuggingFace Inc. team.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""Contains command to delete some revisions from the HF cache directory.
|
16 |
+
|
17 |
+
Usage:
|
18 |
+
huggingface-cli delete-cache
|
19 |
+
huggingface-cli delete-cache --disable-tui
|
20 |
+
huggingface-cli delete-cache --dir ~/.cache/huggingface/hub
|
21 |
+
|
22 |
+
NOTE:
|
23 |
+
This command is based on `InquirerPy` to build the multiselect menu in the terminal.
|
24 |
+
This dependency has to be installed with `pip install huggingface_hub[cli]`. Since
|
25 |
+
we want to avoid as much as possible cross-platform issues, I chose a library that
|
26 |
+
is built on top of `python-prompt-toolkit` which seems to be a reference in terminal
|
27 |
+
GUI (actively maintained on both Unix and Windows, 7.9k stars).
|
28 |
+
|
29 |
+
For the moment, the TUI feature is in beta.
|
30 |
+
|
31 |
+
See:
|
32 |
+
- https://github.com/kazhala/InquirerPy
|
33 |
+
- https://inquirerpy.readthedocs.io/en/latest/
|
34 |
+
- https://github.com/prompt-toolkit/python-prompt-toolkit
|
35 |
+
|
36 |
+
Other solutions could have been:
|
37 |
+
- `simple_term_menu`: would be good as well for our use case but some issues suggest
|
38 |
+
that Windows is less supported.
|
39 |
+
See: https://github.com/IngoMeyer441/simple-term-menu
|
40 |
+
- `PyInquirer`: very similar to `InquirerPy` but older and not maintained anymore.
|
41 |
+
In particular, no support of Python3.10.
|
42 |
+
See: https://github.com/CITGuru/PyInquirer
|
43 |
+
- `pick` (or `pickpack`): easy to use and flexible but built on top of Python's
|
44 |
+
standard library `curses` that is specific to Unix (not implemented on Windows).
|
45 |
+
See https://github.com/wong2/pick and https://github.com/anafvana/pickpack.
|
46 |
+
- `inquirer`: lot of traction (700 stars) but explicitly states "experimental
|
47 |
+
support of Windows". Not built on top of `python-prompt-toolkit`.
|
48 |
+
See https://github.com/magmax/python-inquirer
|
49 |
+
|
50 |
+
TODO: add support for `huggingface-cli delete-cache aaaaaa bbbbbb cccccc (...)` ?
|
51 |
+
TODO: add "--keep-last" arg to delete revisions that are not on `main` ref
|
52 |
+
TODO: add "--filter" arg to filter repositories by name ?
|
53 |
+
TODO: add "--sort" arg to sort by size ?
|
54 |
+
TODO: add "--limit" arg to limit to X repos ?
|
55 |
+
TODO: add "-y" arg for immediate deletion ?
|
56 |
+
See discussions in https://github.com/huggingface/huggingface_hub/issues/1025.
|
57 |
+
"""
|
58 |
+
|
59 |
+
import os
|
60 |
+
from argparse import Namespace, _SubParsersAction
|
61 |
+
from functools import wraps
|
62 |
+
from tempfile import mkstemp
|
63 |
+
from typing import Any, Callable, Iterable, List, Optional, Union
|
64 |
+
|
65 |
+
from ..utils import CachedRepoInfo, CachedRevisionInfo, HFCacheInfo, scan_cache_dir
|
66 |
+
from . import BaseHuggingfaceCLICommand
|
67 |
+
from ._cli_utils import ANSI
|
68 |
+
|
69 |
+
|
70 |
+
try:
|
71 |
+
from InquirerPy import inquirer
|
72 |
+
from InquirerPy.base.control import Choice
|
73 |
+
from InquirerPy.separator import Separator
|
74 |
+
|
75 |
+
_inquirer_py_available = True
|
76 |
+
except ImportError:
|
77 |
+
_inquirer_py_available = False
|
78 |
+
|
79 |
+
|
80 |
+
def require_inquirer_py(fn: Callable) -> Callable:
|
81 |
+
"""Decorator to flag methods that require `InquirerPy`."""
|
82 |
+
|
83 |
+
# TODO: refactor this + imports in a unified pattern across codebase
|
84 |
+
@wraps(fn)
|
85 |
+
def _inner(*args, **kwargs):
|
86 |
+
if not _inquirer_py_available:
|
87 |
+
raise ImportError(
|
88 |
+
"The `delete-cache` command requires extra dependencies to work with"
|
89 |
+
" the TUI.\nPlease run `pip install huggingface_hub[cli]` to install"
|
90 |
+
" them.\nOtherwise, disable TUI using the `--disable-tui` flag."
|
91 |
+
)
|
92 |
+
|
93 |
+
return fn(*args, **kwargs)
|
94 |
+
|
95 |
+
return _inner
|
96 |
+
|
97 |
+
|
98 |
+
# Possibility for the user to cancel deletion
|
99 |
+
_CANCEL_DELETION_STR = "CANCEL_DELETION"
|
100 |
+
|
101 |
+
|
102 |
+
class DeleteCacheCommand(BaseHuggingfaceCLICommand):
|
103 |
+
@staticmethod
|
104 |
+
def register_subcommand(parser: _SubParsersAction):
|
105 |
+
delete_cache_parser = parser.add_parser("delete-cache", help="Delete revisions from the cache directory.")
|
106 |
+
|
107 |
+
delete_cache_parser.add_argument(
|
108 |
+
"--dir",
|
109 |
+
type=str,
|
110 |
+
default=None,
|
111 |
+
help="cache directory (optional). Default to the default HuggingFace cache.",
|
112 |
+
)
|
113 |
+
|
114 |
+
delete_cache_parser.add_argument(
|
115 |
+
"--disable-tui",
|
116 |
+
action="store_true",
|
117 |
+
help=(
|
118 |
+
"Disable Terminal User Interface (TUI) mode. Useful if your"
|
119 |
+
" platform/terminal doesn't support the multiselect menu."
|
120 |
+
),
|
121 |
+
)
|
122 |
+
|
123 |
+
delete_cache_parser.set_defaults(func=DeleteCacheCommand)
|
124 |
+
|
125 |
+
def __init__(self, args: Namespace) -> None:
|
126 |
+
self.cache_dir: Optional[str] = args.dir
|
127 |
+
self.disable_tui: bool = args.disable_tui
|
128 |
+
|
129 |
+
def run(self):
|
130 |
+
"""Run `delete-cache` command with or without TUI."""
|
131 |
+
# Scan cache directory
|
132 |
+
hf_cache_info = scan_cache_dir(self.cache_dir)
|
133 |
+
|
134 |
+
# Manual review from the user
|
135 |
+
if self.disable_tui:
|
136 |
+
selected_hashes = _manual_review_no_tui(hf_cache_info, preselected=[])
|
137 |
+
else:
|
138 |
+
selected_hashes = _manual_review_tui(hf_cache_info, preselected=[])
|
139 |
+
|
140 |
+
# If deletion is not cancelled
|
141 |
+
if len(selected_hashes) > 0 and _CANCEL_DELETION_STR not in selected_hashes:
|
142 |
+
confirm_message = _get_expectations_str(hf_cache_info, selected_hashes) + " Confirm deletion ?"
|
143 |
+
|
144 |
+
# Confirm deletion
|
145 |
+
if self.disable_tui:
|
146 |
+
confirmed = _ask_for_confirmation_no_tui(confirm_message)
|
147 |
+
else:
|
148 |
+
confirmed = _ask_for_confirmation_tui(confirm_message)
|
149 |
+
|
150 |
+
# Deletion is confirmed
|
151 |
+
if confirmed:
|
152 |
+
strategy = hf_cache_info.delete_revisions(*selected_hashes)
|
153 |
+
print("Start deletion.")
|
154 |
+
strategy.execute()
|
155 |
+
print(
|
156 |
+
f"Done. Deleted {len(strategy.repos)} repo(s) and"
|
157 |
+
f" {len(strategy.snapshots)} revision(s) for a total of"
|
158 |
+
f" {strategy.expected_freed_size_str}."
|
159 |
+
)
|
160 |
+
return
|
161 |
+
|
162 |
+
# Deletion is cancelled
|
163 |
+
print("Deletion is cancelled. Do nothing.")
|
164 |
+
|
165 |
+
|
166 |
+
@require_inquirer_py
|
167 |
+
def _manual_review_tui(hf_cache_info: HFCacheInfo, preselected: List[str]) -> List[str]:
|
168 |
+
"""Ask the user for a manual review of the revisions to delete.
|
169 |
+
|
170 |
+
Displays a multi-select menu in the terminal (TUI).
|
171 |
+
"""
|
172 |
+
# Define multiselect list
|
173 |
+
choices = _get_tui_choices_from_scan(repos=hf_cache_info.repos, preselected=preselected)
|
174 |
+
checkbox = inquirer.checkbox(
|
175 |
+
message="Select revisions to delete:",
|
176 |
+
choices=choices, # List of revisions with some pre-selection
|
177 |
+
cycle=False, # No loop between top and bottom
|
178 |
+
height=100, # Large list if possible
|
179 |
+
# We use the instruction to display to the user the expected effect of the
|
180 |
+
# deletion.
|
181 |
+
instruction=_get_expectations_str(
|
182 |
+
hf_cache_info,
|
183 |
+
selected_hashes=[c.value for c in choices if isinstance(c, Choice) and c.enabled],
|
184 |
+
),
|
185 |
+
# We use the long instruction to should keybindings instructions to the user
|
186 |
+
long_instruction="Press <space> to select, <enter> to validate and <ctrl+c> to quit without modification.",
|
187 |
+
# Message that is displayed once the user validates its selection.
|
188 |
+
transformer=lambda result: f"{len(result)} revision(s) selected.",
|
189 |
+
)
|
190 |
+
|
191 |
+
# Add a callback to update the information line when a revision is
|
192 |
+
# selected/unselected
|
193 |
+
def _update_expectations(_) -> None:
|
194 |
+
# Hacky way to dynamically set an instruction message to the checkbox when
|
195 |
+
# a revision hash is selected/unselected.
|
196 |
+
checkbox._instruction = _get_expectations_str(
|
197 |
+
hf_cache_info,
|
198 |
+
selected_hashes=[choice["value"] for choice in checkbox.content_control.choices if choice["enabled"]],
|
199 |
+
)
|
200 |
+
|
201 |
+
checkbox.kb_func_lookup["toggle"].append({"func": _update_expectations})
|
202 |
+
|
203 |
+
# Finally display the form to the user.
|
204 |
+
try:
|
205 |
+
return checkbox.execute()
|
206 |
+
except KeyboardInterrupt:
|
207 |
+
return [] # Quit without deletion
|
208 |
+
|
209 |
+
|
210 |
+
@require_inquirer_py
|
211 |
+
def _ask_for_confirmation_tui(message: str, default: bool = True) -> bool:
|
212 |
+
"""Ask for confirmation using Inquirer."""
|
213 |
+
return inquirer.confirm(message, default=default).execute()
|
214 |
+
|
215 |
+
|
216 |
+
def _get_tui_choices_from_scan(repos: Iterable[CachedRepoInfo], preselected: List[str]) -> List:
|
217 |
+
"""Build a list of choices from the scanned repos.
|
218 |
+
|
219 |
+
Args:
|
220 |
+
repos (*Iterable[`CachedRepoInfo`]*):
|
221 |
+
List of scanned repos on which we want to delete revisions.
|
222 |
+
preselected (*List[`str`]*):
|
223 |
+
List of revision hashes that will be preselected.
|
224 |
+
|
225 |
+
Return:
|
226 |
+
The list of choices to pass to `inquirer.checkbox`.
|
227 |
+
"""
|
228 |
+
choices: List[Union[Choice, Separator]] = []
|
229 |
+
|
230 |
+
# First choice is to cancel the deletion. If selected, nothing will be deleted,
|
231 |
+
# no matter the other selected items.
|
232 |
+
choices.append(
|
233 |
+
Choice(
|
234 |
+
_CANCEL_DELETION_STR,
|
235 |
+
name="None of the following (if selected, nothing will be deleted).",
|
236 |
+
enabled=False,
|
237 |
+
)
|
238 |
+
)
|
239 |
+
|
240 |
+
# Display a separator per repo and a Choice for each revisions of the repo
|
241 |
+
for repo in sorted(repos, key=_repo_sorting_order):
|
242 |
+
# Repo as separator
|
243 |
+
choices.append(
|
244 |
+
Separator(
|
245 |
+
f"\n{repo.repo_type.capitalize()} {repo.repo_id} ({repo.size_on_disk_str},"
|
246 |
+
f" used {repo.last_accessed_str})"
|
247 |
+
)
|
248 |
+
)
|
249 |
+
for revision in sorted(repo.revisions, key=_revision_sorting_order):
|
250 |
+
# Revision as choice
|
251 |
+
choices.append(
|
252 |
+
Choice(
|
253 |
+
revision.commit_hash,
|
254 |
+
name=(
|
255 |
+
f"{revision.commit_hash[:8]}:"
|
256 |
+
f" {', '.join(sorted(revision.refs)) or '(detached)'} #"
|
257 |
+
f" modified {revision.last_modified_str}"
|
258 |
+
),
|
259 |
+
enabled=revision.commit_hash in preselected,
|
260 |
+
)
|
261 |
+
)
|
262 |
+
|
263 |
+
# Return choices
|
264 |
+
return choices
|
265 |
+
|
266 |
+
|
267 |
+
def _manual_review_no_tui(hf_cache_info: HFCacheInfo, preselected: List[str]) -> List[str]:
|
268 |
+
"""Ask the user for a manual review of the revisions to delete.
|
269 |
+
|
270 |
+
Used when TUI is disabled. Manual review happens in a separate tmp file that the
|
271 |
+
user can manually edit.
|
272 |
+
"""
|
273 |
+
# 1. Generate temporary file with delete commands.
|
274 |
+
fd, tmp_path = mkstemp(suffix=".txt") # suffix to make it easier to find by editors
|
275 |
+
os.close(fd)
|
276 |
+
|
277 |
+
lines = []
|
278 |
+
for repo in sorted(hf_cache_info.repos, key=_repo_sorting_order):
|
279 |
+
lines.append(
|
280 |
+
f"\n# {repo.repo_type.capitalize()} {repo.repo_id} ({repo.size_on_disk_str},"
|
281 |
+
f" used {repo.last_accessed_str})"
|
282 |
+
)
|
283 |
+
for revision in sorted(repo.revisions, key=_revision_sorting_order):
|
284 |
+
lines.append(
|
285 |
+
# Deselect by prepending a '#'
|
286 |
+
f"{'' if revision.commit_hash in preselected else '#'} "
|
287 |
+
f" {revision.commit_hash} # Refs:"
|
288 |
+
# Print `refs` as comment on same line
|
289 |
+
f" {', '.join(sorted(revision.refs)) or '(detached)'} # modified"
|
290 |
+
# Print `last_modified` as comment on same line
|
291 |
+
f" {revision.last_modified_str}"
|
292 |
+
)
|
293 |
+
|
294 |
+
with open(tmp_path, "w") as f:
|
295 |
+
f.write(_MANUAL_REVIEW_NO_TUI_INSTRUCTIONS)
|
296 |
+
f.write("\n".join(lines))
|
297 |
+
|
298 |
+
# 2. Prompt instructions to user.
|
299 |
+
instructions = f"""
|
300 |
+
TUI is disabled. In order to select which revisions you want to delete, please edit
|
301 |
+
the following file using the text editor of your choice. Instructions for manual
|
302 |
+
editing are located at the beginning of the file. Edit the file, save it and confirm
|
303 |
+
to continue.
|
304 |
+
File to edit: {ANSI.bold(tmp_path)}
|
305 |
+
"""
|
306 |
+
print("\n".join(line.strip() for line in instructions.strip().split("\n")))
|
307 |
+
|
308 |
+
# 3. Wait for user confirmation.
|
309 |
+
while True:
|
310 |
+
selected_hashes = _read_manual_review_tmp_file(tmp_path)
|
311 |
+
if _ask_for_confirmation_no_tui(
|
312 |
+
_get_expectations_str(hf_cache_info, selected_hashes) + " Continue ?",
|
313 |
+
default=False,
|
314 |
+
):
|
315 |
+
break
|
316 |
+
|
317 |
+
# 4. Return selected_hashes
|
318 |
+
os.remove(tmp_path)
|
319 |
+
return selected_hashes
|
320 |
+
|
321 |
+
|
322 |
+
def _ask_for_confirmation_no_tui(message: str, default: bool = True) -> bool:
|
323 |
+
"""Ask for confirmation using pure-python."""
|
324 |
+
YES = ("y", "yes", "1")
|
325 |
+
NO = ("n", "no", "0")
|
326 |
+
DEFAULT = ""
|
327 |
+
ALL = YES + NO + (DEFAULT,)
|
328 |
+
full_message = message + (" (Y/n) " if default else " (y/N) ")
|
329 |
+
while True:
|
330 |
+
answer = input(full_message).lower()
|
331 |
+
if answer == DEFAULT:
|
332 |
+
return default
|
333 |
+
if answer in YES:
|
334 |
+
return True
|
335 |
+
if answer in NO:
|
336 |
+
return False
|
337 |
+
print(f"Invalid input. Must be one of {ALL}")
|
338 |
+
|
339 |
+
|
340 |
+
def _get_expectations_str(hf_cache_info: HFCacheInfo, selected_hashes: List[str]) -> str:
|
341 |
+
"""Format a string to display to the user how much space would be saved.
|
342 |
+
|
343 |
+
Example:
|
344 |
+
```
|
345 |
+
>>> _get_expectations_str(hf_cache_info, selected_hashes)
|
346 |
+
'7 revisions selected counting for 4.3G.'
|
347 |
+
```
|
348 |
+
"""
|
349 |
+
if _CANCEL_DELETION_STR in selected_hashes:
|
350 |
+
return "Nothing will be deleted."
|
351 |
+
strategy = hf_cache_info.delete_revisions(*selected_hashes)
|
352 |
+
return f"{len(selected_hashes)} revisions selected counting for {strategy.expected_freed_size_str}."
|
353 |
+
|
354 |
+
|
355 |
+
def _read_manual_review_tmp_file(tmp_path: str) -> List[str]:
|
356 |
+
"""Read the manually reviewed instruction file and return a list of revision hash.
|
357 |
+
|
358 |
+
Example:
|
359 |
+
```txt
|
360 |
+
# This is the tmp file content
|
361 |
+
###
|
362 |
+
|
363 |
+
# Commented out line
|
364 |
+
123456789 # revision hash
|
365 |
+
|
366 |
+
# Something else
|
367 |
+
# a_newer_hash # 2 days ago
|
368 |
+
an_older_hash # 3 days ago
|
369 |
+
```
|
370 |
+
|
371 |
+
```py
|
372 |
+
>>> _read_manual_review_tmp_file(tmp_path)
|
373 |
+
['123456789', 'an_older_hash']
|
374 |
+
```
|
375 |
+
"""
|
376 |
+
with open(tmp_path) as f:
|
377 |
+
content = f.read()
|
378 |
+
|
379 |
+
# Split lines
|
380 |
+
lines = [line.strip() for line in content.split("\n")]
|
381 |
+
|
382 |
+
# Filter commented lines
|
383 |
+
selected_lines = [line for line in lines if not line.startswith("#")]
|
384 |
+
|
385 |
+
# Select only before comment
|
386 |
+
selected_hashes = [line.split("#")[0].strip() for line in selected_lines]
|
387 |
+
|
388 |
+
# Return revision hashes
|
389 |
+
return [hash for hash in selected_hashes if len(hash) > 0]
|
390 |
+
|
391 |
+
|
392 |
+
_MANUAL_REVIEW_NO_TUI_INSTRUCTIONS = f"""
|
393 |
+
# INSTRUCTIONS
|
394 |
+
# ------------
|
395 |
+
# This is a temporary file created by running `huggingface-cli delete-cache` with the
|
396 |
+
# `--disable-tui` option. It contains a set of revisions that can be deleted from your
|
397 |
+
# local cache directory.
|
398 |
+
#
|
399 |
+
# Please manually review the revisions you want to delete:
|
400 |
+
# - Revision hashes can be commented out with '#'.
|
401 |
+
# - Only non-commented revisions in this file will be deleted.
|
402 |
+
# - Revision hashes that are removed from this file are ignored as well.
|
403 |
+
# - If `{_CANCEL_DELETION_STR}` line is uncommented, the all cache deletion is cancelled and
|
404 |
+
# no changes will be applied.
|
405 |
+
#
|
406 |
+
# Once you've manually reviewed this file, please confirm deletion in the terminal. This
|
407 |
+
# file will be automatically removed once done.
|
408 |
+
# ------------
|
409 |
+
|
410 |
+
# KILL SWITCH
|
411 |
+
# ------------
|
412 |
+
# Un-comment following line to completely cancel the deletion process
|
413 |
+
# {_CANCEL_DELETION_STR}
|
414 |
+
# ------------
|
415 |
+
|
416 |
+
# REVISIONS
|
417 |
+
# ------------
|
418 |
+
""".strip()
|
419 |
+
|
420 |
+
|
421 |
+
def _repo_sorting_order(repo: CachedRepoInfo) -> Any:
|
422 |
+
# First split by Dataset/Model, then sort by last accessed (oldest first)
|
423 |
+
return (repo.repo_type, repo.last_accessed)
|
424 |
+
|
425 |
+
|
426 |
+
def _revision_sorting_order(revision: CachedRevisionInfo) -> Any:
|
427 |
+
# Sort by last modified (oldest first)
|
428 |
+
return revision.last_modified
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/download.py
ADDED
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2023-present, the HuggingFace Inc. team.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""Contains command to download files from the Hub with the CLI.
|
16 |
+
|
17 |
+
Usage:
|
18 |
+
huggingface-cli download --help
|
19 |
+
|
20 |
+
# Download file
|
21 |
+
huggingface-cli download gpt2 config.json
|
22 |
+
|
23 |
+
# Download entire repo
|
24 |
+
huggingface-cli download fffiloni/zeroscope --repo-type=space --revision=refs/pr/78
|
25 |
+
|
26 |
+
# Download repo with filters
|
27 |
+
huggingface-cli download gpt2 --include="*.safetensors"
|
28 |
+
|
29 |
+
# Download with token
|
30 |
+
huggingface-cli download Wauplin/private-model --token=hf_***
|
31 |
+
|
32 |
+
# Download quietly (no progress bar, no warnings, only the returned path)
|
33 |
+
huggingface-cli download gpt2 config.json --quiet
|
34 |
+
|
35 |
+
# Download to local dir
|
36 |
+
huggingface-cli download gpt2 --local-dir=./models/gpt2
|
37 |
+
"""
|
38 |
+
|
39 |
+
import warnings
|
40 |
+
from argparse import Namespace, _SubParsersAction
|
41 |
+
from typing import List, Literal, Optional, Union
|
42 |
+
|
43 |
+
from huggingface_hub import logging
|
44 |
+
from huggingface_hub._snapshot_download import snapshot_download
|
45 |
+
from huggingface_hub.commands import BaseHuggingfaceCLICommand
|
46 |
+
from huggingface_hub.constants import HF_HUB_ENABLE_HF_TRANSFER
|
47 |
+
from huggingface_hub.file_download import hf_hub_download
|
48 |
+
from huggingface_hub.utils import disable_progress_bars, enable_progress_bars
|
49 |
+
|
50 |
+
|
51 |
+
logger = logging.get_logger(__name__)
|
52 |
+
|
53 |
+
|
54 |
+
class DownloadCommand(BaseHuggingfaceCLICommand):
|
55 |
+
@staticmethod
|
56 |
+
def register_subcommand(parser: _SubParsersAction):
|
57 |
+
download_parser = parser.add_parser("download", help="Download files from the Hub")
|
58 |
+
download_parser.add_argument(
|
59 |
+
"repo_id", type=str, help="ID of the repo to download from (e.g. `username/repo-name`)."
|
60 |
+
)
|
61 |
+
download_parser.add_argument(
|
62 |
+
"filenames", type=str, nargs="*", help="Files to download (e.g. `config.json`, `data/metadata.jsonl`)."
|
63 |
+
)
|
64 |
+
download_parser.add_argument(
|
65 |
+
"--repo-type",
|
66 |
+
choices=["model", "dataset", "space"],
|
67 |
+
default="model",
|
68 |
+
help="Type of repo to download from (defaults to 'model').",
|
69 |
+
)
|
70 |
+
download_parser.add_argument(
|
71 |
+
"--revision",
|
72 |
+
type=str,
|
73 |
+
help="An optional Git revision id which can be a branch name, a tag, or a commit hash.",
|
74 |
+
)
|
75 |
+
download_parser.add_argument(
|
76 |
+
"--include", nargs="*", type=str, help="Glob patterns to match files to download."
|
77 |
+
)
|
78 |
+
download_parser.add_argument(
|
79 |
+
"--exclude", nargs="*", type=str, help="Glob patterns to exclude from files to download."
|
80 |
+
)
|
81 |
+
download_parser.add_argument(
|
82 |
+
"--cache-dir", type=str, help="Path to the directory where to save the downloaded files."
|
83 |
+
)
|
84 |
+
download_parser.add_argument(
|
85 |
+
"--local-dir",
|
86 |
+
type=str,
|
87 |
+
help=(
|
88 |
+
"If set, the downloaded file will be placed under this directory either as a symlink (default) or a"
|
89 |
+
" regular file. Check out"
|
90 |
+
" https://huggingface.co/docs/huggingface_hub/guides/download#download-files-to-local-folder for more"
|
91 |
+
" details."
|
92 |
+
),
|
93 |
+
)
|
94 |
+
download_parser.add_argument(
|
95 |
+
"--local-dir-use-symlinks",
|
96 |
+
choices=["auto", "True", "False"],
|
97 |
+
default="auto",
|
98 |
+
help=(
|
99 |
+
"To be used with `local_dir`. If set to 'auto', the cache directory will be used and the file will be"
|
100 |
+
" either duplicated or symlinked to the local directory depending on its size. It set to `True`, a"
|
101 |
+
" symlink will be created, no matter the file size. If set to `False`, the file will either be"
|
102 |
+
" duplicated from cache (if already exists) or downloaded from the Hub and not cached."
|
103 |
+
),
|
104 |
+
)
|
105 |
+
download_parser.add_argument(
|
106 |
+
"--force-download",
|
107 |
+
action="store_true",
|
108 |
+
help="If True, the files will be downloaded even if they are already cached.",
|
109 |
+
)
|
110 |
+
download_parser.add_argument(
|
111 |
+
"--resume-download", action="store_true", help="If True, resume a previously interrupted download."
|
112 |
+
)
|
113 |
+
download_parser.add_argument(
|
114 |
+
"--token", type=str, help="A User Access Token generated from https://huggingface.co/settings/tokens"
|
115 |
+
)
|
116 |
+
download_parser.add_argument(
|
117 |
+
"--quiet",
|
118 |
+
action="store_true",
|
119 |
+
help="If True, progress bars are disabled and only the path to the download files is printed.",
|
120 |
+
)
|
121 |
+
download_parser.set_defaults(func=DownloadCommand)
|
122 |
+
|
123 |
+
def __init__(self, args: Namespace) -> None:
|
124 |
+
self.token = args.token
|
125 |
+
self.repo_id: str = args.repo_id
|
126 |
+
self.filenames: List[str] = args.filenames
|
127 |
+
self.repo_type: str = args.repo_type
|
128 |
+
self.revision: Optional[str] = args.revision
|
129 |
+
self.include: Optional[List[str]] = args.include
|
130 |
+
self.exclude: Optional[List[str]] = args.exclude
|
131 |
+
self.cache_dir: Optional[str] = args.cache_dir
|
132 |
+
self.local_dir: Optional[str] = args.local_dir
|
133 |
+
self.force_download: bool = args.force_download
|
134 |
+
self.resume_download: bool = args.resume_download
|
135 |
+
self.quiet: bool = args.quiet
|
136 |
+
|
137 |
+
# Raise if local_dir_use_symlinks is invalid
|
138 |
+
self.local_dir_use_symlinks: Union[Literal["auto"], bool]
|
139 |
+
use_symlinks_lowercase = args.local_dir_use_symlinks.lower()
|
140 |
+
if use_symlinks_lowercase == "true":
|
141 |
+
self.local_dir_use_symlinks = True
|
142 |
+
elif use_symlinks_lowercase == "false":
|
143 |
+
self.local_dir_use_symlinks = False
|
144 |
+
elif use_symlinks_lowercase == "auto":
|
145 |
+
self.local_dir_use_symlinks = "auto"
|
146 |
+
else:
|
147 |
+
raise ValueError(
|
148 |
+
f"'{args.local_dir_use_symlinks}' is not a valid value for `local_dir_use_symlinks`. It must be either"
|
149 |
+
" 'auto', 'True' or 'False'."
|
150 |
+
)
|
151 |
+
|
152 |
+
def run(self) -> None:
|
153 |
+
if self.quiet:
|
154 |
+
disable_progress_bars()
|
155 |
+
with warnings.catch_warnings():
|
156 |
+
warnings.simplefilter("ignore")
|
157 |
+
print(self._download()) # Print path to downloaded files
|
158 |
+
enable_progress_bars()
|
159 |
+
else:
|
160 |
+
logging.set_verbosity_info()
|
161 |
+
print(self._download()) # Print path to downloaded files
|
162 |
+
logging.set_verbosity_warning()
|
163 |
+
|
164 |
+
def _download(self) -> str:
|
165 |
+
# Warn user if patterns are ignored
|
166 |
+
if len(self.filenames) > 0:
|
167 |
+
if self.include is not None and len(self.include) > 0:
|
168 |
+
warnings.warn("Ignoring `--include` since filenames have being explicitly set.")
|
169 |
+
if self.exclude is not None and len(self.exclude) > 0:
|
170 |
+
warnings.warn("Ignoring `--exclude` since filenames have being explicitly set.")
|
171 |
+
|
172 |
+
if not HF_HUB_ENABLE_HF_TRANSFER:
|
173 |
+
logger.info(
|
174 |
+
"Consider using `hf_transfer` for faster downloads. This solution comes with some limitations. See"
|
175 |
+
" https://huggingface.co/docs/huggingface_hub/hf_transfer for more details."
|
176 |
+
)
|
177 |
+
|
178 |
+
# Single file to download: use `hf_hub_download`
|
179 |
+
if len(self.filenames) == 1:
|
180 |
+
return hf_hub_download(
|
181 |
+
repo_id=self.repo_id,
|
182 |
+
repo_type=self.repo_type,
|
183 |
+
revision=self.revision,
|
184 |
+
filename=self.filenames[0],
|
185 |
+
cache_dir=self.cache_dir,
|
186 |
+
resume_download=self.resume_download,
|
187 |
+
force_download=self.force_download,
|
188 |
+
token=self.token,
|
189 |
+
local_dir=self.local_dir,
|
190 |
+
local_dir_use_symlinks=self.local_dir_use_symlinks,
|
191 |
+
library_name="huggingface-cli",
|
192 |
+
)
|
193 |
+
|
194 |
+
# Otherwise: use `snapshot_download` to ensure all files comes from same revision
|
195 |
+
elif len(self.filenames) == 0:
|
196 |
+
allow_patterns = self.include
|
197 |
+
ignore_patterns = self.exclude
|
198 |
+
else:
|
199 |
+
allow_patterns = self.filenames
|
200 |
+
ignore_patterns = None
|
201 |
+
|
202 |
+
return snapshot_download(
|
203 |
+
repo_id=self.repo_id,
|
204 |
+
repo_type=self.repo_type,
|
205 |
+
revision=self.revision,
|
206 |
+
allow_patterns=allow_patterns,
|
207 |
+
ignore_patterns=ignore_patterns,
|
208 |
+
resume_download=self.resume_download,
|
209 |
+
force_download=self.force_download,
|
210 |
+
cache_dir=self.cache_dir,
|
211 |
+
token=self.token,
|
212 |
+
local_dir=self.local_dir,
|
213 |
+
local_dir_use_symlinks=self.local_dir_use_symlinks,
|
214 |
+
library_name="huggingface-cli",
|
215 |
+
)
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/env.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2022 The HuggingFace Team. All rights reserved.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
"""Contains command to print information about the environment.
|
15 |
+
|
16 |
+
Usage:
|
17 |
+
huggingface-cli env
|
18 |
+
"""
|
19 |
+
|
20 |
+
from argparse import _SubParsersAction
|
21 |
+
|
22 |
+
from ..utils import dump_environment_info
|
23 |
+
from . import BaseHuggingfaceCLICommand
|
24 |
+
|
25 |
+
|
26 |
+
class EnvironmentCommand(BaseHuggingfaceCLICommand):
|
27 |
+
def __init__(self, args):
|
28 |
+
self.args = args
|
29 |
+
|
30 |
+
@staticmethod
|
31 |
+
def register_subcommand(parser: _SubParsersAction):
|
32 |
+
env_parser = parser.add_parser("env", help="Print information about the environment.")
|
33 |
+
env_parser.set_defaults(func=EnvironmentCommand)
|
34 |
+
|
35 |
+
def run(self) -> None:
|
36 |
+
dump_environment_info()
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/huggingface_cli.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# Copyright 2020 The HuggingFace Team. All rights reserved.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
from argparse import ArgumentParser
|
17 |
+
|
18 |
+
from huggingface_hub.commands.delete_cache import DeleteCacheCommand
|
19 |
+
from huggingface_hub.commands.download import DownloadCommand
|
20 |
+
from huggingface_hub.commands.env import EnvironmentCommand
|
21 |
+
from huggingface_hub.commands.lfs import LfsCommands
|
22 |
+
from huggingface_hub.commands.scan_cache import ScanCacheCommand
|
23 |
+
from huggingface_hub.commands.upload import UploadCommand
|
24 |
+
from huggingface_hub.commands.user import UserCommands
|
25 |
+
|
26 |
+
|
27 |
+
def main():
|
28 |
+
parser = ArgumentParser("huggingface-cli", usage="huggingface-cli <command> [<args>]")
|
29 |
+
commands_parser = parser.add_subparsers(help="huggingface-cli command helpers")
|
30 |
+
|
31 |
+
# Register commands
|
32 |
+
EnvironmentCommand.register_subcommand(commands_parser)
|
33 |
+
UserCommands.register_subcommand(commands_parser)
|
34 |
+
UploadCommand.register_subcommand(commands_parser)
|
35 |
+
DownloadCommand.register_subcommand(commands_parser)
|
36 |
+
LfsCommands.register_subcommand(commands_parser)
|
37 |
+
ScanCacheCommand.register_subcommand(commands_parser)
|
38 |
+
DeleteCacheCommand.register_subcommand(commands_parser)
|
39 |
+
|
40 |
+
# Let's go
|
41 |
+
args = parser.parse_args()
|
42 |
+
|
43 |
+
if not hasattr(args, "func"):
|
44 |
+
parser.print_help()
|
45 |
+
exit(1)
|
46 |
+
|
47 |
+
# Run
|
48 |
+
service = args.func(args)
|
49 |
+
service.run()
|
50 |
+
|
51 |
+
|
52 |
+
if __name__ == "__main__":
|
53 |
+
main()
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/lfs.py
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Implementation of a custom transfer agent for the transfer type "multipart" for
|
3 |
+
git-lfs.
|
4 |
+
|
5 |
+
Inspired by:
|
6 |
+
github.com/cbartz/git-lfs-swift-transfer-agent/blob/master/git_lfs_swift_transfer.py
|
7 |
+
|
8 |
+
Spec is: github.com/git-lfs/git-lfs/blob/master/docs/custom-transfers.md
|
9 |
+
|
10 |
+
|
11 |
+
To launch debugger while developing:
|
12 |
+
|
13 |
+
``` [lfs "customtransfer.multipart"]
|
14 |
+
path = /path/to/huggingface_hub/.env/bin/python args = -m debugpy --listen 5678
|
15 |
+
--wait-for-client
|
16 |
+
/path/to/huggingface_hub/src/huggingface_hub/commands/huggingface_cli.py
|
17 |
+
lfs-multipart-upload ```"""
|
18 |
+
|
19 |
+
import json
|
20 |
+
import os
|
21 |
+
import subprocess
|
22 |
+
import sys
|
23 |
+
from argparse import _SubParsersAction
|
24 |
+
from typing import Dict, List, Optional
|
25 |
+
|
26 |
+
from huggingface_hub.commands import BaseHuggingfaceCLICommand
|
27 |
+
from huggingface_hub.lfs import LFS_MULTIPART_UPLOAD_COMMAND, SliceFileObj
|
28 |
+
|
29 |
+
from ..utils import get_session, hf_raise_for_status, logging
|
30 |
+
|
31 |
+
|
32 |
+
logger = logging.get_logger(__name__)
|
33 |
+
|
34 |
+
|
35 |
+
class LfsCommands(BaseHuggingfaceCLICommand):
|
36 |
+
"""
|
37 |
+
Implementation of a custom transfer agent for the transfer type "multipart"
|
38 |
+
for git-lfs. This lets users upload large files >5GB 🔥. Spec for LFS custom
|
39 |
+
transfer agent is:
|
40 |
+
https://github.com/git-lfs/git-lfs/blob/master/docs/custom-transfers.md
|
41 |
+
|
42 |
+
This introduces two commands to the CLI:
|
43 |
+
|
44 |
+
1. $ huggingface-cli lfs-enable-largefiles
|
45 |
+
|
46 |
+
This should be executed once for each model repo that contains a model file
|
47 |
+
>5GB. It's documented in the error message you get if you just try to git
|
48 |
+
push a 5GB file without having enabled it before.
|
49 |
+
|
50 |
+
2. $ huggingface-cli lfs-multipart-upload
|
51 |
+
|
52 |
+
This command is called by lfs directly and is not meant to be called by the
|
53 |
+
user.
|
54 |
+
"""
|
55 |
+
|
56 |
+
@staticmethod
|
57 |
+
def register_subcommand(parser: _SubParsersAction):
|
58 |
+
enable_parser = parser.add_parser(
|
59 |
+
"lfs-enable-largefiles", help="Configure your repository to enable upload of files > 5GB."
|
60 |
+
)
|
61 |
+
enable_parser.add_argument("path", type=str, help="Local path to repository you want to configure.")
|
62 |
+
enable_parser.set_defaults(func=lambda args: LfsEnableCommand(args))
|
63 |
+
|
64 |
+
# Command will get called by git-lfs, do not call it directly.
|
65 |
+
upload_parser = parser.add_parser(LFS_MULTIPART_UPLOAD_COMMAND, add_help=False)
|
66 |
+
upload_parser.set_defaults(func=lambda args: LfsUploadCommand(args))
|
67 |
+
|
68 |
+
|
69 |
+
class LfsEnableCommand:
|
70 |
+
def __init__(self, args):
|
71 |
+
self.args = args
|
72 |
+
|
73 |
+
def run(self):
|
74 |
+
local_path = os.path.abspath(self.args.path)
|
75 |
+
if not os.path.isdir(local_path):
|
76 |
+
print("This does not look like a valid git repo.")
|
77 |
+
exit(1)
|
78 |
+
subprocess.run(
|
79 |
+
"git config lfs.customtransfer.multipart.path huggingface-cli".split(),
|
80 |
+
check=True,
|
81 |
+
cwd=local_path,
|
82 |
+
)
|
83 |
+
subprocess.run(
|
84 |
+
f"git config lfs.customtransfer.multipart.args {LFS_MULTIPART_UPLOAD_COMMAND}".split(),
|
85 |
+
check=True,
|
86 |
+
cwd=local_path,
|
87 |
+
)
|
88 |
+
print("Local repo set up for largefiles")
|
89 |
+
|
90 |
+
|
91 |
+
def write_msg(msg: Dict):
|
92 |
+
"""Write out the message in Line delimited JSON."""
|
93 |
+
msg_str = json.dumps(msg) + "\n"
|
94 |
+
sys.stdout.write(msg_str)
|
95 |
+
sys.stdout.flush()
|
96 |
+
|
97 |
+
|
98 |
+
def read_msg() -> Optional[Dict]:
|
99 |
+
"""Read Line delimited JSON from stdin."""
|
100 |
+
msg = json.loads(sys.stdin.readline().strip())
|
101 |
+
|
102 |
+
if "terminate" in (msg.get("type"), msg.get("event")):
|
103 |
+
# terminate message received
|
104 |
+
return None
|
105 |
+
|
106 |
+
if msg.get("event") not in ("download", "upload"):
|
107 |
+
logger.critical("Received unexpected message")
|
108 |
+
sys.exit(1)
|
109 |
+
|
110 |
+
return msg
|
111 |
+
|
112 |
+
|
113 |
+
class LfsUploadCommand:
|
114 |
+
def __init__(self, args) -> None:
|
115 |
+
self.args = args
|
116 |
+
|
117 |
+
def run(self) -> None:
|
118 |
+
# Immediately after invoking a custom transfer process, git-lfs
|
119 |
+
# sends initiation data to the process over stdin.
|
120 |
+
# This tells the process useful information about the configuration.
|
121 |
+
init_msg = json.loads(sys.stdin.readline().strip())
|
122 |
+
if not (init_msg.get("event") == "init" and init_msg.get("operation") == "upload"):
|
123 |
+
write_msg({"error": {"code": 32, "message": "Wrong lfs init operation"}})
|
124 |
+
sys.exit(1)
|
125 |
+
|
126 |
+
# The transfer process should use the information it needs from the
|
127 |
+
# initiation structure, and also perform any one-off setup tasks it
|
128 |
+
# needs to do. It should then respond on stdout with a simple empty
|
129 |
+
# confirmation structure, as follows:
|
130 |
+
write_msg({})
|
131 |
+
|
132 |
+
# After the initiation exchange, git-lfs will send any number of
|
133 |
+
# transfer requests to the stdin of the transfer process, in a serial sequence.
|
134 |
+
while True:
|
135 |
+
msg = read_msg()
|
136 |
+
if msg is None:
|
137 |
+
# When all transfers have been processed, git-lfs will send
|
138 |
+
# a terminate event to the stdin of the transfer process.
|
139 |
+
# On receiving this message the transfer process should
|
140 |
+
# clean up and terminate. No response is expected.
|
141 |
+
sys.exit(0)
|
142 |
+
|
143 |
+
oid = msg["oid"]
|
144 |
+
filepath = msg["path"]
|
145 |
+
completion_url = msg["action"]["href"]
|
146 |
+
header = msg["action"]["header"]
|
147 |
+
chunk_size = int(header.pop("chunk_size"))
|
148 |
+
presigned_urls: List[str] = list(header.values())
|
149 |
+
|
150 |
+
# Send a "started" progress event to allow other workers to start.
|
151 |
+
# Otherwise they're delayed until first "progress" event is reported,
|
152 |
+
# i.e. after the first 5GB by default (!)
|
153 |
+
write_msg(
|
154 |
+
{
|
155 |
+
"event": "progress",
|
156 |
+
"oid": oid,
|
157 |
+
"bytesSoFar": 1,
|
158 |
+
"bytesSinceLast": 0,
|
159 |
+
}
|
160 |
+
)
|
161 |
+
|
162 |
+
parts = []
|
163 |
+
with open(filepath, "rb") as file:
|
164 |
+
for i, presigned_url in enumerate(presigned_urls):
|
165 |
+
with SliceFileObj(
|
166 |
+
file,
|
167 |
+
seek_from=i * chunk_size,
|
168 |
+
read_limit=chunk_size,
|
169 |
+
) as data:
|
170 |
+
r = get_session().put(presigned_url, data=data)
|
171 |
+
hf_raise_for_status(r)
|
172 |
+
parts.append(
|
173 |
+
{
|
174 |
+
"etag": r.headers.get("etag"),
|
175 |
+
"partNumber": i + 1,
|
176 |
+
}
|
177 |
+
)
|
178 |
+
# In order to support progress reporting while data is uploading / downloading,
|
179 |
+
# the transfer process should post messages to stdout
|
180 |
+
write_msg(
|
181 |
+
{
|
182 |
+
"event": "progress",
|
183 |
+
"oid": oid,
|
184 |
+
"bytesSoFar": (i + 1) * chunk_size,
|
185 |
+
"bytesSinceLast": chunk_size,
|
186 |
+
}
|
187 |
+
)
|
188 |
+
# Not precise but that's ok.
|
189 |
+
|
190 |
+
r = get_session().post(
|
191 |
+
completion_url,
|
192 |
+
json={
|
193 |
+
"oid": oid,
|
194 |
+
"parts": parts,
|
195 |
+
},
|
196 |
+
)
|
197 |
+
hf_raise_for_status(r)
|
198 |
+
|
199 |
+
write_msg({"event": "complete", "oid": oid})
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/scan_cache.py
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022-present, the HuggingFace Inc. team.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""Contains command to scan the HF cache directory.
|
16 |
+
|
17 |
+
Usage:
|
18 |
+
huggingface-cli scan-cache
|
19 |
+
huggingface-cli scan-cache -v
|
20 |
+
huggingface-cli scan-cache -vvv
|
21 |
+
huggingface-cli scan-cache --dir ~/.cache/huggingface/hub
|
22 |
+
"""
|
23 |
+
|
24 |
+
import time
|
25 |
+
from argparse import Namespace, _SubParsersAction
|
26 |
+
from typing import Optional
|
27 |
+
|
28 |
+
from ..utils import CacheNotFound, HFCacheInfo, scan_cache_dir
|
29 |
+
from . import BaseHuggingfaceCLICommand
|
30 |
+
from ._cli_utils import ANSI, tabulate
|
31 |
+
|
32 |
+
|
33 |
+
class ScanCacheCommand(BaseHuggingfaceCLICommand):
|
34 |
+
@staticmethod
|
35 |
+
def register_subcommand(parser: _SubParsersAction):
|
36 |
+
scan_cache_parser = parser.add_parser("scan-cache", help="Scan cache directory.")
|
37 |
+
|
38 |
+
scan_cache_parser.add_argument(
|
39 |
+
"--dir",
|
40 |
+
type=str,
|
41 |
+
default=None,
|
42 |
+
help="cache directory to scan (optional). Default to the default HuggingFace cache.",
|
43 |
+
)
|
44 |
+
scan_cache_parser.add_argument(
|
45 |
+
"-v",
|
46 |
+
"--verbose",
|
47 |
+
action="count",
|
48 |
+
default=0,
|
49 |
+
help="show a more verbose output",
|
50 |
+
)
|
51 |
+
scan_cache_parser.set_defaults(func=ScanCacheCommand)
|
52 |
+
|
53 |
+
def __init__(self, args: Namespace) -> None:
|
54 |
+
self.verbosity: int = args.verbose
|
55 |
+
self.cache_dir: Optional[str] = args.dir
|
56 |
+
|
57 |
+
def run(self):
|
58 |
+
try:
|
59 |
+
t0 = time.time()
|
60 |
+
hf_cache_info = scan_cache_dir(self.cache_dir)
|
61 |
+
t1 = time.time()
|
62 |
+
except CacheNotFound as exc:
|
63 |
+
cache_dir = exc.cache_dir
|
64 |
+
print(f"Cache directory not found: {cache_dir}")
|
65 |
+
return
|
66 |
+
|
67 |
+
self._print_hf_cache_info_as_table(hf_cache_info)
|
68 |
+
|
69 |
+
print(
|
70 |
+
f"\nDone in {round(t1-t0,1)}s. Scanned {len(hf_cache_info.repos)} repo(s)"
|
71 |
+
f" for a total of {ANSI.red(hf_cache_info.size_on_disk_str)}."
|
72 |
+
)
|
73 |
+
if len(hf_cache_info.warnings) > 0:
|
74 |
+
message = f"Got {len(hf_cache_info.warnings)} warning(s) while scanning."
|
75 |
+
if self.verbosity >= 3:
|
76 |
+
print(ANSI.gray(message))
|
77 |
+
for warning in hf_cache_info.warnings:
|
78 |
+
print(ANSI.gray(warning))
|
79 |
+
else:
|
80 |
+
print(ANSI.gray(message + " Use -vvv to print details."))
|
81 |
+
|
82 |
+
def _print_hf_cache_info_as_table(self, hf_cache_info: HFCacheInfo) -> None:
|
83 |
+
if self.verbosity == 0:
|
84 |
+
print(
|
85 |
+
tabulate(
|
86 |
+
rows=[
|
87 |
+
[
|
88 |
+
repo.repo_id,
|
89 |
+
repo.repo_type,
|
90 |
+
"{:>12}".format(repo.size_on_disk_str),
|
91 |
+
repo.nb_files,
|
92 |
+
repo.last_accessed_str,
|
93 |
+
repo.last_modified_str,
|
94 |
+
", ".join(sorted(repo.refs)),
|
95 |
+
str(repo.repo_path),
|
96 |
+
]
|
97 |
+
for repo in sorted(hf_cache_info.repos, key=lambda repo: repo.repo_path)
|
98 |
+
],
|
99 |
+
headers=[
|
100 |
+
"REPO ID",
|
101 |
+
"REPO TYPE",
|
102 |
+
"SIZE ON DISK",
|
103 |
+
"NB FILES",
|
104 |
+
"LAST_ACCESSED",
|
105 |
+
"LAST_MODIFIED",
|
106 |
+
"REFS",
|
107 |
+
"LOCAL PATH",
|
108 |
+
],
|
109 |
+
)
|
110 |
+
)
|
111 |
+
else:
|
112 |
+
print(
|
113 |
+
tabulate(
|
114 |
+
rows=[
|
115 |
+
[
|
116 |
+
repo.repo_id,
|
117 |
+
repo.repo_type,
|
118 |
+
revision.commit_hash,
|
119 |
+
"{:>12}".format(revision.size_on_disk_str),
|
120 |
+
revision.nb_files,
|
121 |
+
revision.last_modified_str,
|
122 |
+
", ".join(sorted(revision.refs)),
|
123 |
+
str(revision.snapshot_path),
|
124 |
+
]
|
125 |
+
for repo in sorted(hf_cache_info.repos, key=lambda repo: repo.repo_path)
|
126 |
+
for revision in sorted(repo.revisions, key=lambda revision: revision.commit_hash)
|
127 |
+
],
|
128 |
+
headers=[
|
129 |
+
"REPO ID",
|
130 |
+
"REPO TYPE",
|
131 |
+
"REVISION",
|
132 |
+
"SIZE ON DISK",
|
133 |
+
"NB FILES",
|
134 |
+
"LAST_MODIFIED",
|
135 |
+
"REFS",
|
136 |
+
"LOCAL PATH",
|
137 |
+
],
|
138 |
+
)
|
139 |
+
)
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/upload.py
ADDED
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2023-present, the HuggingFace Inc. team.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""Contains command to upload a repo or file with the CLI.
|
16 |
+
|
17 |
+
Usage:
|
18 |
+
# Upload file (implicit)
|
19 |
+
huggingface-cli upload my-cool-model ./my-cool-model.safetensors
|
20 |
+
|
21 |
+
# Upload file (explicit)
|
22 |
+
huggingface-cli upload my-cool-model ./my-cool-model.safetensors model.safetensors
|
23 |
+
|
24 |
+
# Upload directory (implicit). If `my-cool-model/` is a directory it will be uploaded, otherwise an exception is raised.
|
25 |
+
huggingface-cli upload my-cool-model
|
26 |
+
|
27 |
+
# Upload directory (explicit)
|
28 |
+
huggingface-cli upload my-cool-model ./models/my-cool-model .
|
29 |
+
|
30 |
+
# Upload filtered directory (example: tensorboard logs except for the last run)
|
31 |
+
huggingface-cli upload my-cool-model ./model/training /logs --include "*.tfevents.*" --exclude "*20230905*"
|
32 |
+
|
33 |
+
# Upload private dataset
|
34 |
+
huggingface-cli upload Wauplin/my-cool-dataset ./data . --repo-type=dataset --private
|
35 |
+
|
36 |
+
# Upload with token
|
37 |
+
huggingface-cli upload Wauplin/my-cool-model --token=hf_****
|
38 |
+
|
39 |
+
# Sync local Space with Hub (upload new files, delete removed files)
|
40 |
+
huggingface-cli upload Wauplin/space-example --repo-type=space --exclude="/logs/*" --delete="*" --commit-message="Sync local Space with Hub"
|
41 |
+
|
42 |
+
# Schedule commits every 30 minutes
|
43 |
+
huggingface-cli upload Wauplin/my-cool-model --every=30
|
44 |
+
"""
|
45 |
+
|
46 |
+
import os
|
47 |
+
import time
|
48 |
+
import warnings
|
49 |
+
from argparse import Namespace, _SubParsersAction
|
50 |
+
from typing import List, Optional
|
51 |
+
|
52 |
+
from huggingface_hub import logging
|
53 |
+
from huggingface_hub._commit_scheduler import CommitScheduler
|
54 |
+
from huggingface_hub.commands import BaseHuggingfaceCLICommand
|
55 |
+
from huggingface_hub.constants import HF_HUB_ENABLE_HF_TRANSFER
|
56 |
+
from huggingface_hub.hf_api import HfApi
|
57 |
+
from huggingface_hub.utils import RevisionNotFoundError, disable_progress_bars, enable_progress_bars
|
58 |
+
|
59 |
+
|
60 |
+
logger = logging.get_logger(__name__)
|
61 |
+
|
62 |
+
|
63 |
+
class UploadCommand(BaseHuggingfaceCLICommand):
|
64 |
+
@staticmethod
|
65 |
+
def register_subcommand(parser: _SubParsersAction):
|
66 |
+
upload_parser = parser.add_parser("upload", help="Upload a file or a folder to a repo on the Hub")
|
67 |
+
upload_parser.add_argument(
|
68 |
+
"repo_id", type=str, help="The ID of the repo to upload to (e.g. `username/repo-name`)."
|
69 |
+
)
|
70 |
+
upload_parser.add_argument(
|
71 |
+
"local_path", nargs="?", help="Local path to the file or folder to upload. Defaults to current directory."
|
72 |
+
)
|
73 |
+
upload_parser.add_argument(
|
74 |
+
"path_in_repo",
|
75 |
+
nargs="?",
|
76 |
+
help="Path of the file or folder in the repo. Defaults to the relative path of the file or folder.",
|
77 |
+
)
|
78 |
+
upload_parser.add_argument(
|
79 |
+
"--repo-type",
|
80 |
+
choices=["model", "dataset", "space"],
|
81 |
+
default="model",
|
82 |
+
help="Type of the repo to upload to (e.g. `dataset`).",
|
83 |
+
)
|
84 |
+
upload_parser.add_argument(
|
85 |
+
"--revision",
|
86 |
+
type=str,
|
87 |
+
help=(
|
88 |
+
"An optional Git revision to push to. It can be a branch name or a PR reference. If revision does not"
|
89 |
+
" exist and `--create-pr` is not set, a branch will be automatically created."
|
90 |
+
),
|
91 |
+
)
|
92 |
+
upload_parser.add_argument(
|
93 |
+
"--private",
|
94 |
+
action="store_true",
|
95 |
+
help=(
|
96 |
+
"Whether to create a private repo if repo doesn't exist on the Hub. Ignored if the repo already"
|
97 |
+
" exists."
|
98 |
+
),
|
99 |
+
)
|
100 |
+
upload_parser.add_argument("--include", nargs="*", type=str, help="Glob patterns to match files to upload.")
|
101 |
+
upload_parser.add_argument(
|
102 |
+
"--exclude", nargs="*", type=str, help="Glob patterns to exclude from files to upload."
|
103 |
+
)
|
104 |
+
upload_parser.add_argument(
|
105 |
+
"--delete",
|
106 |
+
nargs="*",
|
107 |
+
type=str,
|
108 |
+
help="Glob patterns for file to be deleted from the repo while committing.",
|
109 |
+
)
|
110 |
+
upload_parser.add_argument(
|
111 |
+
"--commit-message", type=str, help="The summary / title / first line of the generated commit."
|
112 |
+
)
|
113 |
+
upload_parser.add_argument("--commit-description", type=str, help="The description of the generated commit.")
|
114 |
+
upload_parser.add_argument(
|
115 |
+
"--create-pr", action="store_true", help="Whether to upload content as a new Pull Request."
|
116 |
+
)
|
117 |
+
upload_parser.add_argument(
|
118 |
+
"--every",
|
119 |
+
type=float,
|
120 |
+
help="If set, a background job is scheduled to create commits every `every` minutes.",
|
121 |
+
)
|
122 |
+
upload_parser.add_argument(
|
123 |
+
"--token", type=str, help="A User Access Token generated from https://huggingface.co/settings/tokens"
|
124 |
+
)
|
125 |
+
upload_parser.add_argument(
|
126 |
+
"--quiet",
|
127 |
+
action="store_true",
|
128 |
+
help="If True, progress bars are disabled and only the path to the uploaded files is printed.",
|
129 |
+
)
|
130 |
+
upload_parser.set_defaults(func=UploadCommand)
|
131 |
+
|
132 |
+
def __init__(self, args: Namespace) -> None:
|
133 |
+
self.repo_id: str = args.repo_id
|
134 |
+
self.repo_type: Optional[str] = args.repo_type
|
135 |
+
self.revision: Optional[str] = args.revision
|
136 |
+
self.private: bool = args.private
|
137 |
+
|
138 |
+
self.include: Optional[List[str]] = args.include
|
139 |
+
self.exclude: Optional[List[str]] = args.exclude
|
140 |
+
self.delete: Optional[List[str]] = args.delete
|
141 |
+
|
142 |
+
self.commit_message: Optional[str] = args.commit_message
|
143 |
+
self.commit_description: Optional[str] = args.commit_description
|
144 |
+
self.create_pr: bool = args.create_pr
|
145 |
+
self.api: HfApi = HfApi(token=args.token, library_name="huggingface-cli")
|
146 |
+
self.quiet: bool = args.quiet # disable warnings and progress bars
|
147 |
+
|
148 |
+
# Check `--every` is valid
|
149 |
+
if args.every is not None and args.every <= 0:
|
150 |
+
raise ValueError(f"`every` must be a positive value (got '{args.every}')")
|
151 |
+
self.every: Optional[float] = args.every
|
152 |
+
|
153 |
+
# Resolve `local_path` and `path_in_repo`
|
154 |
+
repo_name: str = args.repo_id.split("/")[-1] # e.g. "Wauplin/my-cool-model" => "my-cool-model"
|
155 |
+
self.local_path: str
|
156 |
+
self.path_in_repo: str
|
157 |
+
if args.local_path is None and os.path.isfile(repo_name):
|
158 |
+
# Implicit case 1: user provided only a repo_id which happen to be a local file as well => upload it with same name
|
159 |
+
self.local_path = repo_name
|
160 |
+
self.path_in_repo = repo_name
|
161 |
+
elif args.local_path is None and os.path.isdir(repo_name):
|
162 |
+
# Implicit case 2: user provided only a repo_id which happen to be a local folder as well => upload it at root
|
163 |
+
self.local_path = repo_name
|
164 |
+
self.path_in_repo = "."
|
165 |
+
elif args.local_path is None:
|
166 |
+
# Implicit case 3: user provided only a repo_id that does not match a local file or folder
|
167 |
+
# => the user must explicitly provide a local_path => raise exception
|
168 |
+
raise ValueError(f"'{repo_name}' is not a local file or folder. Please set `local_path` explicitly.")
|
169 |
+
elif args.path_in_repo is None and os.path.isfile(args.local_path):
|
170 |
+
# Explicit local path to file, no path in repo => upload it at root with same name
|
171 |
+
self.local_path = args.local_path
|
172 |
+
self.path_in_repo = os.path.basename(args.local_path)
|
173 |
+
elif args.path_in_repo is None:
|
174 |
+
# Explicit local path to folder, no path in repo => upload at root
|
175 |
+
self.local_path = args.local_path
|
176 |
+
self.path_in_repo = "."
|
177 |
+
else:
|
178 |
+
# Finally, if both paths are explicit
|
179 |
+
self.local_path = args.local_path
|
180 |
+
self.path_in_repo = args.path_in_repo
|
181 |
+
|
182 |
+
def run(self) -> None:
|
183 |
+
if self.quiet:
|
184 |
+
disable_progress_bars()
|
185 |
+
with warnings.catch_warnings():
|
186 |
+
warnings.simplefilter("ignore")
|
187 |
+
print(self._upload())
|
188 |
+
enable_progress_bars()
|
189 |
+
else:
|
190 |
+
logging.set_verbosity_info()
|
191 |
+
print(self._upload())
|
192 |
+
logging.set_verbosity_warning()
|
193 |
+
|
194 |
+
def _upload(self) -> str:
|
195 |
+
if os.path.isfile(self.local_path):
|
196 |
+
if self.include is not None and len(self.include) > 0:
|
197 |
+
warnings.warn("Ignoring `--include` since a single file is uploaded.")
|
198 |
+
if self.exclude is not None and len(self.exclude) > 0:
|
199 |
+
warnings.warn("Ignoring `--exclude` since a single file is uploaded.")
|
200 |
+
if self.delete is not None and len(self.delete) > 0:
|
201 |
+
warnings.warn("Ignoring `--delete` since a single file is uploaded.")
|
202 |
+
|
203 |
+
if not HF_HUB_ENABLE_HF_TRANSFER:
|
204 |
+
logger.info(
|
205 |
+
"Consider using `hf_transfer` for faster uploads. This solution comes with some limitations. See"
|
206 |
+
" https://huggingface.co/docs/huggingface_hub/hf_transfer for more details."
|
207 |
+
)
|
208 |
+
|
209 |
+
# Schedule commits if `every` is set
|
210 |
+
if self.every is not None:
|
211 |
+
if os.path.isfile(self.local_path):
|
212 |
+
# If file => watch entire folder + use allow_patterns
|
213 |
+
folder_path = os.path.dirname(self.local_path)
|
214 |
+
path_in_repo = (
|
215 |
+
self.path_in_repo[: -len(self.local_path)] # remove filename from path_in_repo
|
216 |
+
if self.path_in_repo.endswith(self.local_path)
|
217 |
+
else self.path_in_repo
|
218 |
+
)
|
219 |
+
allow_patterns = [self.local_path]
|
220 |
+
ignore_patterns = []
|
221 |
+
else:
|
222 |
+
folder_path = self.local_path
|
223 |
+
path_in_repo = self.path_in_repo
|
224 |
+
allow_patterns = self.include or []
|
225 |
+
ignore_patterns = self.exclude or []
|
226 |
+
if self.delete is not None and len(self.delete) > 0:
|
227 |
+
warnings.warn("Ignoring `--delete` when uploading with scheduled commits.")
|
228 |
+
|
229 |
+
scheduler = CommitScheduler(
|
230 |
+
folder_path=folder_path,
|
231 |
+
repo_id=self.repo_id,
|
232 |
+
repo_type=self.repo_type,
|
233 |
+
revision=self.revision,
|
234 |
+
allow_patterns=allow_patterns,
|
235 |
+
ignore_patterns=ignore_patterns,
|
236 |
+
path_in_repo=path_in_repo,
|
237 |
+
private=self.private,
|
238 |
+
every=self.every,
|
239 |
+
hf_api=self.api,
|
240 |
+
)
|
241 |
+
print(f"Scheduling commits every {self.every} minutes to {scheduler.repo_id}.")
|
242 |
+
try: # Block main thread until KeyboardInterrupt
|
243 |
+
while True:
|
244 |
+
time.sleep(100)
|
245 |
+
except KeyboardInterrupt:
|
246 |
+
scheduler.stop()
|
247 |
+
return "Stopped scheduled commits."
|
248 |
+
|
249 |
+
# Otherwise, create repo and proceed with the upload
|
250 |
+
if not os.path.isfile(self.local_path) and not os.path.isdir(self.local_path):
|
251 |
+
raise FileNotFoundError(f"No such file or directory: '{self.local_path}'.")
|
252 |
+
repo_id = self.api.create_repo(
|
253 |
+
repo_id=self.repo_id,
|
254 |
+
repo_type=self.repo_type,
|
255 |
+
exist_ok=True,
|
256 |
+
private=self.private,
|
257 |
+
space_sdk="gradio" if self.repo_type == "space" else None,
|
258 |
+
# ^ We don't want it to fail when uploading to a Space => let's set Gradio by default.
|
259 |
+
# ^ I'd rather not add CLI args to set it explicitly as we already have `huggingface-cli repo create` for that.
|
260 |
+
).repo_id
|
261 |
+
|
262 |
+
# Check if branch already exists and if not, create it
|
263 |
+
if self.revision is not None and not self.create_pr:
|
264 |
+
try:
|
265 |
+
self.api.repo_info(repo_id=repo_id, repo_type=self.repo_type, revision=self.revision)
|
266 |
+
except RevisionNotFoundError:
|
267 |
+
logger.info(f"Branch '{self.revision}' not found. Creating it...")
|
268 |
+
self.api.create_branch(repo_id=repo_id, repo_type=self.repo_type, branch=self.revision, exist_ok=True)
|
269 |
+
# ^ `exist_ok=True` to avoid race concurrency issues
|
270 |
+
|
271 |
+
# File-based upload
|
272 |
+
if os.path.isfile(self.local_path):
|
273 |
+
return self.api.upload_file(
|
274 |
+
path_or_fileobj=self.local_path,
|
275 |
+
path_in_repo=self.path_in_repo,
|
276 |
+
repo_id=repo_id,
|
277 |
+
repo_type=self.repo_type,
|
278 |
+
revision=self.revision,
|
279 |
+
commit_message=self.commit_message,
|
280 |
+
commit_description=self.commit_description,
|
281 |
+
create_pr=self.create_pr,
|
282 |
+
)
|
283 |
+
|
284 |
+
# Folder-based upload
|
285 |
+
else:
|
286 |
+
return self.api.upload_folder(
|
287 |
+
folder_path=self.local_path,
|
288 |
+
path_in_repo=self.path_in_repo,
|
289 |
+
repo_id=repo_id,
|
290 |
+
repo_type=self.repo_type,
|
291 |
+
revision=self.revision,
|
292 |
+
commit_message=self.commit_message,
|
293 |
+
commit_description=self.commit_description,
|
294 |
+
create_pr=self.create_pr,
|
295 |
+
allow_patterns=self.include,
|
296 |
+
ignore_patterns=self.exclude,
|
297 |
+
delete_patterns=self.delete,
|
298 |
+
)
|
venv/lib/python3.10/site-packages/huggingface_hub/commands/user.py
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2020 The HuggingFace Team. All rights reserved.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
import subprocess
|
15 |
+
from argparse import _SubParsersAction
|
16 |
+
|
17 |
+
from requests.exceptions import HTTPError
|
18 |
+
|
19 |
+
from huggingface_hub.commands import BaseHuggingfaceCLICommand
|
20 |
+
from huggingface_hub.constants import (
|
21 |
+
ENDPOINT,
|
22 |
+
REPO_TYPES,
|
23 |
+
REPO_TYPES_URL_PREFIXES,
|
24 |
+
SPACES_SDK_TYPES,
|
25 |
+
)
|
26 |
+
from huggingface_hub.hf_api import HfApi
|
27 |
+
|
28 |
+
from .._login import ( # noqa: F401 # for backward compatibility # noqa: F401 # for backward compatibility
|
29 |
+
NOTEBOOK_LOGIN_PASSWORD_HTML,
|
30 |
+
NOTEBOOK_LOGIN_TOKEN_HTML_END,
|
31 |
+
NOTEBOOK_LOGIN_TOKEN_HTML_START,
|
32 |
+
login,
|
33 |
+
logout,
|
34 |
+
notebook_login,
|
35 |
+
)
|
36 |
+
from ..utils import get_token
|
37 |
+
from ._cli_utils import ANSI
|
38 |
+
|
39 |
+
|
40 |
+
class UserCommands(BaseHuggingfaceCLICommand):
|
41 |
+
@staticmethod
|
42 |
+
def register_subcommand(parser: _SubParsersAction):
|
43 |
+
login_parser = parser.add_parser("login", help="Log in using a token from huggingface.co/settings/tokens")
|
44 |
+
login_parser.add_argument(
|
45 |
+
"--token",
|
46 |
+
type=str,
|
47 |
+
help="Token generated from https://huggingface.co/settings/tokens",
|
48 |
+
)
|
49 |
+
login_parser.add_argument(
|
50 |
+
"--add-to-git-credential",
|
51 |
+
action="store_true",
|
52 |
+
help="Optional: Save token to git credential helper.",
|
53 |
+
)
|
54 |
+
login_parser.set_defaults(func=lambda args: LoginCommand(args))
|
55 |
+
whoami_parser = parser.add_parser("whoami", help="Find out which huggingface.co account you are logged in as.")
|
56 |
+
whoami_parser.set_defaults(func=lambda args: WhoamiCommand(args))
|
57 |
+
logout_parser = parser.add_parser("logout", help="Log out")
|
58 |
+
logout_parser.set_defaults(func=lambda args: LogoutCommand(args))
|
59 |
+
|
60 |
+
# new system: git-based repo system
|
61 |
+
repo_parser = parser.add_parser("repo", help="{create} Commands to interact with your huggingface.co repos.")
|
62 |
+
repo_subparsers = repo_parser.add_subparsers(help="huggingface.co repos related commands")
|
63 |
+
repo_create_parser = repo_subparsers.add_parser("create", help="Create a new repo on huggingface.co")
|
64 |
+
repo_create_parser.add_argument(
|
65 |
+
"name",
|
66 |
+
type=str,
|
67 |
+
help="Name for your repo. Will be namespaced under your username to build the repo id.",
|
68 |
+
)
|
69 |
+
repo_create_parser.add_argument(
|
70 |
+
"--type",
|
71 |
+
type=str,
|
72 |
+
help='Optional: repo_type: set to "dataset" or "space" if creating a dataset or space, default is model.',
|
73 |
+
)
|
74 |
+
repo_create_parser.add_argument("--organization", type=str, help="Optional: organization namespace.")
|
75 |
+
repo_create_parser.add_argument(
|
76 |
+
"--space_sdk",
|
77 |
+
type=str,
|
78 |
+
help='Optional: Hugging Face Spaces SDK type. Required when --type is set to "space".',
|
79 |
+
choices=SPACES_SDK_TYPES,
|
80 |
+
)
|
81 |
+
repo_create_parser.add_argument(
|
82 |
+
"-y",
|
83 |
+
"--yes",
|
84 |
+
action="store_true",
|
85 |
+
help="Optional: answer Yes to the prompt",
|
86 |
+
)
|
87 |
+
repo_create_parser.set_defaults(func=lambda args: RepoCreateCommand(args))
|
88 |
+
|
89 |
+
|
90 |
+
class BaseUserCommand:
|
91 |
+
def __init__(self, args):
|
92 |
+
self.args = args
|
93 |
+
self._api = HfApi()
|
94 |
+
|
95 |
+
|
96 |
+
class LoginCommand(BaseUserCommand):
|
97 |
+
def run(self):
|
98 |
+
login(token=self.args.token, add_to_git_credential=self.args.add_to_git_credential)
|
99 |
+
|
100 |
+
|
101 |
+
class LogoutCommand(BaseUserCommand):
|
102 |
+
def run(self):
|
103 |
+
logout()
|
104 |
+
|
105 |
+
|
106 |
+
class WhoamiCommand(BaseUserCommand):
|
107 |
+
def run(self):
|
108 |
+
token = get_token()
|
109 |
+
if token is None:
|
110 |
+
print("Not logged in")
|
111 |
+
exit()
|
112 |
+
try:
|
113 |
+
info = self._api.whoami(token)
|
114 |
+
print(info["name"])
|
115 |
+
orgs = [org["name"] for org in info["orgs"]]
|
116 |
+
if orgs:
|
117 |
+
print(ANSI.bold("orgs: "), ",".join(orgs))
|
118 |
+
|
119 |
+
if ENDPOINT != "https://huggingface.co":
|
120 |
+
print(f"Authenticated through private endpoint: {ENDPOINT}")
|
121 |
+
except HTTPError as e:
|
122 |
+
print(e)
|
123 |
+
print(ANSI.red(e.response.text))
|
124 |
+
exit(1)
|
125 |
+
|
126 |
+
|
127 |
+
class RepoCreateCommand(BaseUserCommand):
|
128 |
+
def run(self):
|
129 |
+
token = get_token()
|
130 |
+
if token is None:
|
131 |
+
print("Not logged in")
|
132 |
+
exit(1)
|
133 |
+
try:
|
134 |
+
stdout = subprocess.check_output(["git", "--version"]).decode("utf-8")
|
135 |
+
print(ANSI.gray(stdout.strip()))
|
136 |
+
except FileNotFoundError:
|
137 |
+
print("Looks like you do not have git installed, please install.")
|
138 |
+
|
139 |
+
try:
|
140 |
+
stdout = subprocess.check_output(["git-lfs", "--version"]).decode("utf-8")
|
141 |
+
print(ANSI.gray(stdout.strip()))
|
142 |
+
except FileNotFoundError:
|
143 |
+
print(
|
144 |
+
ANSI.red(
|
145 |
+
"Looks like you do not have git-lfs installed, please install."
|
146 |
+
" You can install from https://git-lfs.github.com/."
|
147 |
+
" Then run `git lfs install` (you only have to do this once)."
|
148 |
+
)
|
149 |
+
)
|
150 |
+
print("")
|
151 |
+
|
152 |
+
user = self._api.whoami(token)["name"]
|
153 |
+
namespace = self.args.organization if self.args.organization is not None else user
|
154 |
+
|
155 |
+
repo_id = f"{namespace}/{self.args.name}"
|
156 |
+
|
157 |
+
if self.args.type not in REPO_TYPES:
|
158 |
+
print("Invalid repo --type")
|
159 |
+
exit(1)
|
160 |
+
|
161 |
+
if self.args.type in REPO_TYPES_URL_PREFIXES:
|
162 |
+
prefixed_repo_id = REPO_TYPES_URL_PREFIXES[self.args.type] + repo_id
|
163 |
+
else:
|
164 |
+
prefixed_repo_id = repo_id
|
165 |
+
|
166 |
+
print(f"You are about to create {ANSI.bold(prefixed_repo_id)}")
|
167 |
+
|
168 |
+
if not self.args.yes:
|
169 |
+
choice = input("Proceed? [Y/n] ").lower()
|
170 |
+
if not (choice == "" or choice == "y" or choice == "yes"):
|
171 |
+
print("Abort")
|
172 |
+
exit()
|
173 |
+
try:
|
174 |
+
url = self._api.create_repo(
|
175 |
+
repo_id=repo_id,
|
176 |
+
token=token,
|
177 |
+
repo_type=self.args.type,
|
178 |
+
space_sdk=self.args.space_sdk,
|
179 |
+
)
|
180 |
+
except HTTPError as e:
|
181 |
+
print(e)
|
182 |
+
print(ANSI.red(e.response.text))
|
183 |
+
exit(1)
|
184 |
+
print("\nYour repo now lives at:")
|
185 |
+
print(f" {ANSI.bold(url)}")
|
186 |
+
print("\nYou can clone it locally with the command below, and commit/push as usual.")
|
187 |
+
print(f"\n git clone {url}")
|
188 |
+
print("")
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__init__.py
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is auto-generated by `utils/generate_inference_types.py`.
|
2 |
+
# Do not modify it manually.
|
3 |
+
#
|
4 |
+
# ruff: noqa: F401
|
5 |
+
|
6 |
+
from .audio_classification import (
|
7 |
+
AudioClassificationInput,
|
8 |
+
AudioClassificationOutputElement,
|
9 |
+
AudioClassificationParameters,
|
10 |
+
)
|
11 |
+
from .audio_to_audio import AudioToAudioInput, AudioToAudioOutputElement
|
12 |
+
from .automatic_speech_recognition import (
|
13 |
+
AutomaticSpeechRecognitionGenerationParameters,
|
14 |
+
AutomaticSpeechRecognitionInput,
|
15 |
+
AutomaticSpeechRecognitionOutput,
|
16 |
+
AutomaticSpeechRecognitionOutputChunk,
|
17 |
+
AutomaticSpeechRecognitionParameters,
|
18 |
+
)
|
19 |
+
from .base import BaseInferenceType
|
20 |
+
from .chat_completion import (
|
21 |
+
ChatCompletionInput,
|
22 |
+
ChatCompletionInputMessage,
|
23 |
+
ChatCompletionOutput,
|
24 |
+
ChatCompletionOutputChoice,
|
25 |
+
ChatCompletionOutputChoiceMessage,
|
26 |
+
ChatCompletionStreamOutput,
|
27 |
+
ChatCompletionStreamOutputChoice,
|
28 |
+
ChatCompletionStreamOutputDelta,
|
29 |
+
)
|
30 |
+
from .depth_estimation import DepthEstimationInput, DepthEstimationOutput
|
31 |
+
from .document_question_answering import (
|
32 |
+
DocumentQuestionAnsweringInput,
|
33 |
+
DocumentQuestionAnsweringInputData,
|
34 |
+
DocumentQuestionAnsweringOutputElement,
|
35 |
+
DocumentQuestionAnsweringParameters,
|
36 |
+
)
|
37 |
+
from .feature_extraction import FeatureExtractionInput
|
38 |
+
from .fill_mask import FillMaskInput, FillMaskOutputElement, FillMaskParameters
|
39 |
+
from .image_classification import (
|
40 |
+
ImageClassificationInput,
|
41 |
+
ImageClassificationOutputElement,
|
42 |
+
ImageClassificationParameters,
|
43 |
+
)
|
44 |
+
from .image_segmentation import ImageSegmentationInput, ImageSegmentationOutputElement, ImageSegmentationParameters
|
45 |
+
from .image_to_image import ImageToImageInput, ImageToImageOutput, ImageToImageParameters, ImageToImageTargetSize
|
46 |
+
from .image_to_text import ImageToTextGenerationParameters, ImageToTextInput, ImageToTextOutput, ImageToTextParameters
|
47 |
+
from .object_detection import (
|
48 |
+
ObjectDetectionBoundingBox,
|
49 |
+
ObjectDetectionInput,
|
50 |
+
ObjectDetectionOutputElement,
|
51 |
+
ObjectDetectionParameters,
|
52 |
+
)
|
53 |
+
from .question_answering import (
|
54 |
+
QuestionAnsweringInput,
|
55 |
+
QuestionAnsweringInputData,
|
56 |
+
QuestionAnsweringOutputElement,
|
57 |
+
QuestionAnsweringParameters,
|
58 |
+
)
|
59 |
+
from .sentence_similarity import SentenceSimilarityInput, SentenceSimilarityInputData
|
60 |
+
from .summarization import SummarizationGenerationParameters, SummarizationInput, SummarizationOutput
|
61 |
+
from .table_question_answering import (
|
62 |
+
TableQuestionAnsweringInput,
|
63 |
+
TableQuestionAnsweringInputData,
|
64 |
+
TableQuestionAnsweringOutputElement,
|
65 |
+
)
|
66 |
+
from .text2text_generation import Text2TextGenerationInput, Text2TextGenerationOutput, Text2TextGenerationParameters
|
67 |
+
from .text_classification import TextClassificationInput, TextClassificationOutputElement, TextClassificationParameters
|
68 |
+
from .text_generation import (
|
69 |
+
TextGenerationInput,
|
70 |
+
TextGenerationOutput,
|
71 |
+
TextGenerationOutputDetails,
|
72 |
+
TextGenerationOutputSequenceDetails,
|
73 |
+
TextGenerationOutputToken,
|
74 |
+
TextGenerationParameters,
|
75 |
+
TextGenerationPrefillToken,
|
76 |
+
TextGenerationStreamDetails,
|
77 |
+
TextGenerationStreamOutput,
|
78 |
+
)
|
79 |
+
from .text_to_audio import TextToAudioGenerationParameters, TextToAudioInput, TextToAudioOutput, TextToAudioParameters
|
80 |
+
from .text_to_image import TextToImageInput, TextToImageOutput, TextToImageParameters, TextToImageTargetSize
|
81 |
+
from .token_classification import (
|
82 |
+
TokenClassificationInput,
|
83 |
+
TokenClassificationOutputElement,
|
84 |
+
TokenClassificationParameters,
|
85 |
+
)
|
86 |
+
from .translation import TranslationGenerationParameters, TranslationInput, TranslationOutput
|
87 |
+
from .video_classification import (
|
88 |
+
VideoClassificationInput,
|
89 |
+
VideoClassificationOutputElement,
|
90 |
+
VideoClassificationParameters,
|
91 |
+
)
|
92 |
+
from .visual_question_answering import (
|
93 |
+
VisualQuestionAnsweringInput,
|
94 |
+
VisualQuestionAnsweringInputData,
|
95 |
+
VisualQuestionAnsweringOutputElement,
|
96 |
+
VisualQuestionAnsweringParameters,
|
97 |
+
)
|
98 |
+
from .zero_shot_classification import (
|
99 |
+
ZeroShotClassificationInput,
|
100 |
+
ZeroShotClassificationInputData,
|
101 |
+
ZeroShotClassificationOutputElement,
|
102 |
+
ZeroShotClassificationParameters,
|
103 |
+
)
|
104 |
+
from .zero_shot_image_classification import (
|
105 |
+
ZeroShotImageClassificationInput,
|
106 |
+
ZeroShotImageClassificationInputData,
|
107 |
+
ZeroShotImageClassificationOutputElement,
|
108 |
+
ZeroShotImageClassificationParameters,
|
109 |
+
)
|
110 |
+
from .zero_shot_object_detection import (
|
111 |
+
ZeroShotObjectDetectionBoundingBox,
|
112 |
+
ZeroShotObjectDetectionInput,
|
113 |
+
ZeroShotObjectDetectionInputData,
|
114 |
+
ZeroShotObjectDetectionOutputElement,
|
115 |
+
)
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (5.2 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/audio_classification.cpython-310.pyc
ADDED
Binary file (1.44 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/audio_to_audio.cpython-310.pyc
ADDED
Binary file (966 Bytes). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/automatic_speech_recognition.cpython-310.pyc
ADDED
Binary file (2.75 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/base.cpython-310.pyc
ADDED
Binary file (4.61 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/chat_completion.cpython-310.pyc
ADDED
Binary file (2.81 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/depth_estimation.cpython-310.pyc
ADDED
Binary file (997 Bytes). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/document_question_answering.cpython-310.pyc
ADDED
Binary file (2.08 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/feature_extraction.cpython-310.pyc
ADDED
Binary file (719 Bytes). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/fill_mask.cpython-310.pyc
ADDED
Binary file (1.42 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/image_classification.cpython-310.pyc
ADDED
Binary file (1.45 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/image_segmentation.cpython-310.pyc
ADDED
Binary file (1.61 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/image_to_image.cpython-310.pyc
ADDED
Binary file (1.67 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/image_to_text.cpython-310.pyc
ADDED
Binary file (2.39 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/object_detection.cpython-310.pyc
ADDED
Binary file (1.67 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/question_answering.cpython-310.pyc
ADDED
Binary file (1.87 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/sentence_similarity.cpython-310.pyc
ADDED
Binary file (978 Bytes). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/summarization.cpython-310.pyc
ADDED
Binary file (1.59 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/table_question_answering.cpython-310.pyc
ADDED
Binary file (1.44 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/text2text_generation.cpython-310.pyc
ADDED
Binary file (1.65 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/text_classification.cpython-310.pyc
ADDED
Binary file (1.43 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/text_generation.cpython-310.pyc
ADDED
Binary file (4.08 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/text_to_audio.cpython-310.pyc
ADDED
Binary file (2.37 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/text_to_image.cpython-310.pyc
ADDED
Binary file (1.7 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/token_classification.cpython-310.pyc
ADDED
Binary file (1.7 kB). View file
|
|
venv/lib/python3.10/site-packages/huggingface_hub/inference/_generated/types/__pycache__/translation.cpython-310.pyc
ADDED
Binary file (1.58 kB). View file
|
|