Datasets:
Add Meta OmniASR Modal baseline (part 10)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +48 -0
- .venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/INSTALLER +1 -0
- .venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/METADATA +373 -0
- .venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/RECORD +376 -0
- .venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/REQUESTED +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/WHEEL +5 -0
- .venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/entry_points.txt +7 -0
- .venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/licenses/LICENSE +201 -0
- .venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/top_level.txt +1 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_datetime.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_deprecation.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_detect_agent.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_dotenv.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_experimental.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_fixes.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_git_credential.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_headers.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_hf_uris.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_http.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_lfs.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_oauth_device.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_pagination.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_parsing.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_paths.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_runtime.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_safetensors.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_subprocess.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_telemetry.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_terminal.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_typing.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_validators.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_verification.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_xet.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_xet_progress_reporting.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/endpoint_helpers.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/insecure_hashlib.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/logging.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/sha.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/tqdm.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/_auth.py +456 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/_cache_assets.py +133 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/_cache_manager.py +890 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/_chunk_utils.py +64 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/_datetime.py +66 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/_deprecation.py +136 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/_detect_agent.py +204 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/_dotenv.py +68 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/_experimental.py +67 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/_fixes.py +123 -0
- .venv/lib/python3.12/site-packages/huggingface_hub/utils/_git_credential.py +119 -0
.gitattributes
CHANGED
|
@@ -114,3 +114,51 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 114 |
.venv/lib/python3.12/site-packages/huggingface_hub/__pycache__/hf_api.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 115 |
.venv/lib/python3.12/site-packages/huggingface_hub/inference/__pycache__/_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 116 |
.venv/lib/python3.12/site-packages/huggingface_hub/inference/_generated/__pycache__/_async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
.venv/lib/python3.12/site-packages/huggingface_hub/__pycache__/hf_api.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 115 |
.venv/lib/python3.12/site-packages/huggingface_hub/inference/__pycache__/_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 116 |
.venv/lib/python3.12/site-packages/huggingface_hub/inference/_generated/__pycache__/_async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 117 |
+
.venv/lib/python3.12/site-packages/kiwisolver/_cext.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 118 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/_cm_listed.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 119 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/_mathtext.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 120 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/axis.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 121 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/backend_bases.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 122 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/cbook.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 123 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/collections.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 124 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/colors.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 125 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/figure.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 126 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/patches.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 127 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/pyplot.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 128 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/ticker.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 129 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/transforms.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 130 |
+
.venv/lib/python3.12/site-packages/matplotlib/__pycache__/widgets.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 131 |
+
.venv/lib/python3.12/site-packages/matplotlib/_c_internal_utils.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 132 |
+
.venv/lib/python3.12/site-packages/matplotlib/_image.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 133 |
+
.venv/lib/python3.12/site-packages/matplotlib/_path.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 134 |
+
.venv/lib/python3.12/site-packages/matplotlib/_qhull.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 135 |
+
.venv/lib/python3.12/site-packages/matplotlib/_tri.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 136 |
+
.venv/lib/python3.12/site-packages/matplotlib/axes/__pycache__/_axes.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 137 |
+
.venv/lib/python3.12/site-packages/matplotlib/axes/__pycache__/_base.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 138 |
+
.venv/lib/python3.12/site-packages/matplotlib/backends/__pycache__/backend_pdf.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 139 |
+
.venv/lib/python3.12/site-packages/matplotlib/backends/_backend_agg.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 140 |
+
.venv/lib/python3.12/site-packages/matplotlib/backends/_tkagg.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 141 |
+
.venv/lib/python3.12/site-packages/matplotlib/ft2font.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 142 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-Bold.ttf filter=lfs diff=lfs merge=lfs -text
|
| 143 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf filter=lfs diff=lfs merge=lfs -text
|
| 144 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf filter=lfs diff=lfs merge=lfs -text
|
| 145 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans.ttf filter=lfs diff=lfs merge=lfs -text
|
| 146 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-Bold.ttf filter=lfs diff=lfs merge=lfs -text
|
| 147 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-BoldOblique.ttf filter=lfs diff=lfs merge=lfs -text
|
| 148 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf filter=lfs diff=lfs merge=lfs -text
|
| 149 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono.ttf filter=lfs diff=lfs merge=lfs -text
|
| 150 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-Bold.ttf filter=lfs diff=lfs merge=lfs -text
|
| 151 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-BoldItalic.ttf filter=lfs diff=lfs merge=lfs -text
|
| 152 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-Italic.ttf filter=lfs diff=lfs merge=lfs -text
|
| 153 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif.ttf filter=lfs diff=lfs merge=lfs -text
|
| 154 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/LastResortHE-Regular.ttf filter=lfs diff=lfs merge=lfs -text
|
| 155 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf filter=lfs diff=lfs merge=lfs -text
|
| 156 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralBol.ttf filter=lfs diff=lfs merge=lfs -text
|
| 157 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf filter=lfs diff=lfs merge=lfs -text
|
| 158 |
+
.venv/lib/python3.12/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneralItalic.ttf filter=lfs diff=lfs merge=lfs -text
|
| 159 |
+
.venv/lib/python3.12/site-packages/matplotlib/tests/__pycache__/test_axes.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 160 |
+
.venv/lib/python3.12/site-packages/matplotlib/tests/__pycache__/test_colors.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 161 |
+
.venv/lib/python3.12/site-packages/matplotlib/tests/__pycache__/test_figure.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 162 |
+
.venv/lib/python3.12/site-packages/matplotlib/tests/__pycache__/test_image.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 163 |
+
.venv/lib/python3.12/site-packages/matplotlib/tests/__pycache__/test_legend.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 164 |
+
.venv/lib/python3.12/site-packages/matplotlib/tests/__pycache__/test_ticker.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
.venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
.venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: huggingface_hub
|
| 3 |
+
Version: 1.24.0
|
| 4 |
+
Summary: Client library to download and publish models, datasets and other repos on the huggingface.co hub
|
| 5 |
+
Home-page: https://github.com/huggingface/huggingface_hub
|
| 6 |
+
Author: Hugging Face, Inc.
|
| 7 |
+
Author-email: julien@huggingface.co
|
| 8 |
+
License: Apache-2.0
|
| 9 |
+
Keywords: model-hub machine-learning models natural-language-processing deep-learning pytorch pretrained-models
|
| 10 |
+
Classifier: Intended Audience :: Developers
|
| 11 |
+
Classifier: Intended Audience :: Education
|
| 12 |
+
Classifier: Intended Audience :: Science/Research
|
| 13 |
+
Classifier: License :: OSI Approved :: Apache Software License
|
| 14 |
+
Classifier: Operating System :: OS Independent
|
| 15 |
+
Classifier: Programming Language :: Python :: 3
|
| 16 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.14
|
| 22 |
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
| 23 |
+
Requires-Python: >=3.10.0
|
| 24 |
+
Description-Content-Type: text/markdown
|
| 25 |
+
License-File: LICENSE
|
| 26 |
+
Requires-Dist: click<9.0.0,>=8.4.2
|
| 27 |
+
Requires-Dist: filelock>=3.10.0
|
| 28 |
+
Requires-Dist: fsspec>=2023.5.0
|
| 29 |
+
Requires-Dist: hf-xet<2.0.0,>=1.5.1; platform_machine == "x86_64" or platform_machine == "amd64" or platform_machine == "AMD64" or platform_machine == "arm64" or platform_machine == "aarch64"
|
| 30 |
+
Requires-Dist: httpx<1,>=0.23.0
|
| 31 |
+
Requires-Dist: packaging>=20.9
|
| 32 |
+
Requires-Dist: pyyaml>=5.1
|
| 33 |
+
Requires-Dist: tqdm>=4.42.1
|
| 34 |
+
Requires-Dist: typing-extensions>=4.1.0
|
| 35 |
+
Provides-Extra: oauth
|
| 36 |
+
Requires-Dist: authlib>=1.3.2; extra == "oauth"
|
| 37 |
+
Requires-Dist: fastapi; extra == "oauth"
|
| 38 |
+
Requires-Dist: httpx; extra == "oauth"
|
| 39 |
+
Requires-Dist: itsdangerous; extra == "oauth"
|
| 40 |
+
Provides-Extra: torch
|
| 41 |
+
Requires-Dist: torch; extra == "torch"
|
| 42 |
+
Requires-Dist: safetensors[torch]; extra == "torch"
|
| 43 |
+
Provides-Extra: fastai
|
| 44 |
+
Requires-Dist: toml; extra == "fastai"
|
| 45 |
+
Requires-Dist: fastai>=2.4; extra == "fastai"
|
| 46 |
+
Requires-Dist: fastcore>=1.3.27; extra == "fastai"
|
| 47 |
+
Provides-Extra: hf-xet
|
| 48 |
+
Requires-Dist: hf-xet<2.0.0,>=1.5.1; extra == "hf-xet"
|
| 49 |
+
Provides-Extra: mcp
|
| 50 |
+
Requires-Dist: mcp>=1.8.0; extra == "mcp"
|
| 51 |
+
Provides-Extra: testing
|
| 52 |
+
Requires-Dist: authlib>=1.3.2; extra == "testing"
|
| 53 |
+
Requires-Dist: fastapi; extra == "testing"
|
| 54 |
+
Requires-Dist: httpx; extra == "testing"
|
| 55 |
+
Requires-Dist: itsdangerous; extra == "testing"
|
| 56 |
+
Requires-Dist: jedi; extra == "testing"
|
| 57 |
+
Requires-Dist: Jinja2; extra == "testing"
|
| 58 |
+
Requires-Dist: pytest>=8.4.2; extra == "testing"
|
| 59 |
+
Requires-Dist: pytest-cov; extra == "testing"
|
| 60 |
+
Requires-Dist: pytest-env; extra == "testing"
|
| 61 |
+
Requires-Dist: pytest-xdist; extra == "testing"
|
| 62 |
+
Requires-Dist: pytest-vcr; extra == "testing"
|
| 63 |
+
Requires-Dist: pytest-asyncio; extra == "testing"
|
| 64 |
+
Requires-Dist: pytest-rerunfailures<16.0; extra == "testing"
|
| 65 |
+
Requires-Dist: pytest-mock; extra == "testing"
|
| 66 |
+
Requires-Dist: urllib3<2.0; extra == "testing"
|
| 67 |
+
Requires-Dist: soundfile; extra == "testing"
|
| 68 |
+
Requires-Dist: Pillow; extra == "testing"
|
| 69 |
+
Requires-Dist: numpy; extra == "testing"
|
| 70 |
+
Requires-Dist: duckdb; extra == "testing"
|
| 71 |
+
Requires-Dist: fastapi; extra == "testing"
|
| 72 |
+
Provides-Extra: gradio
|
| 73 |
+
Requires-Dist: gradio>=5.0.0; extra == "gradio"
|
| 74 |
+
Requires-Dist: requests; extra == "gradio"
|
| 75 |
+
Provides-Extra: typing
|
| 76 |
+
Requires-Dist: typing-extensions>=4.8.0; extra == "typing"
|
| 77 |
+
Requires-Dist: types-PyYAML; extra == "typing"
|
| 78 |
+
Requires-Dist: types-simplejson; extra == "typing"
|
| 79 |
+
Requires-Dist: types-toml; extra == "typing"
|
| 80 |
+
Requires-Dist: types-tqdm; extra == "typing"
|
| 81 |
+
Requires-Dist: types-urllib3; extra == "typing"
|
| 82 |
+
Provides-Extra: quality
|
| 83 |
+
Requires-Dist: ruff>=0.9.0; extra == "quality"
|
| 84 |
+
Requires-Dist: mypy==1.15.0; extra == "quality"
|
| 85 |
+
Requires-Dist: libcst>=1.4.0; extra == "quality"
|
| 86 |
+
Requires-Dist: ty; extra == "quality"
|
| 87 |
+
Provides-Extra: all
|
| 88 |
+
Requires-Dist: authlib>=1.3.2; extra == "all"
|
| 89 |
+
Requires-Dist: fastapi; extra == "all"
|
| 90 |
+
Requires-Dist: httpx; extra == "all"
|
| 91 |
+
Requires-Dist: itsdangerous; extra == "all"
|
| 92 |
+
Requires-Dist: jedi; extra == "all"
|
| 93 |
+
Requires-Dist: Jinja2; extra == "all"
|
| 94 |
+
Requires-Dist: pytest>=8.4.2; extra == "all"
|
| 95 |
+
Requires-Dist: pytest-cov; extra == "all"
|
| 96 |
+
Requires-Dist: pytest-env; extra == "all"
|
| 97 |
+
Requires-Dist: pytest-xdist; extra == "all"
|
| 98 |
+
Requires-Dist: pytest-vcr; extra == "all"
|
| 99 |
+
Requires-Dist: pytest-asyncio; extra == "all"
|
| 100 |
+
Requires-Dist: pytest-rerunfailures<16.0; extra == "all"
|
| 101 |
+
Requires-Dist: pytest-mock; extra == "all"
|
| 102 |
+
Requires-Dist: urllib3<2.0; extra == "all"
|
| 103 |
+
Requires-Dist: soundfile; extra == "all"
|
| 104 |
+
Requires-Dist: Pillow; extra == "all"
|
| 105 |
+
Requires-Dist: numpy; extra == "all"
|
| 106 |
+
Requires-Dist: duckdb; extra == "all"
|
| 107 |
+
Requires-Dist: fastapi; extra == "all"
|
| 108 |
+
Requires-Dist: ruff>=0.9.0; extra == "all"
|
| 109 |
+
Requires-Dist: mypy==1.15.0; extra == "all"
|
| 110 |
+
Requires-Dist: libcst>=1.4.0; extra == "all"
|
| 111 |
+
Requires-Dist: ty; extra == "all"
|
| 112 |
+
Requires-Dist: typing-extensions>=4.8.0; extra == "all"
|
| 113 |
+
Requires-Dist: types-PyYAML; extra == "all"
|
| 114 |
+
Requires-Dist: types-simplejson; extra == "all"
|
| 115 |
+
Requires-Dist: types-toml; extra == "all"
|
| 116 |
+
Requires-Dist: types-tqdm; extra == "all"
|
| 117 |
+
Requires-Dist: types-urllib3; extra == "all"
|
| 118 |
+
Provides-Extra: dev
|
| 119 |
+
Requires-Dist: authlib>=1.3.2; extra == "dev"
|
| 120 |
+
Requires-Dist: fastapi; extra == "dev"
|
| 121 |
+
Requires-Dist: httpx; extra == "dev"
|
| 122 |
+
Requires-Dist: itsdangerous; extra == "dev"
|
| 123 |
+
Requires-Dist: jedi; extra == "dev"
|
| 124 |
+
Requires-Dist: Jinja2; extra == "dev"
|
| 125 |
+
Requires-Dist: pytest>=8.4.2; extra == "dev"
|
| 126 |
+
Requires-Dist: pytest-cov; extra == "dev"
|
| 127 |
+
Requires-Dist: pytest-env; extra == "dev"
|
| 128 |
+
Requires-Dist: pytest-xdist; extra == "dev"
|
| 129 |
+
Requires-Dist: pytest-vcr; extra == "dev"
|
| 130 |
+
Requires-Dist: pytest-asyncio; extra == "dev"
|
| 131 |
+
Requires-Dist: pytest-rerunfailures<16.0; extra == "dev"
|
| 132 |
+
Requires-Dist: pytest-mock; extra == "dev"
|
| 133 |
+
Requires-Dist: urllib3<2.0; extra == "dev"
|
| 134 |
+
Requires-Dist: soundfile; extra == "dev"
|
| 135 |
+
Requires-Dist: Pillow; extra == "dev"
|
| 136 |
+
Requires-Dist: numpy; extra == "dev"
|
| 137 |
+
Requires-Dist: duckdb; extra == "dev"
|
| 138 |
+
Requires-Dist: fastapi; extra == "dev"
|
| 139 |
+
Requires-Dist: ruff>=0.9.0; extra == "dev"
|
| 140 |
+
Requires-Dist: mypy==1.15.0; extra == "dev"
|
| 141 |
+
Requires-Dist: libcst>=1.4.0; extra == "dev"
|
| 142 |
+
Requires-Dist: ty; extra == "dev"
|
| 143 |
+
Requires-Dist: typing-extensions>=4.8.0; extra == "dev"
|
| 144 |
+
Requires-Dist: types-PyYAML; extra == "dev"
|
| 145 |
+
Requires-Dist: types-simplejson; extra == "dev"
|
| 146 |
+
Requires-Dist: types-toml; extra == "dev"
|
| 147 |
+
Requires-Dist: types-tqdm; extra == "dev"
|
| 148 |
+
Requires-Dist: types-urllib3; extra == "dev"
|
| 149 |
+
Dynamic: author
|
| 150 |
+
Dynamic: author-email
|
| 151 |
+
Dynamic: classifier
|
| 152 |
+
Dynamic: description
|
| 153 |
+
Dynamic: description-content-type
|
| 154 |
+
Dynamic: home-page
|
| 155 |
+
Dynamic: keywords
|
| 156 |
+
Dynamic: license
|
| 157 |
+
Dynamic: license-file
|
| 158 |
+
Dynamic: provides-extra
|
| 159 |
+
Dynamic: requires-dist
|
| 160 |
+
Dynamic: requires-python
|
| 161 |
+
Dynamic: summary
|
| 162 |
+
|
| 163 |
+
<p align="center">
|
| 164 |
+
<picture>
|
| 165 |
+
<source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub-dark.svg">
|
| 166 |
+
<source media="(prefers-color-scheme: light)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub.svg">
|
| 167 |
+
<img alt="huggingface_hub library logo" src="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub.svg" width="352" height="59" style="max-width: 100%">
|
| 168 |
+
</picture>
|
| 169 |
+
<br/>
|
| 170 |
+
<br/>
|
| 171 |
+
</p>
|
| 172 |
+
|
| 173 |
+
<p align="center">
|
| 174 |
+
<i>The official CLI and Python client for the Hugging Face Hub.</i>
|
| 175 |
+
<br/>
|
| 176 |
+
<a href="#what-is-huggingface_hub">About</a>
|
| 177 |
+
·
|
| 178 |
+
<a href="https://huggingface.co/docs/huggingface_hub">Documentation</a>
|
| 179 |
+
·
|
| 180 |
+
<a href="https://huggingface.co/docs/huggingface_hub/en/installation">Install</a>
|
| 181 |
+
·
|
| 182 |
+
<a href="https://huggingface.co/docs/huggingface_hub/en/guides/cli">CLI Guide</a>
|
| 183 |
+
·
|
| 184 |
+
<a href="https://github.com/huggingface/huggingface_hub/blob/main/CONTRIBUTING.md">Contributing</a>
|
| 185 |
+
</p>
|
| 186 |
+
|
| 187 |
+
<p align="center">
|
| 188 |
+
<a href="https://huggingface.co/docs/huggingface_hub/en/index"><img alt="Documentation" src="https://img.shields.io/website/http/huggingface.co/docs/huggingface_hub/index.svg?down_color=red&down_message=offline&up_message=online&label=doc"></a>
|
| 189 |
+
<a href="https://github.com/huggingface/huggingface_hub/releases"><img alt="GitHub release" src="https://img.shields.io/github/release/huggingface/huggingface_hub.svg"></a>
|
| 190 |
+
<a href="https://github.com/huggingface/huggingface_hub"><img alt="PyPi version" src="https://img.shields.io/pypi/pyversions/huggingface_hub.svg"></a>
|
| 191 |
+
<a href="https://pypi.org/project/huggingface-hub"><img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/huggingface_hub"></a>
|
| 192 |
+
<a href="https://codecov.io/gh/huggingface/huggingface_hub"><img alt="Code coverage" src="https://codecov.io/gh/huggingface/huggingface_hub/branch/main/graph/badge.svg?token=RXP95LE2XL"></a>
|
| 193 |
+
</p>
|
| 194 |
+
|
| 195 |
+
<h4 align="center">
|
| 196 |
+
<p>
|
| 197 |
+
<b>English</b> |
|
| 198 |
+
<a href="https://github.com/huggingface/huggingface_hub/blob/main/i18n/README_de.md">Deutsch</a> |
|
| 199 |
+
<a href="https://github.com/huggingface/huggingface_hub/blob/main/i18n/README_fr.md">Français</a> |
|
| 200 |
+
<a href="https://github.com/huggingface/huggingface_hub/blob/main/i18n/README_hi.md">हिंदी</a> |
|
| 201 |
+
<a href="https://github.com/huggingface/huggingface_hub/blob/main/i18n/README_ko.md">한국어</a> |
|
| 202 |
+
<a href="https://github.com/huggingface/huggingface_hub/blob/main/i18n/README_cn.md">中文 (简体)</a> |
|
| 203 |
+
<a href="https://github.com/huggingface/huggingface_hub/blob/main/i18n/README_kn.md">ಕನ್ನಡ</a>
|
| 204 |
+
</p>
|
| 205 |
+
</h4>
|
| 206 |
+
|
| 207 |
+
## Quick start
|
| 208 |
+
|
| 209 |
+
Install the [`hf` CLI](https://huggingface.co/docs/huggingface_hub/en/guides/cli) with the standalone installer:
|
| 210 |
+
|
| 211 |
+
```bash
|
| 212 |
+
# On macOS and Linux.
|
| 213 |
+
curl -LsSf https://hf.co/cli/install.sh | bash
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
```powershell
|
| 217 |
+
# On Windows.
|
| 218 |
+
powershell -ExecutionPolicy ByPass -c "irm https://hf.co/cli/install.ps1 | iex"
|
| 219 |
+
```
|
| 220 |
+
|
| 221 |
+
Log in, then start working with the Hub:
|
| 222 |
+
|
| 223 |
+
```bash
|
| 224 |
+
# Log in (use --token $HF_TOKEN in non-interactive environments)
|
| 225 |
+
hf auth login
|
| 226 |
+
|
| 227 |
+
# Find models served by Inference Providers
|
| 228 |
+
hf models ls --warm
|
| 229 |
+
|
| 230 |
+
# Download a model
|
| 231 |
+
hf download Qwen/Qwen3-0.6B
|
| 232 |
+
|
| 233 |
+
# Upload files to your own repo
|
| 234 |
+
hf upload username/my-cool-model ./model.safetensors
|
| 235 |
+
|
| 236 |
+
# Sync a local folder to a storage bucket
|
| 237 |
+
hf buckets sync ./checkpoints hf://buckets/username/my-bucket
|
| 238 |
+
|
| 239 |
+
# Run a job on Hugging Face infrastructure
|
| 240 |
+
hf jobs run python:3.12 python -c "print('Hello from the cloud!')"
|
| 241 |
+
|
| 242 |
+
# Discover everything else
|
| 243 |
+
hf --help
|
| 244 |
+
```
|
| 245 |
+
|
| 246 |
+
The Hub uses tokens to authenticate applications (see [docs](https://huggingface.co/docs/hub/security-tokens)). Check out the [CLI guide](https://huggingface.co/docs/huggingface_hub/en/guides/cli) for a tour of the main features.
|
| 247 |
+
|
| 248 |
+
## What is `huggingface_hub`?
|
| 249 |
+
|
| 250 |
+
The `huggingface_hub` library allows you to interact with the [Hugging Face Hub](https://huggingface.co/), a platform democratizing open-source Machine Learning for creators and collaborators. Discover pre-trained models and datasets for your projects, play with the thousands of machine learning apps hosted on the Hub, or create and share your own models, datasets and demos with the community. Everything ships in one package with two interfaces: the [`hf` CLI](https://huggingface.co/docs/huggingface_hub/en/guides/cli) for your terminal and the `huggingface_hub` library for Python — both designed to work well for humans and AI agents. Use them to:
|
| 251 |
+
|
| 252 |
+
- [Download files](https://huggingface.co/docs/huggingface_hub/en/guides/download) from the Hub.
|
| 253 |
+
- [Upload files](https://huggingface.co/docs/huggingface_hub/en/guides/upload) to the Hub.
|
| 254 |
+
- [Manage your repositories](https://huggingface.co/docs/huggingface_hub/en/guides/repository).
|
| 255 |
+
- [Run Inference](https://huggingface.co/docs/huggingface_hub/en/guides/inference) on deployed models.
|
| 256 |
+
- [Run Jobs](https://huggingface.co/docs/huggingface_hub/en/guides/jobs) on Hugging Face infrastructure.
|
| 257 |
+
- [Search](https://huggingface.co/docs/huggingface_hub/en/guides/search) for models, datasets and Spaces.
|
| 258 |
+
- [Share Model Cards](https://huggingface.co/docs/huggingface_hub/en/guides/model-cards) to document your models.
|
| 259 |
+
- [Engage with the community](https://huggingface.co/docs/huggingface_hub/en/guides/community) through PRs and comments.
|
| 260 |
+
- Do all of the above from the terminal with the [`hf` CLI](https://huggingface.co/docs/huggingface_hub/en/guides/cli).
|
| 261 |
+
|
| 262 |
+
## Built for humans and AI agents
|
| 263 |
+
|
| 264 |
+
The `hf` CLI is designed for people and coding agents alike: the same commands adapt their output when run by an agent. If you use Claude Code, Codex, Cursor, or another coding agent, install the `hf` CLI Skill — a command reference generated from your installed CLI:
|
| 265 |
+
|
| 266 |
+
```bash
|
| 267 |
+
# for Codex, Cursor, OpenCode, Pi and other agents that load skills from `.agents/skills`
|
| 268 |
+
hf skills add
|
| 269 |
+
# includes the above + Claude Code
|
| 270 |
+
hf skills add --claude
|
| 271 |
+
```
|
| 272 |
+
|
| 273 |
+
Learn more in the [Hugging Face CLI for AI agents guide](https://huggingface.co/docs/hub/agents-cli) and the [announcement blog post](https://huggingface.co/blog/hf-cli-for-agents).
|
| 274 |
+
|
| 275 |
+
## Use the Python library
|
| 276 |
+
|
| 277 |
+
Install the `huggingface_hub` package with [pip](https://pypi.org/project/huggingface-hub/) (this also installs the `hf` CLI):
|
| 278 |
+
|
| 279 |
+
```bash
|
| 280 |
+
pip install huggingface_hub
|
| 281 |
+
```
|
| 282 |
+
|
| 283 |
+
We recommend using [`uv`](https://docs.astral.sh/uv/) for a fast and reliable install:
|
| 284 |
+
|
| 285 |
+
```bash
|
| 286 |
+
uv pip install huggingface_hub
|
| 287 |
+
```
|
| 288 |
+
|
| 289 |
+
In order to keep the package minimal by default, `huggingface_hub` comes with optional dependencies useful for some use cases. For example, if you want to use the MCP module, run:
|
| 290 |
+
|
| 291 |
+
```bash
|
| 292 |
+
pip install "huggingface_hub[mcp]"
|
| 293 |
+
```
|
| 294 |
+
|
| 295 |
+
To learn more about installation and optional dependencies, check out the [installation guide](https://huggingface.co/docs/huggingface_hub/en/installation).
|
| 296 |
+
|
| 297 |
+
### Download files
|
| 298 |
+
|
| 299 |
+
Download a single file
|
| 300 |
+
|
| 301 |
+
```py
|
| 302 |
+
from huggingface_hub import hf_hub_download
|
| 303 |
+
|
| 304 |
+
hf_hub_download(repo_id="zai-org/GLM-5.2", filename="config.json")
|
| 305 |
+
```
|
| 306 |
+
|
| 307 |
+
Or an entire repository
|
| 308 |
+
|
| 309 |
+
```py
|
| 310 |
+
from huggingface_hub import snapshot_download
|
| 311 |
+
|
| 312 |
+
snapshot_download("sentence-transformers/all-MiniLM-L6-v2")
|
| 313 |
+
```
|
| 314 |
+
|
| 315 |
+
Files will be downloaded in a local cache folder. More details in [this guide](https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache).
|
| 316 |
+
|
| 317 |
+
### Create a repository
|
| 318 |
+
|
| 319 |
+
```py
|
| 320 |
+
from huggingface_hub import create_repo
|
| 321 |
+
|
| 322 |
+
create_repo(repo_id="super-cool-model")
|
| 323 |
+
```
|
| 324 |
+
|
| 325 |
+
### Upload files
|
| 326 |
+
|
| 327 |
+
Upload a single file
|
| 328 |
+
|
| 329 |
+
```py
|
| 330 |
+
from huggingface_hub import upload_file
|
| 331 |
+
|
| 332 |
+
upload_file(
|
| 333 |
+
path_or_fileobj="/home/lysandre/dummy-test/README.md",
|
| 334 |
+
path_in_repo="README.md",
|
| 335 |
+
repo_id="lysandre/test-model",
|
| 336 |
+
)
|
| 337 |
+
```
|
| 338 |
+
|
| 339 |
+
Or an entire folder
|
| 340 |
+
|
| 341 |
+
```py
|
| 342 |
+
from huggingface_hub import upload_folder
|
| 343 |
+
|
| 344 |
+
upload_folder(
|
| 345 |
+
folder_path="/path/to/local/space",
|
| 346 |
+
repo_id="username/my-cool-space",
|
| 347 |
+
repo_type="space",
|
| 348 |
+
)
|
| 349 |
+
```
|
| 350 |
+
|
| 351 |
+
More details in the [upload guide](https://huggingface.co/docs/huggingface_hub/en/guides/upload).
|
| 352 |
+
|
| 353 |
+
## Integrating with the Hub.
|
| 354 |
+
|
| 355 |
+
We're partnering with cool open source ML libraries to provide free model hosting and versioning. You can find the existing integrations [here](https://huggingface.co/docs/hub/libraries).
|
| 356 |
+
|
| 357 |
+
The advantages are:
|
| 358 |
+
|
| 359 |
+
- Free model or dataset hosting for libraries and their users.
|
| 360 |
+
- Built-in file versioning, even with very large files, made possible by [Xet](https://huggingface.co/docs/hub/xet/index), the Hub's chunk-deduplicated storage backend.
|
| 361 |
+
- In-browser widgets to play with the uploaded models.
|
| 362 |
+
- Anyone can upload a new model for your library, they just need to add the corresponding tag for the model to be discoverable.
|
| 363 |
+
- Fast downloads! We use Cloudfront (a CDN) to geo-replicate downloads so they're blazing fast from anywhere on the globe.
|
| 364 |
+
- Usage stats and more features to come.
|
| 365 |
+
|
| 366 |
+
If you would like to integrate your library, feel free to open an issue to begin the discussion. We wrote a [step-by-step guide](https://huggingface.co/docs/hub/adding-a-library) with ❤️ showing how to do this integration.
|
| 367 |
+
|
| 368 |
+
## Contributions (feature requests, bugs, etc.) are super welcome 💙💚💛💜🧡❤️
|
| 369 |
+
|
| 370 |
+
Everyone is welcome to contribute, and we value everybody's contribution. Code is not the only way to help the community.
|
| 371 |
+
Answering questions, helping others, reaching out and improving the documentations are immensely valuable to the community.
|
| 372 |
+
We wrote a [contribution guide](https://github.com/huggingface/huggingface_hub/blob/main/CONTRIBUTING.md) to summarize
|
| 373 |
+
how to get started to contribute to this repository.
|
.venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
../../../bin/hf,sha256=QzqAAPLHTL_yQruKm9ioWfHK-6KEvBiZ5ghwRNb6meQ,203
|
| 2 |
+
../../../bin/huggingface-cli,sha256=RkGTZ1xtx21Q0MKTIVPO5Ru9x--InCCDi-rcTUNolV8,215
|
| 3 |
+
../../../bin/tiny-agents,sha256=QxqPt8N8zZVpaY1prKwqUB5LM_mO4GkdqABKYi0qGNs,213
|
| 4 |
+
huggingface_hub-1.24.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 5 |
+
huggingface_hub-1.24.0.dist-info/METADATA,sha256=v9Nc5D4ZrL3kN81cNvd66iJ1JPd9uOkE7TeLj61cjMQ,16311
|
| 6 |
+
huggingface_hub-1.24.0.dist-info/RECORD,,
|
| 7 |
+
huggingface_hub-1.24.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 8 |
+
huggingface_hub-1.24.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
| 9 |
+
huggingface_hub-1.24.0.dist-info/entry_points.txt,sha256=zP7F_bBSdircPQFysHQZ9F3Lcn5_dCSOEZxVlGCsG0w,212
|
| 10 |
+
huggingface_hub-1.24.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
| 11 |
+
huggingface_hub-1.24.0.dist-info/top_level.txt,sha256=8KzlQJAY4miUvjAssOAJodqKOw3harNzuiwGQ9qLSSk,16
|
| 12 |
+
huggingface_hub/__init__.py,sha256=-S0NPE6Z4nJekQs_IfXDYzv314lNMbbaDDEhCTl8C3c,60255
|
| 13 |
+
huggingface_hub/__pycache__/__init__.cpython-312.pyc,,
|
| 14 |
+
huggingface_hub/__pycache__/_buckets.cpython-312.pyc,,
|
| 15 |
+
huggingface_hub/__pycache__/_commit_api.cpython-312.pyc,,
|
| 16 |
+
huggingface_hub/__pycache__/_commit_scheduler.cpython-312.pyc,,
|
| 17 |
+
huggingface_hub/__pycache__/_dataset_viewer.cpython-312.pyc,,
|
| 18 |
+
huggingface_hub/__pycache__/_eval_results.cpython-312.pyc,,
|
| 19 |
+
huggingface_hub/__pycache__/_inference_endpoints.cpython-312.pyc,,
|
| 20 |
+
huggingface_hub/__pycache__/_jobs_api.cpython-312.pyc,,
|
| 21 |
+
huggingface_hub/__pycache__/_local_folder.cpython-312.pyc,,
|
| 22 |
+
huggingface_hub/__pycache__/_login.cpython-312.pyc,,
|
| 23 |
+
huggingface_hub/__pycache__/_oauth.cpython-312.pyc,,
|
| 24 |
+
huggingface_hub/__pycache__/_oidc.cpython-312.pyc,,
|
| 25 |
+
huggingface_hub/__pycache__/_sandbox.cpython-312.pyc,,
|
| 26 |
+
huggingface_hub/__pycache__/_sandbox_cache.cpython-312.pyc,,
|
| 27 |
+
huggingface_hub/__pycache__/_snapshot_download.cpython-312.pyc,,
|
| 28 |
+
huggingface_hub/__pycache__/_space_api.cpython-312.pyc,,
|
| 29 |
+
huggingface_hub/__pycache__/_tensorboard_logger.cpython-312.pyc,,
|
| 30 |
+
huggingface_hub/__pycache__/_tree_cache.cpython-312.pyc,,
|
| 31 |
+
huggingface_hub/__pycache__/_upload_large_folder.cpython-312.pyc,,
|
| 32 |
+
huggingface_hub/__pycache__/_upload_pipeline.cpython-312.pyc,,
|
| 33 |
+
huggingface_hub/__pycache__/_webhooks_payload.cpython-312.pyc,,
|
| 34 |
+
huggingface_hub/__pycache__/_webhooks_server.cpython-312.pyc,,
|
| 35 |
+
huggingface_hub/__pycache__/community.cpython-312.pyc,,
|
| 36 |
+
huggingface_hub/__pycache__/constants.cpython-312.pyc,,
|
| 37 |
+
huggingface_hub/__pycache__/dataclasses.cpython-312.pyc,,
|
| 38 |
+
huggingface_hub/__pycache__/errors.cpython-312.pyc,,
|
| 39 |
+
huggingface_hub/__pycache__/fastai_utils.cpython-312.pyc,,
|
| 40 |
+
huggingface_hub/__pycache__/file_download.cpython-312.pyc,,
|
| 41 |
+
huggingface_hub/__pycache__/hf_api.cpython-312.pyc,,
|
| 42 |
+
huggingface_hub/__pycache__/hf_file_system.cpython-312.pyc,,
|
| 43 |
+
huggingface_hub/__pycache__/hub_mixin.cpython-312.pyc,,
|
| 44 |
+
huggingface_hub/__pycache__/lfs.cpython-312.pyc,,
|
| 45 |
+
huggingface_hub/__pycache__/repocard.cpython-312.pyc,,
|
| 46 |
+
huggingface_hub/__pycache__/repocard_data.cpython-312.pyc,,
|
| 47 |
+
huggingface_hub/_buckets.py,sha256=XyLbsLzS2fpQz0aAIjKzV-1YbQ4XYZ4-HXQTVq0TXoU,45311
|
| 48 |
+
huggingface_hub/_commit_api.py,sha256=yW99ZJbIuiRt604bQ2TpDzsfxTO-IxdFW8nf-NY2MyE,45389
|
| 49 |
+
huggingface_hub/_commit_scheduler.py,sha256=VG3zjb7xb66NrFMq_pB9dWIsoqSPoF6CntovV7vUiWg,14684
|
| 50 |
+
huggingface_hub/_dataset_viewer.py,sha256=LE9k4s0WJ0JNdriJ8L6qV_-xfbUVC1VEh7CBd0jOjLI,5675
|
| 51 |
+
huggingface_hub/_eval_results.py,sha256=Og7p7bCl2HQG6ZWlSDyir-CRTXjNWPu3S3q65cTGffs,8126
|
| 52 |
+
huggingface_hub/_hot_reload/__init__.py,sha256=nQEuyVZLAS_463Dff1JH5MorTpkYsBVFCyPhYWY3UyI,606
|
| 53 |
+
huggingface_hub/_hot_reload/__pycache__/__init__.cpython-312.pyc,,
|
| 54 |
+
huggingface_hub/_hot_reload/__pycache__/client.cpython-312.pyc,,
|
| 55 |
+
huggingface_hub/_hot_reload/__pycache__/sse_client.cpython-312.pyc,,
|
| 56 |
+
huggingface_hub/_hot_reload/__pycache__/types.cpython-312.pyc,,
|
| 57 |
+
huggingface_hub/_hot_reload/client.py,sha256=Ax7qT4CUi5wrg3mDzqkAG8ZzDsCwdcIIS1FIXK0SqD8,4269
|
| 58 |
+
huggingface_hub/_hot_reload/sse_client.py,sha256=49kmsB2P9sxgbZ16ed6F4aLDs3rsHrNpbp6iKlvF90c,4948
|
| 59 |
+
huggingface_hub/_hot_reload/types.py,sha256=d3AOJCLUxT41Fhz4jUrFevm9bfpooe_3PQhpBdgNYSs,2725
|
| 60 |
+
huggingface_hub/_inference_endpoints.py,sha256=TNCEvHfu5M790bQPl4BccRzcii8WS5FlDYGrGqQzdW4,17724
|
| 61 |
+
huggingface_hub/_jobs_api.py,sha256=tZMrw8idM6nbIz_EJsOt7Gx7_2v7CzRtaUqrQfXAsi0,21164
|
| 62 |
+
huggingface_hub/_local_folder.py,sha256=Fc_hikyMaZRHtXIDZj38hL7MNkq5nZZVxQF-dd-EkMo,18279
|
| 63 |
+
huggingface_hub/_login.py,sha256=wAMdhqMSSh3GBJDozodmk4IIsAvb9J6LaLY9KnXFoyY,21818
|
| 64 |
+
huggingface_hub/_oauth.py,sha256=S8evEd8JLJHz-JiSjGH4WiIi_A7oDox_xH7E9rN1Jic,18628
|
| 65 |
+
huggingface_hub/_oidc.py,sha256=3kcCLavWQ5FQOwizUPzLaBb1ft2FIJo0bSXL24S3r4U,7098
|
| 66 |
+
huggingface_hub/_sandbox.py,sha256=F6ZMchoqH8cnzdmGECqszL8JR4hcWIgGDq4QgV8W-TQ,80138
|
| 67 |
+
huggingface_hub/_sandbox_cache.py,sha256=UYpvHOWZj7CRhacYs5Ot-5N1wFcAapiAyniYdoX-jX8,5742
|
| 68 |
+
huggingface_hub/_snapshot_download.py,sha256=jdXyEI_e00GLeTIs6r783MbO5-AdS2nCow2aqlgzy1Q,30431
|
| 69 |
+
huggingface_hub/_space_api.py,sha256=MF3ezhgl0Vpt3RP1wuwZ7VI9_rSyIlIJ5SmDzIwQlcQ,13424
|
| 70 |
+
huggingface_hub/_tensorboard_logger.py,sha256=GA-LhoG4Z-0Zq7w5B9vTIDJbWUkAhiG2d8a-ktlwGDY,8377
|
| 71 |
+
huggingface_hub/_tree_cache.py,sha256=9JU2uOX5oQT3wK2BSUj5Yb33UUNpmybGav5d5FduzGk,5336
|
| 72 |
+
huggingface_hub/_upload_large_folder.py,sha256=BWA1zyOK9W_3YUerX9YWQa3wAYtHRe_ypgsO79JEkqo,31235
|
| 73 |
+
huggingface_hub/_upload_pipeline.py,sha256=19UxsZ10NB05kOXEvTN663TDE--9EBJjvxR4uI-Lg9c,28946
|
| 74 |
+
huggingface_hub/_webhooks_payload.py,sha256=B9zqljcm20DGeVxJKba570i6RP-cR9CEupMGBuNDHHA,3544
|
| 75 |
+
huggingface_hub/_webhooks_server.py,sha256=VXOk3FHkbIc28phxknJfaFy5B_EoKOKihoCKyOaWZQk,15767
|
| 76 |
+
huggingface_hub/cli/__init__.py,sha256=tWu3Is-m2tlJwXhM_vT2mPRgpnt9KhU9qvw5aRsnjU0,664
|
| 77 |
+
huggingface_hub/cli/__pycache__/__init__.cpython-312.pyc,,
|
| 78 |
+
huggingface_hub/cli/__pycache__/_city_game.cpython-312.pyc,,
|
| 79 |
+
huggingface_hub/cli/__pycache__/_cli_utils.cpython-312.pyc,,
|
| 80 |
+
huggingface_hub/cli/__pycache__/_completion.cpython-312.pyc,,
|
| 81 |
+
huggingface_hub/cli/__pycache__/_cp.cpython-312.pyc,,
|
| 82 |
+
huggingface_hub/cli/__pycache__/_errors.cpython-312.pyc,,
|
| 83 |
+
huggingface_hub/cli/__pycache__/_file_listing.cpython-312.pyc,,
|
| 84 |
+
huggingface_hub/cli/__pycache__/_framework.cpython-312.pyc,,
|
| 85 |
+
huggingface_hub/cli/__pycache__/_help_formatter.cpython-312.pyc,,
|
| 86 |
+
huggingface_hub/cli/__pycache__/_output.cpython-312.pyc,,
|
| 87 |
+
huggingface_hub/cli/__pycache__/_skills.cpython-312.pyc,,
|
| 88 |
+
huggingface_hub/cli/__pycache__/auth.cpython-312.pyc,,
|
| 89 |
+
huggingface_hub/cli/__pycache__/buckets.cpython-312.pyc,,
|
| 90 |
+
huggingface_hub/cli/__pycache__/cache.cpython-312.pyc,,
|
| 91 |
+
huggingface_hub/cli/__pycache__/collections.cpython-312.pyc,,
|
| 92 |
+
huggingface_hub/cli/__pycache__/datasets.cpython-312.pyc,,
|
| 93 |
+
huggingface_hub/cli/__pycache__/deprecated_cli.cpython-312.pyc,,
|
| 94 |
+
huggingface_hub/cli/__pycache__/discussions.cpython-312.pyc,,
|
| 95 |
+
huggingface_hub/cli/__pycache__/download.cpython-312.pyc,,
|
| 96 |
+
huggingface_hub/cli/__pycache__/extensions.cpython-312.pyc,,
|
| 97 |
+
huggingface_hub/cli/__pycache__/hf.cpython-312.pyc,,
|
| 98 |
+
huggingface_hub/cli/__pycache__/inference_endpoints.cpython-312.pyc,,
|
| 99 |
+
huggingface_hub/cli/__pycache__/jobs.cpython-312.pyc,,
|
| 100 |
+
huggingface_hub/cli/__pycache__/lfs.cpython-312.pyc,,
|
| 101 |
+
huggingface_hub/cli/__pycache__/models.cpython-312.pyc,,
|
| 102 |
+
huggingface_hub/cli/__pycache__/papers.cpython-312.pyc,,
|
| 103 |
+
huggingface_hub/cli/__pycache__/repo_files.cpython-312.pyc,,
|
| 104 |
+
huggingface_hub/cli/__pycache__/repos.cpython-312.pyc,,
|
| 105 |
+
huggingface_hub/cli/__pycache__/sandbox.cpython-312.pyc,,
|
| 106 |
+
huggingface_hub/cli/__pycache__/skills.cpython-312.pyc,,
|
| 107 |
+
huggingface_hub/cli/__pycache__/spaces.cpython-312.pyc,,
|
| 108 |
+
huggingface_hub/cli/__pycache__/system.cpython-312.pyc,,
|
| 109 |
+
huggingface_hub/cli/__pycache__/upload.cpython-312.pyc,,
|
| 110 |
+
huggingface_hub/cli/__pycache__/upload_large_folder.cpython-312.pyc,,
|
| 111 |
+
huggingface_hub/cli/__pycache__/webhooks.cpython-312.pyc,,
|
| 112 |
+
huggingface_hub/cli/_city_game.py,sha256=2qkC9dCtPwf4-aqrnbN-vApf0YqIcGGjn2v-etrTfqg,20585
|
| 113 |
+
huggingface_hub/cli/_cli_utils.py,sha256=Q5795puu89Kf4fEvQYPjyJmDnyqFEyEr5SW1xQXQk8I,41313
|
| 114 |
+
huggingface_hub/cli/_completion.py,sha256=BDP6Vob9TLFp6K3lr0XOY98FyD-rm22KrjwsO_YGNbE,3759
|
| 115 |
+
huggingface_hub/cli/_cp.py,sha256=Z-2Z_tBs1e4XBqRO5R9QnabU4qTi9HDlbA52jTBaCkY,10436
|
| 116 |
+
huggingface_hub/cli/_errors.py,sha256=X0rUTO-3eCK5v_MLGEza1BxcuXGccPY-h7ShzmuQc34,5907
|
| 117 |
+
huggingface_hub/cli/_file_listing.py,sha256=QRGm9oZS_g0Cv_jLQcUR6iNwBzMrsmbhs1kxwuY6rwk,7910
|
| 118 |
+
huggingface_hub/cli/_framework.py,sha256=HqfAEYGWRSjKABAZi2zVNgryyU9QKW8u-tRXfR_4nQ8,27364
|
| 119 |
+
huggingface_hub/cli/_help_formatter.py,sha256=-vsa3HfHQFkKWms77EGyp9i22t44ETmVt2L-e8qP-KM,1288
|
| 120 |
+
huggingface_hub/cli/_output.py,sha256=A_yLkT0lzIovZV-fS7NZx7hCGiwiqJNtvUr-IbYPgpQ,13908
|
| 121 |
+
huggingface_hub/cli/_skills.py,sha256=b1dlasxALM5KsDG5R1azcETksQ6ssYYZN-kaz-RdHwg,12134
|
| 122 |
+
huggingface_hub/cli/auth.py,sha256=Ew79M60pTMCnS1ewKVK3fd8ZyfHrNjREOmNWuFXy37M,6056
|
| 123 |
+
huggingface_hub/cli/buckets.py,sha256=J8xMP88fQ6ri3f65Z8XEImI2GNA4KKWloLJJQCBezZw,21062
|
| 124 |
+
huggingface_hub/cli/cache.py,sha256=Oa3g53dUYlNIKy6crlXXGxG7lOZFa6iob0-8mMalCDc,28059
|
| 125 |
+
huggingface_hub/cli/collections.py,sha256=ECTb__1zduL3F02ezGkQIaaSmUOVaeBbsGMs_8MTPcI,10078
|
| 126 |
+
huggingface_hub/cli/datasets.py,sha256=X1xMJTFhHH5NJtmjTS6NN1g4ffai6Abh_obDEJM5mvo,10497
|
| 127 |
+
huggingface_hub/cli/deprecated_cli.py,sha256=vAK_CR4NE9uzNJ0I59SyBnIln5nlypG4CPoohMoPMVg,1090
|
| 128 |
+
huggingface_hub/cli/discussions.py,sha256=obvvN4mtsFnfMs67YTZaMvHkVaM6A-FYr5n-wGkF_jE,14029
|
| 129 |
+
huggingface_hub/cli/download.py,sha256=o6fMKJoNQMxCm1RQUnX3blihJ17mantxkf0F68rZIxs,9669
|
| 130 |
+
huggingface_hub/cli/extensions.py,sha256=qNM1DmzcQXt8kPWQfISc8Pvyku8BxAs-BOVP6sKRBOM,25572
|
| 131 |
+
huggingface_hub/cli/hf.py,sha256=G2R-Mgo2AX09aRiAb-13eZbO441m9yDTwMCtSUf1iac,5208
|
| 132 |
+
huggingface_hub/cli/inference_endpoints.py,sha256=4pfvPm5PVQizStyXGRBnrev62KvhzSNEL65UEVtRcKw,17418
|
| 133 |
+
huggingface_hub/cli/jobs.py,sha256=-eMUXzpU3Dzxp9RAjff-6eCxYwxH9M3s6KK_MOn6Rgo,49640
|
| 134 |
+
huggingface_hub/cli/lfs.py,sha256=MAccazVPX0n-ySRaPocaQUHP7oBnVrvWZt0RhmNIavs,5936
|
| 135 |
+
huggingface_hub/cli/models.py,sha256=eG7H5yDjCVrdL7W_-wpcl70qXlv8bC-roSEu8AroPws,10148
|
| 136 |
+
huggingface_hub/cli/papers.py,sha256=HvT-8zj2fi14ua6awWpHphlbJ362FEJIwSCBJRQZ_cM,4982
|
| 137 |
+
huggingface_hub/cli/repo_files.py,sha256=sGbD5wND3miF71ThfOBJm4xzPRUpJBeLFdvyj229NAM,2443
|
| 138 |
+
huggingface_hub/cli/repos.py,sha256=QS3xYKvspLhCfO5VvpORrSiF6XhSVFclmBxsacVDP2c,20192
|
| 139 |
+
huggingface_hub/cli/sandbox.py,sha256=rTCZf6WhoDa7UiNhsTU_4Lh5uKqKYOs73xXGAAqJGdA,18379
|
| 140 |
+
huggingface_hub/cli/skills.py,sha256=JQkqD43bfr8IapIVp8rvQpd8NKA0dXSbGJD8g-u51w8,19473
|
| 141 |
+
huggingface_hub/cli/spaces.py,sha256=AU655GGrQmF1s1yO8yO6ml2Z8veE7zsh4UMuR5b13RI,40800
|
| 142 |
+
huggingface_hub/cli/system.py,sha256=NtICLnQ49BHFpm2Cl37IV_h21L6mufxVDfse8Lp38HA,1760
|
| 143 |
+
huggingface_hub/cli/upload.py,sha256=P6sq8Dj81a2wazUgZEqbliRleVAAmJrf8ajFDDzHrBE,11318
|
| 144 |
+
huggingface_hub/cli/upload_large_folder.py,sha256=A-2qxAdLrYd8IogfZS2nDhSR1cpA_aaxhXst638WkAk,4081
|
| 145 |
+
huggingface_hub/cli/webhooks.py,sha256=HdpPp01c6Ece_EuNNJr46rnRki3vF4j4o9-SqYRUHnM,8550
|
| 146 |
+
huggingface_hub/community.py,sha256=N5OE5Rbc2BMwpNXCFOPQAwn0otqQunsXdEnSE_0J2Xo,12325
|
| 147 |
+
huggingface_hub/constants.py,sha256=eI3-JDy6jkG1EuXAjUdVdG67kbj6gxGNlr9In2-5AMc,13182
|
| 148 |
+
huggingface_hub/dataclasses.py,sha256=47qPdMJMuzFFjPwqa_bRvzh7nxwXx_lXE8h3eblkxp8,25940
|
| 149 |
+
huggingface_hub/errors.py,sha256=eso8GCrCcDv1Yb6NDBqyFt_Vr9PLCOsueNylNlDXMD4,18391
|
| 150 |
+
huggingface_hub/fastai_utils.py,sha256=jwKeVXH_VP0zxnOKVNQCVCkF-stH70l-bExbbrYkBKQ,16583
|
| 151 |
+
huggingface_hub/file_download.py,sha256=jSwr6Ze9CT0hScAgEZhRx3LF3BRgZSZLoptYwotQxis,87253
|
| 152 |
+
huggingface_hub/hf_api.py,sha256=VBGUpyUhZ__USFBMlNv20CZxzTKnkJ_CdRXez-LX7Wk,659053
|
| 153 |
+
huggingface_hub/hf_file_system.py,sha256=1Y6BqYHafnwulGNufJtzWfMU3Q3sbaW7oOqUcrNlvc4,60581
|
| 154 |
+
huggingface_hub/hub_mixin.py,sha256=ljKAtm3qQsY-ARtxY-PCFx0koFXLI37JytMrzpqfnQo,36912
|
| 155 |
+
huggingface_hub/inference/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 156 |
+
huggingface_hub/inference/__pycache__/__init__.cpython-312.pyc,,
|
| 157 |
+
huggingface_hub/inference/__pycache__/_client.cpython-312.pyc,,
|
| 158 |
+
huggingface_hub/inference/__pycache__/_common.cpython-312.pyc,,
|
| 159 |
+
huggingface_hub/inference/_client.py,sha256=bN5cj4tBHPD6v603uq4CJjMB_mmmpdVcfXtl9XIOVqc,157679
|
| 160 |
+
huggingface_hub/inference/_common.py,sha256=X-fBP8s6xuNTAuQsGVIethE8dNQaa-mK7Ds54qVVDz8,14999
|
| 161 |
+
huggingface_hub/inference/_generated/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 162 |
+
huggingface_hub/inference/_generated/__pycache__/__init__.cpython-312.pyc,,
|
| 163 |
+
huggingface_hub/inference/_generated/__pycache__/_async_client.cpython-312.pyc,,
|
| 164 |
+
huggingface_hub/inference/_generated/_async_client.py,sha256=imtfJD9m3qxeo_59gox3nnV8Tr8dfQF3dQF0Joy5K4g,160890
|
| 165 |
+
huggingface_hub/inference/_generated/types/__init__.py,sha256=e625ENOmTUM4uUL1eAlsZOK7CovNoGBDH-TxSNQhaC4,6869
|
| 166 |
+
huggingface_hub/inference/_generated/types/__pycache__/__init__.cpython-312.pyc,,
|
| 167 |
+
huggingface_hub/inference/_generated/types/__pycache__/audio_classification.cpython-312.pyc,,
|
| 168 |
+
huggingface_hub/inference/_generated/types/__pycache__/audio_to_audio.cpython-312.pyc,,
|
| 169 |
+
huggingface_hub/inference/_generated/types/__pycache__/automatic_speech_recognition.cpython-312.pyc,,
|
| 170 |
+
huggingface_hub/inference/_generated/types/__pycache__/base.cpython-312.pyc,,
|
| 171 |
+
huggingface_hub/inference/_generated/types/__pycache__/chat_completion.cpython-312.pyc,,
|
| 172 |
+
huggingface_hub/inference/_generated/types/__pycache__/depth_estimation.cpython-312.pyc,,
|
| 173 |
+
huggingface_hub/inference/_generated/types/__pycache__/document_question_answering.cpython-312.pyc,,
|
| 174 |
+
huggingface_hub/inference/_generated/types/__pycache__/feature_extraction.cpython-312.pyc,,
|
| 175 |
+
huggingface_hub/inference/_generated/types/__pycache__/fill_mask.cpython-312.pyc,,
|
| 176 |
+
huggingface_hub/inference/_generated/types/__pycache__/image_classification.cpython-312.pyc,,
|
| 177 |
+
huggingface_hub/inference/_generated/types/__pycache__/image_segmentation.cpython-312.pyc,,
|
| 178 |
+
huggingface_hub/inference/_generated/types/__pycache__/image_text_to_image.cpython-312.pyc,,
|
| 179 |
+
huggingface_hub/inference/_generated/types/__pycache__/image_text_to_video.cpython-312.pyc,,
|
| 180 |
+
huggingface_hub/inference/_generated/types/__pycache__/image_to_image.cpython-312.pyc,,
|
| 181 |
+
huggingface_hub/inference/_generated/types/__pycache__/image_to_text.cpython-312.pyc,,
|
| 182 |
+
huggingface_hub/inference/_generated/types/__pycache__/image_to_video.cpython-312.pyc,,
|
| 183 |
+
huggingface_hub/inference/_generated/types/__pycache__/object_detection.cpython-312.pyc,,
|
| 184 |
+
huggingface_hub/inference/_generated/types/__pycache__/question_answering.cpython-312.pyc,,
|
| 185 |
+
huggingface_hub/inference/_generated/types/__pycache__/sentence_similarity.cpython-312.pyc,,
|
| 186 |
+
huggingface_hub/inference/_generated/types/__pycache__/summarization.cpython-312.pyc,,
|
| 187 |
+
huggingface_hub/inference/_generated/types/__pycache__/table_question_answering.cpython-312.pyc,,
|
| 188 |
+
huggingface_hub/inference/_generated/types/__pycache__/text2text_generation.cpython-312.pyc,,
|
| 189 |
+
huggingface_hub/inference/_generated/types/__pycache__/text_classification.cpython-312.pyc,,
|
| 190 |
+
huggingface_hub/inference/_generated/types/__pycache__/text_generation.cpython-312.pyc,,
|
| 191 |
+
huggingface_hub/inference/_generated/types/__pycache__/text_to_audio.cpython-312.pyc,,
|
| 192 |
+
huggingface_hub/inference/_generated/types/__pycache__/text_to_image.cpython-312.pyc,,
|
| 193 |
+
huggingface_hub/inference/_generated/types/__pycache__/text_to_speech.cpython-312.pyc,,
|
| 194 |
+
huggingface_hub/inference/_generated/types/__pycache__/text_to_video.cpython-312.pyc,,
|
| 195 |
+
huggingface_hub/inference/_generated/types/__pycache__/token_classification.cpython-312.pyc,,
|
| 196 |
+
huggingface_hub/inference/_generated/types/__pycache__/translation.cpython-312.pyc,,
|
| 197 |
+
huggingface_hub/inference/_generated/types/__pycache__/video_classification.cpython-312.pyc,,
|
| 198 |
+
huggingface_hub/inference/_generated/types/__pycache__/visual_question_answering.cpython-312.pyc,,
|
| 199 |
+
huggingface_hub/inference/_generated/types/__pycache__/zero_shot_classification.cpython-312.pyc,,
|
| 200 |
+
huggingface_hub/inference/_generated/types/__pycache__/zero_shot_image_classification.cpython-312.pyc,,
|
| 201 |
+
huggingface_hub/inference/_generated/types/__pycache__/zero_shot_object_detection.cpython-312.pyc,,
|
| 202 |
+
huggingface_hub/inference/_generated/types/audio_classification.py,sha256=DGWEvrRPX7xpXlbYY4LMojGcULdEZFTshhNR81rTNcQ,1567
|
| 203 |
+
huggingface_hub/inference/_generated/types/audio_to_audio.py,sha256=2Ep4WkePL7oJwcp5nRJqApwviumGHbft9HhXE9XLHj4,891
|
| 204 |
+
huggingface_hub/inference/_generated/types/automatic_speech_recognition.py,sha256=X0uCj9qwAcOmlKtV3vWH5cAgLGY0PuYIy2eSH7GE1qs,5439
|
| 205 |
+
huggingface_hub/inference/_generated/types/base.py,sha256=EPWp1qudjeEimEAyQ-ptdxpAACoRM8tW342-Ds7pP3I,6938
|
| 206 |
+
huggingface_hub/inference/_generated/types/chat_completion.py,sha256=3yc06ZI0NCZzsaeoxSMWyIHqGc8Vn_6aExncuXa1llE,11100
|
| 207 |
+
huggingface_hub/inference/_generated/types/depth_estimation.py,sha256=5Kn4xNGJg235Cofr1lzO59eRGCuLTZun8z5t6a2do8Q,910
|
| 208 |
+
huggingface_hub/inference/_generated/types/document_question_answering.py,sha256=aUZcrDGexjw8Fnm2rACm_3my77V15NnQHZxj-sa7bjo,3146
|
| 209 |
+
huggingface_hub/inference/_generated/types/feature_extraction.py,sha256=DiO47PqwhdNta_KPDBsXfCPIL6BWNhyCLymxORlqUA0,1509
|
| 210 |
+
huggingface_hub/inference/_generated/types/fill_mask.py,sha256=NhEskgoiMst7U_0cV_S-wryga4_2T5LgpbyQ23vHMp0,1680
|
| 211 |
+
huggingface_hub/inference/_generated/types/image_classification.py,sha256=xWr4OY65EcIIhd7MI610a7xlaAVHQeydi8Gc7tlaPTU,1579
|
| 212 |
+
huggingface_hub/inference/_generated/types/image_segmentation.py,sha256=lZKzbn_gkSi1sYGLb9ryeRr0aDAVrfYh0H5Iiv5JNsY,1935
|
| 213 |
+
huggingface_hub/inference/_generated/types/image_text_to_image.py,sha256=pRQgYKXJbIpEjRBxuIE6NRDtk_km9DSTQ2s2qxkYJRM,2585
|
| 214 |
+
huggingface_hub/inference/_generated/types/image_text_to_video.py,sha256=MVhP8D4eYjpT3hWYkkpuiME-hWY09o7C4rIn_wmnAmY,2450
|
| 215 |
+
huggingface_hub/inference/_generated/types/image_to_image.py,sha256=P9TeMFSnZI_pa6DyinzDPWL0PNm_INJwsqFUEzpwIcU,2262
|
| 216 |
+
huggingface_hub/inference/_generated/types/image_to_text.py,sha256=DCDS0Nqi-4AuATitvZm4EgrzYQuQEQ5lzBcaHuCmHnY,4740
|
| 217 |
+
huggingface_hub/inference/_generated/types/image_to_video.py,sha256=iMCjiFTUza9AW_MyJ1videhYgvMY9QSzQ59kNdTE9QY,2206
|
| 218 |
+
huggingface_hub/inference/_generated/types/object_detection.py,sha256=zNILlyZJh59rNNfqXM5x9uprDCPfEU-bvBtabeKSMzI,1965
|
| 219 |
+
huggingface_hub/inference/_generated/types/question_answering.py,sha256=lIRf8DjRiAsjzWUBEsGt354SB4bvejLokf-8luHw6_o,2845
|
| 220 |
+
huggingface_hub/inference/_generated/types/sentence_similarity.py,sha256=eNGiO4dR-Lft9yOLE0E97jfVyOT_ExDWZW5GeJGdatU,1027
|
| 221 |
+
huggingface_hub/inference/_generated/types/summarization.py,sha256=5Dpt6LRteT-hO9esa3Ty_-xSL5U-zTtVZzy3iKwZRng,1472
|
| 222 |
+
huggingface_hub/inference/_generated/types/table_question_answering.py,sha256=bwn616XJ-eLa5JKzn3m9rZZ3z63INGEUwRSOCWlEh-4,2269
|
| 223 |
+
huggingface_hub/inference/_generated/types/text2text_generation.py,sha256=fotSlPWtIlp_LG26AQvNRXxU-jCUfda5PWsxCkbFeKM,1591
|
| 224 |
+
huggingface_hub/inference/_generated/types/text_classification.py,sha256=uamBzz4YzWQ9mb6yuriykX8r47ZHf0K3eJpOLzB2qJw,1439
|
| 225 |
+
huggingface_hub/inference/_generated/types/text_generation.py,sha256=FRUljypvCSQ2RaiylhlHeLJfHNy8qZvuty6SCB_zcaA,5813
|
| 226 |
+
huggingface_hub/inference/_generated/types/text_to_audio.py,sha256=CiaTUSBdFtOs3gGTosqyQrjCwrN8mVJLRxDDWUtwZpQ,4677
|
| 227 |
+
huggingface_hub/inference/_generated/types/text_to_image.py,sha256=Ju25WIDHE-1n8jlZ_udG4rpAaPYpmghR7-cDgVfuf48,1869
|
| 228 |
+
huggingface_hub/inference/_generated/types/text_to_speech.py,sha256=WqDzWkhZsDcjapkoFrkyjF903SKs7aHhjypsYrn8oBw,4693
|
| 229 |
+
huggingface_hub/inference/_generated/types/text_to_video.py,sha256=KjcDbtChwrIxIdTH6vcesUaMcjL2xjPf2nWEnHazj4Y,1756
|
| 230 |
+
huggingface_hub/inference/_generated/types/token_classification.py,sha256=8KRBlqgFDszaUnPMvdRkZNQaZBtDfBhKZ6SggQldQMM,1894
|
| 231 |
+
huggingface_hub/inference/_generated/types/translation.py,sha256=-j2PC1-qfoxvGMaKesqf5jXelqj0BDlEpfvZ7dsIEJM,1742
|
| 232 |
+
huggingface_hub/inference/_generated/types/video_classification.py,sha256=vfaCqp8MuRMMtGvYCX0x4-AcwEd71kPHgSYJTNIOxLQ,1668
|
| 233 |
+
huggingface_hub/inference/_generated/types/visual_question_answering.py,sha256=sWIB-SuEpW21oU6O5qQF3tt5PavUFsFOa8Xg4upTtek,1654
|
| 234 |
+
huggingface_hub/inference/_generated/types/zero_shot_classification.py,sha256=gx-7WHad7xsNa89iSKSteKHjaHrKbIyzN_nSdJN3HCY,1697
|
| 235 |
+
huggingface_hub/inference/_generated/types/zero_shot_image_classification.py,sha256=JZTQvcbSGrOQlWcPuJvAMT8YziDpBRn1O2RQSw507uY,1449
|
| 236 |
+
huggingface_hub/inference/_generated/types/zero_shot_object_detection.py,sha256=sjdpVUN5zW9aYBymLVUs6i5HVk2qkUBO9ysEjHmsXVM,1605
|
| 237 |
+
huggingface_hub/inference/_mcp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 238 |
+
huggingface_hub/inference/_mcp/__pycache__/__init__.cpython-312.pyc,,
|
| 239 |
+
huggingface_hub/inference/_mcp/__pycache__/_cli_hacks.cpython-312.pyc,,
|
| 240 |
+
huggingface_hub/inference/_mcp/__pycache__/agent.cpython-312.pyc,,
|
| 241 |
+
huggingface_hub/inference/_mcp/__pycache__/cli.cpython-312.pyc,,
|
| 242 |
+
huggingface_hub/inference/_mcp/__pycache__/constants.cpython-312.pyc,,
|
| 243 |
+
huggingface_hub/inference/_mcp/__pycache__/mcp_client.cpython-312.pyc,,
|
| 244 |
+
huggingface_hub/inference/_mcp/__pycache__/types.cpython-312.pyc,,
|
| 245 |
+
huggingface_hub/inference/_mcp/__pycache__/utils.cpython-312.pyc,,
|
| 246 |
+
huggingface_hub/inference/_mcp/_cli_hacks.py,sha256=kIA8FfRfOWS3SrZrMTbuVOjE6yxfKfMK75Co5egTWHA,3284
|
| 247 |
+
huggingface_hub/inference/_mcp/agent.py,sha256=ufIzMGHore5n252hV5GZPM0ouDXIl6tv5Jl_5gHXnbg,4250
|
| 248 |
+
huggingface_hub/inference/_mcp/cli.py,sha256=RKdVQ_VdEgf1AL_QBCvwrsUQ0Ux4R1yerrE46DrV5C0,9642
|
| 249 |
+
huggingface_hub/inference/_mcp/constants.py,sha256=0Ih6ivEvG-pfF8NwErFngzP4Rof4lQoz6ms_eKSAkUI,2463
|
| 250 |
+
huggingface_hub/inference/_mcp/mcp_client.py,sha256=dGp8PhN6aVw4bDnuSySFSiguHUiz-nzhgv89CVdO7pI,17243
|
| 251 |
+
huggingface_hub/inference/_mcp/types.py,sha256=yHNfPsM9MhD06oeKdkbmrBsW-3WhUeqA26fyfRfx_bk,929
|
| 252 |
+
huggingface_hub/inference/_mcp/utils.py,sha256=gxSB_rBjQ6VrkApKFsxk6-UzhijxkDVNuZrsjW5pL8k,4318
|
| 253 |
+
huggingface_hub/inference/_providers/__init__.py,sha256=TNWnSNPk0RmToBysTc5D1COm0vHEJoGom0Yh7oG2wC4,9838
|
| 254 |
+
huggingface_hub/inference/_providers/__pycache__/__init__.cpython-312.pyc,,
|
| 255 |
+
huggingface_hub/inference/_providers/__pycache__/_common.cpython-312.pyc,,
|
| 256 |
+
huggingface_hub/inference/_providers/__pycache__/cerebras.cpython-312.pyc,,
|
| 257 |
+
huggingface_hub/inference/_providers/__pycache__/cohere.cpython-312.pyc,,
|
| 258 |
+
huggingface_hub/inference/_providers/__pycache__/deepinfra.cpython-312.pyc,,
|
| 259 |
+
huggingface_hub/inference/_providers/__pycache__/fal_ai.cpython-312.pyc,,
|
| 260 |
+
huggingface_hub/inference/_providers/__pycache__/featherless_ai.cpython-312.pyc,,
|
| 261 |
+
huggingface_hub/inference/_providers/__pycache__/fireworks_ai.cpython-312.pyc,,
|
| 262 |
+
huggingface_hub/inference/_providers/__pycache__/groq.cpython-312.pyc,,
|
| 263 |
+
huggingface_hub/inference/_providers/__pycache__/hf_inference.cpython-312.pyc,,
|
| 264 |
+
huggingface_hub/inference/_providers/__pycache__/novita.cpython-312.pyc,,
|
| 265 |
+
huggingface_hub/inference/_providers/__pycache__/nscale.cpython-312.pyc,,
|
| 266 |
+
huggingface_hub/inference/_providers/__pycache__/openai.cpython-312.pyc,,
|
| 267 |
+
huggingface_hub/inference/_providers/__pycache__/ovhcloud.cpython-312.pyc,,
|
| 268 |
+
huggingface_hub/inference/_providers/__pycache__/publicai.cpython-312.pyc,,
|
| 269 |
+
huggingface_hub/inference/_providers/__pycache__/replicate.cpython-312.pyc,,
|
| 270 |
+
huggingface_hub/inference/_providers/__pycache__/scaleway.cpython-312.pyc,,
|
| 271 |
+
huggingface_hub/inference/_providers/__pycache__/together.cpython-312.pyc,,
|
| 272 |
+
huggingface_hub/inference/_providers/__pycache__/wavespeed.cpython-312.pyc,,
|
| 273 |
+
huggingface_hub/inference/_providers/__pycache__/zai_org.cpython-312.pyc,,
|
| 274 |
+
huggingface_hub/inference/_providers/_common.py,sha256=9CjlMAtb7W0-GdB1Z-VkV0GKZ0Zm68rIuicdGE-765M,13716
|
| 275 |
+
huggingface_hub/inference/_providers/cerebras.py,sha256=QOJ-1U-os7uE7p6eUnn_P_APq-yQhx28be7c3Tq2EuA,210
|
| 276 |
+
huggingface_hub/inference/_providers/cohere.py,sha256=P9kbIuvQ2rXI1yNmgbw5VKFFTE0huLq2k-BCyDkDico,1226
|
| 277 |
+
huggingface_hub/inference/_providers/deepinfra.py,sha256=4Behgf5V7FTv7CbN6vPEIYwv1z4gztdRRU-KVoOgxVE,4703
|
| 278 |
+
huggingface_hub/inference/_providers/fal_ai.py,sha256=Y2vo5Dl3e8EoehplwNshu8LbDT1e7V4ZyhAMqs0wXws,11705
|
| 279 |
+
huggingface_hub/inference/_providers/featherless_ai.py,sha256=C8OHdFpoFyA--pawLTekUmUSRq4sw_r0D-cSPekD4kE,1347
|
| 280 |
+
huggingface_hub/inference/_providers/fireworks_ai.py,sha256=go6XPum8u0-g768HJ_r0S4Gb445gZJxnuY_acktz-9c,1188
|
| 281 |
+
huggingface_hub/inference/_providers/groq.py,sha256=JTk2JV4ZOlaohho7zLAFQtk92kGVsPmLJ1hmzcwsqvQ,315
|
| 282 |
+
huggingface_hub/inference/_providers/hf_inference.py,sha256=d2vdCKSi5CtyQqYndHHvH7SY131-7YHUK3yE7653eIc,9467
|
| 283 |
+
huggingface_hub/inference/_providers/novita.py,sha256=ATEoSdPAPLMfx3JpBc0sOyLh4upJYP6xHBuo4YEDYvg,2470
|
| 284 |
+
huggingface_hub/inference/_providers/nscale.py,sha256=T1L2JLI9LqYT9_YEdW76YEtxfDNtdGkoFhH-p2LmSxg,1767
|
| 285 |
+
huggingface_hub/inference/_providers/openai.py,sha256=wwjaaQ55xLmDsDnHpZk52xbuLoGZfWzJkFsE8AdFVaI,1054
|
| 286 |
+
huggingface_hub/inference/_providers/ovhcloud.py,sha256=tdmymlkbddMJKV7NRZ-tH2wymbLPFDTqUSXpWJUXyDQ,314
|
| 287 |
+
huggingface_hub/inference/_providers/publicai.py,sha256=1I2W6rORloB5QHSvky4njZO2XKLTwA-kPdNoauoT5rg,210
|
| 288 |
+
huggingface_hub/inference/_providers/replicate.py,sha256=hte0ZB2RtGFwpAuLrFp2Gbgsn3EOlccCnJkWTDTW__A,6027
|
| 289 |
+
huggingface_hub/inference/_providers/scaleway.py,sha256=MfIc7ZND1sPr__rOmNHZVg0VpECQo0bVyksgIm_32xQ,1174
|
| 290 |
+
huggingface_hub/inference/_providers/together.py,sha256=lrymDZ86n5yoR_Zz7o3AzzSePyo0s7BOBU5digLxb5o,12220
|
| 291 |
+
huggingface_hub/inference/_providers/wavespeed.py,sha256=MGM7Y7r2nQiH_EH0t5UE1o1fT-o3sS7RaQlicS9WHsg,5028
|
| 292 |
+
huggingface_hub/inference/_providers/zai_org.py,sha256=gLJZOEmCPmUZvdM7VDn2nxm4ac3veHdoMgQNR63UeWE,4739
|
| 293 |
+
huggingface_hub/lfs.py,sha256=8ymYNHRXgvgUUM9w0EAnC-vkSOOq_1EFJEJNoevoeE8,16588
|
| 294 |
+
huggingface_hub/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 295 |
+
huggingface_hub/repocard.py,sha256=ytBgqomIuM3zOeTPfzQNk_stlswh8DttLDvTbX_woPI,35582
|
| 296 |
+
huggingface_hub/repocard_data.py,sha256=CRW3puz-efDcoGjKIgZv6p3LKKKYVgcy-FGr96zAFOg,34251
|
| 297 |
+
huggingface_hub/serialization/__init__.py,sha256=jCiw_vVQYW52gwVfWiqgocf2Q19kGTQlRGVpf-4SLP8,963
|
| 298 |
+
huggingface_hub/serialization/__pycache__/__init__.cpython-312.pyc,,
|
| 299 |
+
huggingface_hub/serialization/__pycache__/_base.cpython-312.pyc,,
|
| 300 |
+
huggingface_hub/serialization/__pycache__/_dduf.cpython-312.pyc,,
|
| 301 |
+
huggingface_hub/serialization/__pycache__/_torch.cpython-312.pyc,,
|
| 302 |
+
huggingface_hub/serialization/_base.py,sha256=8vYeDIsqgyOO3I_uii44Bkb50LsMz3kkD4gwAPzhfWU,8436
|
| 303 |
+
huggingface_hub/serialization/_dduf.py,sha256=FmGRg5wkXI5sNCgZgCNJFmqb_nVrrQYOHf4Lqq0d64I,15385
|
| 304 |
+
huggingface_hub/serialization/_torch.py,sha256=BtaCP-G3oYRP6Pj9MhI-ygBsk3JbBPnVDW9huSOgtkk,46897
|
| 305 |
+
huggingface_hub/templates/datasetcard_template.md,sha256=W-EMqR6wndbrnZorkVv56URWPG49l7MATGeI015kTvs,5503
|
| 306 |
+
huggingface_hub/templates/modelcard_template.md,sha256=4AqArS3cqdtbit5Bo-DhjcnDFR-pza5hErLLTPM4Yuc,6870
|
| 307 |
+
huggingface_hub/utils/__init__.py,sha256=SHfYVviFx_oyeA0EFOz4kXFeRg-SAbDlgyb8tk4TpeU,4026
|
| 308 |
+
huggingface_hub/utils/__pycache__/__init__.cpython-312.pyc,,
|
| 309 |
+
huggingface_hub/utils/__pycache__/_auth.cpython-312.pyc,,
|
| 310 |
+
huggingface_hub/utils/__pycache__/_cache_assets.cpython-312.pyc,,
|
| 311 |
+
huggingface_hub/utils/__pycache__/_cache_manager.cpython-312.pyc,,
|
| 312 |
+
huggingface_hub/utils/__pycache__/_chunk_utils.cpython-312.pyc,,
|
| 313 |
+
huggingface_hub/utils/__pycache__/_datetime.cpython-312.pyc,,
|
| 314 |
+
huggingface_hub/utils/__pycache__/_deprecation.cpython-312.pyc,,
|
| 315 |
+
huggingface_hub/utils/__pycache__/_detect_agent.cpython-312.pyc,,
|
| 316 |
+
huggingface_hub/utils/__pycache__/_dotenv.cpython-312.pyc,,
|
| 317 |
+
huggingface_hub/utils/__pycache__/_experimental.cpython-312.pyc,,
|
| 318 |
+
huggingface_hub/utils/__pycache__/_fixes.cpython-312.pyc,,
|
| 319 |
+
huggingface_hub/utils/__pycache__/_git_credential.cpython-312.pyc,,
|
| 320 |
+
huggingface_hub/utils/__pycache__/_headers.cpython-312.pyc,,
|
| 321 |
+
huggingface_hub/utils/__pycache__/_hf_uris.cpython-312.pyc,,
|
| 322 |
+
huggingface_hub/utils/__pycache__/_http.cpython-312.pyc,,
|
| 323 |
+
huggingface_hub/utils/__pycache__/_lfs.cpython-312.pyc,,
|
| 324 |
+
huggingface_hub/utils/__pycache__/_oauth_device.cpython-312.pyc,,
|
| 325 |
+
huggingface_hub/utils/__pycache__/_pagination.cpython-312.pyc,,
|
| 326 |
+
huggingface_hub/utils/__pycache__/_parsing.cpython-312.pyc,,
|
| 327 |
+
huggingface_hub/utils/__pycache__/_paths.cpython-312.pyc,,
|
| 328 |
+
huggingface_hub/utils/__pycache__/_runtime.cpython-312.pyc,,
|
| 329 |
+
huggingface_hub/utils/__pycache__/_safetensors.cpython-312.pyc,,
|
| 330 |
+
huggingface_hub/utils/__pycache__/_subprocess.cpython-312.pyc,,
|
| 331 |
+
huggingface_hub/utils/__pycache__/_telemetry.cpython-312.pyc,,
|
| 332 |
+
huggingface_hub/utils/__pycache__/_terminal.cpython-312.pyc,,
|
| 333 |
+
huggingface_hub/utils/__pycache__/_typing.cpython-312.pyc,,
|
| 334 |
+
huggingface_hub/utils/__pycache__/_validators.cpython-312.pyc,,
|
| 335 |
+
huggingface_hub/utils/__pycache__/_verification.cpython-312.pyc,,
|
| 336 |
+
huggingface_hub/utils/__pycache__/_xet.cpython-312.pyc,,
|
| 337 |
+
huggingface_hub/utils/__pycache__/_xet_progress_reporting.cpython-312.pyc,,
|
| 338 |
+
huggingface_hub/utils/__pycache__/endpoint_helpers.cpython-312.pyc,,
|
| 339 |
+
huggingface_hub/utils/__pycache__/insecure_hashlib.cpython-312.pyc,,
|
| 340 |
+
huggingface_hub/utils/__pycache__/logging.cpython-312.pyc,,
|
| 341 |
+
huggingface_hub/utils/__pycache__/sha.cpython-312.pyc,,
|
| 342 |
+
huggingface_hub/utils/__pycache__/tqdm.cpython-312.pyc,,
|
| 343 |
+
huggingface_hub/utils/_auth.py,sha256=Ykuq3yi67jxHmFdyLSc43xvGuCAIR7-h-dajX8IxpGQ,19958
|
| 344 |
+
huggingface_hub/utils/_cache_assets.py,sha256=nnzHRtQAR50dQeIK6qKddsmjjTW9v9HZ7b9bq7PJqss,5691
|
| 345 |
+
huggingface_hub/utils/_cache_manager.py,sha256=2StxP-nHZ5W9_hi8N9wBFqRNLw5HwO0h9HC7NTAGaFE,34955
|
| 346 |
+
huggingface_hub/utils/_chunk_utils.py,sha256=pTjy8Z-KLU4W_6D3OUh3E8lCodWDCd6aJwjNDU0C5U8,2121
|
| 347 |
+
huggingface_hub/utils/_datetime.py,sha256=tbNyI0Dkh27oScPUtLIT_8apqIIkXZYbigjOn9S3aMw,2755
|
| 348 |
+
huggingface_hub/utils/_deprecation.py,sha256=n4kNHbGipquSObJ-gxodcfd6lqoe_8s-VIsTuo3Oruk,4865
|
| 349 |
+
huggingface_hub/utils/_detect_agent.py,sha256=Iw2KW9BUZWfIypn9CtiTmEibHwKK9xx5Ar48z1cMU-Q,7337
|
| 350 |
+
huggingface_hub/utils/_dotenv.py,sha256=NdlEM8OXtzwlwmJCmdc6oGubFObrpgr408y8gnSs7ls,2604
|
| 351 |
+
huggingface_hub/utils/_experimental.py,sha256=q9vUvc1JybVFRQ0GRREG-BLouZEJC_40MxcwbAlOud0,2464
|
| 352 |
+
huggingface_hub/utils/_fixes.py,sha256=jTK1VLmc0ZC9ROSXjKoL5F6kOZFByzirRWIdXxhBfWU,4124
|
| 353 |
+
huggingface_hub/utils/_git_credential.py,sha256=1BhjvIScCOAToDORLOKrR3Szs-m0E5AYHPmC0SD7Nrs,4548
|
| 354 |
+
huggingface_hub/utils/_headers.py,sha256=Q9bu9mvOpm-9rfv-YRlr_Ywy_aMZkmRcN3MbVEcJAJA,8234
|
| 355 |
+
huggingface_hub/utils/_hf_uris.py,sha256=RTHrVKLT5vVU-ca8roXHrKwbN3njowanvxHjx5B4sUg,27558
|
| 356 |
+
huggingface_hub/utils/_http.py,sha256=C_mC63TsaxpmzyYBPHCneXKFLACEytAkBwxRwMNxcB4,46014
|
| 357 |
+
huggingface_hub/utils/_lfs.py,sha256=xMU-ROgNAUpDkzbH6yRZsE-eVYUYTNMGrgVb_QdTv-k,3942
|
| 358 |
+
huggingface_hub/utils/_oauth_device.py,sha256=o7ICmI01yDt1oAFNMUJvN1ThSfaCDpC8AHYSQgcnFGw,7983
|
| 359 |
+
huggingface_hub/utils/_pagination.py,sha256=h-TJjFbX3FqkA1T0tGZ0EhxMvuRSCg-UfL_a-BMs54I,1943
|
| 360 |
+
huggingface_hub/utils/_parsing.py,sha256=DVWuO6s_XMiGfXyc0jyX5hi_yGgBHpF9KLoeQM-VVK0,3586
|
| 361 |
+
huggingface_hub/utils/_paths.py,sha256=kWpUMIK9rmKb2LHgHCkk2DnroDzucrwbj-urCJCgfGw,5962
|
| 362 |
+
huggingface_hub/utils/_runtime.py,sha256=GVJ_Dt6y_48TZWl0ui9yPdW8M7rqGblRGyUqKaXxkCo,13493
|
| 363 |
+
huggingface_hub/utils/_safetensors.py,sha256=qFE7OA-vjU8X0zBBtOeNRzLu147KF-PdFoaxkYfWB4M,4426
|
| 364 |
+
huggingface_hub/utils/_subprocess.py,sha256=tFVBBNot_HLVqQ79y873TGb12C4PUTMwub-GhzDTemE,4542
|
| 365 |
+
huggingface_hub/utils/_telemetry.py,sha256=Tpa3YmOLhK_MEnL2i2fRLQy8aqAEZWbj6MKC18Hs8BA,4824
|
| 366 |
+
huggingface_hub/utils/_terminal.py,sha256=whHgs0Co-1LatoCmJE_ojqE_cWP6b5dWPWpU-uSFWUU,8969
|
| 367 |
+
huggingface_hub/utils/_typing.py,sha256=1LeE785YedppXSR9a1fQDu5rhTxX5v9kBYBaHrP65rA,3542
|
| 368 |
+
huggingface_hub/utils/_validators.py,sha256=tuC1U4yxB-4XKIajZMnKZUSKvZ6qPpydY8LItfa0g40,8419
|
| 369 |
+
huggingface_hub/utils/_verification.py,sha256=ZSilnolSkYmHB3vmBlWuuVr53xz59P5uGnxC3H-Hjc0,5434
|
| 370 |
+
huggingface_hub/utils/_xet.py,sha256=YtEzhvXi21VB4DtrnqGiSh2_Ox77XhVzLlDIwcnYxj0,6305
|
| 371 |
+
huggingface_hub/utils/_xet_progress_reporting.py,sha256=MnNCxB9ieflArNNyz3R4kpkjOdt6mQxi8qp8xqzXQTM,14162
|
| 372 |
+
huggingface_hub/utils/endpoint_helpers.py,sha256=9VtIAlxQ5H_4y30sjCAgbu7XCqAtNLC7aRYxaNn0hLI,2366
|
| 373 |
+
huggingface_hub/utils/insecure_hashlib.py,sha256=z3dVUFvdBZ8kQI_8Vzvvlr3ims-EBiY-SYPdnzIKOkw,1008
|
| 374 |
+
huggingface_hub/utils/logging.py,sha256=WaXk5gRa8Ml_LUIH34QCr8suYj8i_8Wot4IDnYJyWyM,4870
|
| 375 |
+
huggingface_hub/utils/sha.py,sha256=h8wxheZpcv671RhtiIFcFmQTDSrogN3kwQx3ZaNEUHg,2121
|
| 376 |
+
huggingface_hub/utils/tqdm.py,sha256=KbHhkB5g76JgGOGCcjAQOaR-oc-wzd4Sr3wqd41ny7k,13350
|
.venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/REQUESTED
ADDED
|
File without changes
|
.venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: setuptools (83.0.0)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
| 5 |
+
|
.venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/entry_points.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[console_scripts]
|
| 2 |
+
hf = huggingface_hub.cli.hf:main
|
| 3 |
+
huggingface-cli = huggingface_hub.cli.deprecated_cli:main
|
| 4 |
+
tiny-agents = huggingface_hub.inference._mcp.cli:app
|
| 5 |
+
|
| 6 |
+
[fsspec.specs]
|
| 7 |
+
hf = huggingface_hub.HfFileSystem
|
.venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
.venv/lib/python3.12/site-packages/huggingface_hub-1.24.0.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
huggingface_hub
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_datetime.cpython-312.pyc
ADDED
|
Binary file (2.21 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_deprecation.cpython-312.pyc
ADDED
|
Binary file (6.68 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_detect_agent.cpython-312.pyc
ADDED
|
Binary file (8.75 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_dotenv.cpython-312.pyc
ADDED
|
Binary file (3.28 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_experimental.cpython-312.pyc
ADDED
|
Binary file (2.37 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_fixes.cpython-312.pyc
ADDED
|
Binary file (5.63 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_git_credential.cpython-312.pyc
ADDED
|
Binary file (4.93 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_headers.cpython-312.pyc
ADDED
|
Binary file (7.94 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_hf_uris.cpython-312.pyc
ADDED
|
Binary file (28.1 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_http.cpython-312.pyc
ADDED
|
Binary file (45.7 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_lfs.cpython-312.pyc
ADDED
|
Binary file (5.32 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_oauth_device.cpython-312.pyc
ADDED
|
Binary file (8.27 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_pagination.cpython-312.pyc
ADDED
|
Binary file (2.23 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_parsing.cpython-312.pyc
ADDED
|
Binary file (3.91 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_paths.cpython-312.pyc
ADDED
|
Binary file (6 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_runtime.cpython-312.pyc
ADDED
|
Binary file (16.1 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_safetensors.cpython-312.pyc
ADDED
|
Binary file (5.89 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_subprocess.cpython-312.pyc
ADDED
|
Binary file (4.99 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_telemetry.cpython-312.pyc
ADDED
|
Binary file (5.64 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_terminal.cpython-312.pyc
ADDED
|
Binary file (14.6 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_typing.cpython-312.pyc
ADDED
|
Binary file (4.22 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_validators.cpython-312.pyc
ADDED
|
Binary file (8.47 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_verification.cpython-312.pyc
ADDED
|
Binary file (7.54 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_xet.cpython-312.pyc
ADDED
|
Binary file (7.93 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/_xet_progress_reporting.cpython-312.pyc
ADDED
|
Binary file (16.3 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/endpoint_helpers.cpython-312.pyc
ADDED
|
Binary file (2.14 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/insecure_hashlib.cpython-312.pyc
ADDED
|
Binary file (555 Bytes). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/logging.cpython-312.pyc
ADDED
|
Binary file (6.06 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/sha.cpython-312.pyc
ADDED
|
Binary file (2.66 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/__pycache__/tqdm.cpython-312.pyc
ADDED
|
Binary file (14.4 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/_auth.py
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2023 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 helper to get the token from machine (env variable, secret or config file)."""
|
| 15 |
+
|
| 16 |
+
import configparser
|
| 17 |
+
import io
|
| 18 |
+
import logging
|
| 19 |
+
import os
|
| 20 |
+
import time
|
| 21 |
+
import warnings
|
| 22 |
+
from pathlib import Path
|
| 23 |
+
from threading import Lock
|
| 24 |
+
from typing import TypedDict
|
| 25 |
+
|
| 26 |
+
from .. import constants
|
| 27 |
+
from ..errors import DeviceCodeError, OAuthErrorCode, OIDCError
|
| 28 |
+
from ._fixes import WeakFileLock
|
| 29 |
+
from ._oauth_device import refresh_access_token
|
| 30 |
+
from ._runtime import is_colab_enterprise, is_google_colab
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
_SECRET_FILE_MODE = 0o600
|
| 34 |
+
_SECRET_DIR_MODE = 0o700
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def _write_secret(path: Path, content: str) -> None:
|
| 38 |
+
"""Write content to file, restricting both the file and its parent directory to owner-only on POSIX systems."""
|
| 39 |
+
path.parent.mkdir(parents=True, exist_ok=True, mode=_SECRET_DIR_MODE)
|
| 40 |
+
fd = os.open(str(path), os.O_WRONLY | os.O_CREAT | os.O_TRUNC, _SECRET_FILE_MODE)
|
| 41 |
+
with os.fdopen(fd, "w") as f:
|
| 42 |
+
f.write(content)
|
| 43 |
+
try:
|
| 44 |
+
path.chmod(_SECRET_FILE_MODE)
|
| 45 |
+
path.parent.chmod(_SECRET_DIR_MODE)
|
| 46 |
+
except (OSError, NotImplementedError):
|
| 47 |
+
# Windows does not support POSIX modes; chmod() will raise. Best-effort.
|
| 48 |
+
pass
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
_IS_GOOGLE_COLAB_CHECKED = False
|
| 52 |
+
_GOOGLE_COLAB_SECRET_LOCK = Lock()
|
| 53 |
+
_GOOGLE_COLAB_SECRET: str | None = None
|
| 54 |
+
|
| 55 |
+
logger = logging.getLogger(__name__)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def get_token() -> str | None:
|
| 59 |
+
"""
|
| 60 |
+
Get token if user is logged in.
|
| 61 |
+
|
| 62 |
+
Note: in most cases, you should use [`huggingface_hub.utils.build_hf_headers`] instead. This method is only useful
|
| 63 |
+
if you want to retrieve the token for other purposes than sending an HTTP request.
|
| 64 |
+
|
| 65 |
+
If `HF_OIDC_RESOURCE` is set (Trusted Publishers, typically in CI), a short-lived token obtained via OIDC token
|
| 66 |
+
exchange takes precedence. Otherwise the token is retrieved from the `HF_TOKEN` environment variable, then from the
|
| 67 |
+
token file in the Hugging Face home folder. Returns None if user is not logged in. To log in, use [`login`] or
|
| 68 |
+
`hf auth login`.
|
| 69 |
+
|
| 70 |
+
OAuth tokens obtained with the browser-based login come with a refresh token: when such a token is close to
|
| 71 |
+
expiry, it is transparently refreshed and persisted before being returned.
|
| 72 |
+
|
| 73 |
+
Note: if `HF_OIDC_RESOURCE` is set but the OIDC token exchange fails, this raises instead of returning `None`,
|
| 74 |
+
opting into OIDC is explicit, so a failure surfaces as a clear error rather than a silent fallback.
|
| 75 |
+
|
| 76 |
+
Returns:
|
| 77 |
+
`str` or `None`: The token, `None` if it doesn't exist.
|
| 78 |
+
"""
|
| 79 |
+
return (
|
| 80 |
+
_get_token_from_oidc()
|
| 81 |
+
or _get_token_from_environment()
|
| 82 |
+
or _get_token_from_file_refreshed()
|
| 83 |
+
or _get_token_from_google_colab()
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def _get_token_from_google_colab() -> str | None:
|
| 88 |
+
"""Get token from Google Colab secrets vault using `google.colab.userdata.get(...)`.
|
| 89 |
+
|
| 90 |
+
Token is read from the vault only once per session and then stored in a global variable to avoid re-requesting
|
| 91 |
+
access to the vault.
|
| 92 |
+
"""
|
| 93 |
+
# If it's not a Google Colab or it's Colab Enterprise, fallback to environment variable or token file authentication
|
| 94 |
+
if not is_google_colab() or is_colab_enterprise():
|
| 95 |
+
return None
|
| 96 |
+
|
| 97 |
+
# `google.colab.userdata` is not thread-safe
|
| 98 |
+
# This can lead to a deadlock if multiple threads try to access it at the same time
|
| 99 |
+
# (typically when using `snapshot_download`)
|
| 100 |
+
# => use a lock
|
| 101 |
+
# See https://github.com/huggingface/huggingface_hub/issues/1952 for more details.
|
| 102 |
+
with _GOOGLE_COLAB_SECRET_LOCK:
|
| 103 |
+
global _GOOGLE_COLAB_SECRET
|
| 104 |
+
global _IS_GOOGLE_COLAB_CHECKED
|
| 105 |
+
|
| 106 |
+
if _IS_GOOGLE_COLAB_CHECKED: # request access only once
|
| 107 |
+
return _GOOGLE_COLAB_SECRET
|
| 108 |
+
|
| 109 |
+
try:
|
| 110 |
+
from google.colab import userdata # type: ignore
|
| 111 |
+
from google.colab.errors import Error as ColabError # type: ignore
|
| 112 |
+
except ImportError:
|
| 113 |
+
return None
|
| 114 |
+
|
| 115 |
+
try:
|
| 116 |
+
token = userdata.get("HF_TOKEN")
|
| 117 |
+
_GOOGLE_COLAB_SECRET = _clean_token(token)
|
| 118 |
+
except userdata.NotebookAccessError:
|
| 119 |
+
# Means the user has a secret call `HF_TOKEN` and got a popup "please grand access to HF_TOKEN" and refused it
|
| 120 |
+
# => warn user but ignore error => do not re-request access to user
|
| 121 |
+
warnings.warn(
|
| 122 |
+
"\nAccess to the secret `HF_TOKEN` has not been granted on this notebook."
|
| 123 |
+
"\nYou will not be requested again."
|
| 124 |
+
"\nPlease restart the session if you want to be prompted again."
|
| 125 |
+
)
|
| 126 |
+
_GOOGLE_COLAB_SECRET = None
|
| 127 |
+
except userdata.SecretNotFoundError:
|
| 128 |
+
# No `HF_TOKEN` secret defined: simply not logged in via the Colab vault. Not worth a
|
| 129 |
+
# warning now that `login()` is the primary flow (it would even fire during `login()`
|
| 130 |
+
# itself, telling the user to set up a secret while they are busy authenticating).
|
| 131 |
+
logger.info(
|
| 132 |
+
"The secret `HF_TOKEN` does not exist in your Colab secrets. Run `huggingface_hub.login()` to"
|
| 133 |
+
" authenticate (recommended but still optional to access public models or datasets)."
|
| 134 |
+
)
|
| 135 |
+
_GOOGLE_COLAB_SECRET = None
|
| 136 |
+
except ColabError as e:
|
| 137 |
+
# Something happen but we don't know what => recommend to open a GitHub issue
|
| 138 |
+
warnings.warn(f"\nError while fetching `HF_TOKEN` secret value from your vault: '{str(e)}'.")
|
| 139 |
+
_GOOGLE_COLAB_SECRET = None
|
| 140 |
+
|
| 141 |
+
_IS_GOOGLE_COLAB_CHECKED = True
|
| 142 |
+
return _GOOGLE_COLAB_SECRET
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def _get_token_from_environment() -> str | None:
|
| 146 |
+
# `HF_TOKEN` has priority (keep `HUGGING_FACE_HUB_TOKEN` for backward compatibility)
|
| 147 |
+
return _clean_token(os.environ.get("HF_TOKEN") or os.environ.get("HUGGING_FACE_HUB_TOKEN"))
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def _get_token_from_file() -> str | None:
|
| 151 |
+
try:
|
| 152 |
+
return _clean_token(Path(constants.HF_TOKEN_PATH).read_text())
|
| 153 |
+
except FileNotFoundError:
|
| 154 |
+
return None
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
class _OidcTokenCache(TypedDict):
|
| 158 |
+
resource: str
|
| 159 |
+
token: str
|
| 160 |
+
expires_at: float # monotonic clock value after which the cached token must be re-exchanged
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
# Cache for the OIDC-exchanged token: re-exchanging on every `get_token()` call would be wasteful,
|
| 164 |
+
# and re-exchanging shortly before expiry transparently keeps long-running jobs authenticated.
|
| 165 |
+
_OIDC_TOKEN_LOCK = Lock()
|
| 166 |
+
_OIDC_TOKEN_CACHE: _OidcTokenCache | None = None
|
| 167 |
+
_OIDC_REFRESH_MARGIN = 300 # re-exchange this many seconds before the token actually expires
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def _get_token_from_oidc() -> str | None:
|
| 171 |
+
"""Get a short-lived OIDC token in CI (Trusted Publishers).
|
| 172 |
+
|
| 173 |
+
Enabled by setting `HF_OIDC_RESOURCE`, which scopes the token to a repo or user.
|
| 174 |
+
The ID token is read from `HF_OIDC_ID_TOKEN` if available, or minted from a supported CI provider (e.g. GitHub Actions).
|
| 175 |
+
|
| 176 |
+
Returns `None` when OIDC is not enabled.
|
| 177 |
+
If enabled, any failure is raised explicitly rather than falling back silently.
|
| 178 |
+
|
| 179 |
+
See `huggingface_hub._oidc` and https://huggingface.co/docs/hub/trusted-publishers.
|
| 180 |
+
"""
|
| 181 |
+
resource = os.environ.get("HF_OIDC_RESOURCE")
|
| 182 |
+
if not resource:
|
| 183 |
+
return None
|
| 184 |
+
|
| 185 |
+
from .._oidc import detect_provider, oidc_login
|
| 186 |
+
|
| 187 |
+
global _OIDC_TOKEN_CACHE
|
| 188 |
+
with _OIDC_TOKEN_LOCK:
|
| 189 |
+
now = time.monotonic()
|
| 190 |
+
if (
|
| 191 |
+
_OIDC_TOKEN_CACHE is not None
|
| 192 |
+
and _OIDC_TOKEN_CACHE["resource"] == resource
|
| 193 |
+
and now < _OIDC_TOKEN_CACHE["expires_at"]
|
| 194 |
+
):
|
| 195 |
+
return _OIDC_TOKEN_CACHE["token"]
|
| 196 |
+
|
| 197 |
+
# An explicit id token (any provider) takes precedence; otherwise mint from a detected one.
|
| 198 |
+
subject_token = os.environ.get("HF_OIDC_ID_TOKEN") or None
|
| 199 |
+
if subject_token is None and detect_provider() is None:
|
| 200 |
+
raise OIDCError(
|
| 201 |
+
"HF_OIDC_RESOURCE is set but no OIDC id token is available: not running in a supported "
|
| 202 |
+
"CI provider (github) and HF_OIDC_ID_TOKEN is not set. Set HF_OIDC_ID_TOKEN to the id "
|
| 203 |
+
"token minted by your CI provider, or unset HF_OIDC_RESOURCE."
|
| 204 |
+
)
|
| 205 |
+
|
| 206 |
+
result = oidc_login(resource=resource, subject_token=subject_token)
|
| 207 |
+
token = result["access_token"]
|
| 208 |
+
expires_in = int(result.get("expires_in", 3600))
|
| 209 |
+
# A pre-supplied HF_OIDC_ID_TOKEN can't be re-minted, so refreshing early is pointless (the id
|
| 210 |
+
# token is likely already expired by then): cache for the full lifetime. Only the auto-minted
|
| 211 |
+
# path can refresh, so only it gets the safety margin.
|
| 212 |
+
margin = 0 if subject_token is not None else _OIDC_REFRESH_MARGIN
|
| 213 |
+
_OIDC_TOKEN_CACHE = {
|
| 214 |
+
"resource": resource,
|
| 215 |
+
"token": token,
|
| 216 |
+
"expires_at": now + max(expires_in - margin, 0),
|
| 217 |
+
}
|
| 218 |
+
return token
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
class _OAuthRefreshCache(TypedDict):
|
| 222 |
+
file_token: str # token as read from HF_TOKEN_PATH (cache key)
|
| 223 |
+
resolved_token: str # token to return (refreshed, or identical if no refresh was needed)
|
| 224 |
+
recheck_at: float # wall-clock timestamp after which the expiry must be re-evaluated
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
# Cache the refresh decision in-process: `get_token()` is called on every HTTP request and must not
|
| 228 |
+
# re-read the stored tokens file (let alone hit the network) each time.
|
| 229 |
+
_OAUTH_REFRESH_LOCK = Lock()
|
| 230 |
+
_OAUTH_REFRESH_CACHE: _OAuthRefreshCache | None = None
|
| 231 |
+
_OAUTH_REFRESH_MARGIN = 24 * 3600 # refresh when less than 1 day of validity remains
|
| 232 |
+
_OAUTH_RECHECK_INTERVAL = 300 # re-check interval when there is no metadata or the refresh failed
|
| 233 |
+
_OAUTH_REFRESH_WARNED = False # warn at most once per process on refresh failure
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
def _get_token_from_file_refreshed() -> str | None:
|
| 237 |
+
"""Get the token from `HF_TOKEN_PATH`, transparently refreshing it if close to expiry."""
|
| 238 |
+
token = _get_token_from_file()
|
| 239 |
+
if token is None:
|
| 240 |
+
return None
|
| 241 |
+
return _refresh_oauth_token_if_needed(token)
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
def _refresh_oauth_token_if_needed(token: str) -> str:
|
| 245 |
+
"""Refresh an OAuth access token if it is close to expiry. Best-effort: never raises.
|
| 246 |
+
|
| 247 |
+
OAuth tokens obtained with the browser-based login are stored with a `refresh_token` and an
|
| 248 |
+
`expires_at` timestamp (see `_save_token`). When the active token is one of them and about to
|
| 249 |
+
expire, exchange the refresh token for a new access token and persist it. Any other token is
|
| 250 |
+
returned unchanged.
|
| 251 |
+
"""
|
| 252 |
+
global _OAUTH_REFRESH_CACHE
|
| 253 |
+
with _OAUTH_REFRESH_LOCK:
|
| 254 |
+
now = time.time()
|
| 255 |
+
cache = _OAUTH_REFRESH_CACHE
|
| 256 |
+
if cache is not None and cache["file_token"] == token and now < cache["recheck_at"]:
|
| 257 |
+
return cache["resolved_token"]
|
| 258 |
+
|
| 259 |
+
token_name, fields = next(
|
| 260 |
+
((name, fields) for name, fields in _read_stored_tokens_full().items() if fields.get("hf_token") == token),
|
| 261 |
+
(None, {}),
|
| 262 |
+
)
|
| 263 |
+
refresh_token = fields.get("refresh_token")
|
| 264 |
+
expires_at = _parse_expires_at(fields)
|
| 265 |
+
if token_name is None or refresh_token is None or expires_at is None:
|
| 266 |
+
# `token` may have just been replaced by a concurrent refresh (in which case it no
|
| 267 |
+
# longer appears in the stored tokens): serve the fresh file token without caching.
|
| 268 |
+
current_file_token = _get_token_from_file()
|
| 269 |
+
if current_file_token is not None and current_file_token != token:
|
| 270 |
+
return current_file_token
|
| 271 |
+
# Not a refreshable OAuth token (or its metadata was lost): nothing to do.
|
| 272 |
+
_OAUTH_REFRESH_CACHE = {
|
| 273 |
+
"file_token": token,
|
| 274 |
+
"resolved_token": token,
|
| 275 |
+
"recheck_at": now + _OAUTH_RECHECK_INTERVAL,
|
| 276 |
+
}
|
| 277 |
+
return token
|
| 278 |
+
|
| 279 |
+
if expires_at - _OAUTH_REFRESH_MARGIN > now:
|
| 280 |
+
_OAUTH_REFRESH_CACHE = {
|
| 281 |
+
"file_token": token,
|
| 282 |
+
"resolved_token": token,
|
| 283 |
+
"recheck_at": expires_at - _OAUTH_REFRESH_MARGIN,
|
| 284 |
+
}
|
| 285 |
+
return token
|
| 286 |
+
|
| 287 |
+
try:
|
| 288 |
+
# Cross-process file lock: if the server rotates refresh tokens, two processes
|
| 289 |
+
# refreshing concurrently would invalidate each other's refresh token.
|
| 290 |
+
with WeakFileLock(constants.HF_STORED_TOKENS_PATH + ".lock", timeout=30):
|
| 291 |
+
# Re-read under the lock: another process may have refreshed in the meantime.
|
| 292 |
+
fields = _read_stored_tokens_full().get(token_name, {})
|
| 293 |
+
if fields.get("hf_token") != token:
|
| 294 |
+
# Another process already refreshed this token: adopt its result.
|
| 295 |
+
new_token = fields.get("hf_token") or token
|
| 296 |
+
new_expires_at = _parse_expires_at(fields)
|
| 297 |
+
else:
|
| 298 |
+
response = refresh_access_token(refresh_token)
|
| 299 |
+
new_token = response["access_token"]
|
| 300 |
+
new_expires_at = int(now) + int(response["expires_in"]) if "expires_in" in response else None
|
| 301 |
+
_save_token(
|
| 302 |
+
token=new_token,
|
| 303 |
+
token_name=token_name,
|
| 304 |
+
# The server may rotate the refresh token; keep the old one if it doesn't.
|
| 305 |
+
refresh_token=response.get("refresh_token") or refresh_token,
|
| 306 |
+
expires_at=new_expires_at,
|
| 307 |
+
)
|
| 308 |
+
# Update the active token file, unless another process switched to a different token meanwhile.
|
| 309 |
+
if _get_token_from_file() == token:
|
| 310 |
+
_write_secret(Path(constants.HF_TOKEN_PATH), new_token)
|
| 311 |
+
logger.info(f"Access token `{token_name}` has been refreshed.")
|
| 312 |
+
except Exception as e:
|
| 313 |
+
if isinstance(e, DeviceCodeError) and e.error_code == OAuthErrorCode.INVALID_GRANT:
|
| 314 |
+
# Refresh token expired or revoked: retrying is pointless, a re-login is required.
|
| 315 |
+
# Warned unconditionally (the inf recheck guarantees it fires at most once): an
|
| 316 |
+
# earlier transient warning must not suppress this actionable message.
|
| 317 |
+
logger.warning(
|
| 318 |
+
"Your Hugging Face access token has expired and could not be refreshed "
|
| 319 |
+
f"(session expired or revoked). Run `hf auth login` to re-authenticate. ({e})"
|
| 320 |
+
)
|
| 321 |
+
recheck_at = float("inf")
|
| 322 |
+
else:
|
| 323 |
+
# Transient failure (offline, server error, ...): retry later.
|
| 324 |
+
_warn_refresh_failure_once(f"Could not refresh your Hugging Face access token: {e}. Will retry later.")
|
| 325 |
+
recheck_at = now + _OAUTH_RECHECK_INTERVAL
|
| 326 |
+
# Return the existing token: if it's truly expired, the API will reject it with a clear error.
|
| 327 |
+
_OAUTH_REFRESH_CACHE = {"file_token": token, "resolved_token": token, "recheck_at": recheck_at}
|
| 328 |
+
return token
|
| 329 |
+
|
| 330 |
+
_OAUTH_REFRESH_CACHE = {
|
| 331 |
+
"file_token": new_token,
|
| 332 |
+
"resolved_token": new_token,
|
| 333 |
+
# The floor guards against a token lifetime shorter than the refresh margin, which
|
| 334 |
+
# would otherwise put `recheck_at` in the past and trigger a refresh on every call.
|
| 335 |
+
"recheck_at": max(
|
| 336 |
+
now + _OAUTH_RECHECK_INTERVAL,
|
| 337 |
+
new_expires_at - _OAUTH_REFRESH_MARGIN if new_expires_at else 0,
|
| 338 |
+
),
|
| 339 |
+
}
|
| 340 |
+
return new_token
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
def _warn_refresh_failure_once(message: str) -> None:
|
| 344 |
+
global _OAUTH_REFRESH_WARNED
|
| 345 |
+
if not _OAUTH_REFRESH_WARNED:
|
| 346 |
+
logger.warning(message)
|
| 347 |
+
_OAUTH_REFRESH_WARNED = True
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
def _parse_expires_at(fields: dict[str, str]) -> int | None:
|
| 351 |
+
"""Parse the `expires_at` field of a stored-tokens section, `None` if missing or corrupt."""
|
| 352 |
+
try:
|
| 353 |
+
return int(fields["expires_at"])
|
| 354 |
+
except (KeyError, ValueError):
|
| 355 |
+
return None
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
def get_stored_tokens() -> dict[str, str]:
|
| 359 |
+
"""
|
| 360 |
+
Returns the parsed INI file containing the access tokens.
|
| 361 |
+
The file is located at `HF_STORED_TOKENS_PATH`, defaulting to `~/.cache/huggingface/stored_tokens`.
|
| 362 |
+
If the file does not exist, an empty dictionary is returned.
|
| 363 |
+
|
| 364 |
+
Returns: `dict[str, str]`
|
| 365 |
+
Key is the token name and value is the token.
|
| 366 |
+
"""
|
| 367 |
+
return {token_name: fields.get("hf_token", "") for token_name, fields in _read_stored_tokens_full().items()}
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
def _read_stored_tokens_full() -> dict[str, dict[str, str]]:
|
| 371 |
+
"""Read all sections of the stored tokens INI file, with all their fields.
|
| 372 |
+
|
| 373 |
+
Beside `hf_token`, sections for OAuth tokens also carry `refresh_token` and `expires_at`
|
| 374 |
+
(unix timestamp), used by [`get_token`] to transparently refresh them.
|
| 375 |
+
"""
|
| 376 |
+
tokens_path = Path(constants.HF_STORED_TOKENS_PATH)
|
| 377 |
+
if not tokens_path.exists():
|
| 378 |
+
return {}
|
| 379 |
+
# interpolation=None: token values are opaque strings, a `%` must not be interpreted.
|
| 380 |
+
config = configparser.ConfigParser(interpolation=None)
|
| 381 |
+
try:
|
| 382 |
+
config.read(tokens_path)
|
| 383 |
+
return {token_name: dict(config.items(token_name)) for token_name in config.sections()}
|
| 384 |
+
except configparser.Error as e:
|
| 385 |
+
logger.error(f"Error parsing stored tokens file: {e}")
|
| 386 |
+
return {}
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
def _save_stored_tokens_full(stored_tokens: dict[str, dict[str, str]]) -> None:
|
| 390 |
+
"""Write all sections and their fields to the stored tokens INI file."""
|
| 391 |
+
config = configparser.ConfigParser(interpolation=None)
|
| 392 |
+
for token_name in sorted(stored_tokens.keys()):
|
| 393 |
+
config.add_section(token_name)
|
| 394 |
+
for key, value in stored_tokens[token_name].items():
|
| 395 |
+
config.set(token_name, key, value)
|
| 396 |
+
|
| 397 |
+
buf = io.StringIO()
|
| 398 |
+
config.write(buf)
|
| 399 |
+
_write_secret(Path(constants.HF_STORED_TOKENS_PATH), buf.getvalue())
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
def _get_token_by_name(token_name: str) -> str | None:
|
| 403 |
+
"""
|
| 404 |
+
Get the token by name.
|
| 405 |
+
|
| 406 |
+
Args:
|
| 407 |
+
token_name (`str`):
|
| 408 |
+
The name of the token to get.
|
| 409 |
+
|
| 410 |
+
Returns:
|
| 411 |
+
`str` or `None`: The token, `None` if it doesn't exist.
|
| 412 |
+
|
| 413 |
+
"""
|
| 414 |
+
stored_tokens = get_stored_tokens()
|
| 415 |
+
if token_name not in stored_tokens:
|
| 416 |
+
return None
|
| 417 |
+
return _clean_token(stored_tokens[token_name])
|
| 418 |
+
|
| 419 |
+
|
| 420 |
+
def _save_token(
|
| 421 |
+
token: str, token_name: str, *, refresh_token: str | None = None, expires_at: int | None = None
|
| 422 |
+
) -> None:
|
| 423 |
+
"""
|
| 424 |
+
Save the given token.
|
| 425 |
+
|
| 426 |
+
If the stored tokens file does not exist, it will be created.
|
| 427 |
+
Args:
|
| 428 |
+
token (`str`):
|
| 429 |
+
The token to save.
|
| 430 |
+
token_name (`str`):
|
| 431 |
+
The name of the token.
|
| 432 |
+
refresh_token (`str`, *optional*):
|
| 433 |
+
OAuth refresh token used to renew the access token when it expires.
|
| 434 |
+
expires_at (`int`, *optional*):
|
| 435 |
+
Unix timestamp at which the access token expires.
|
| 436 |
+
"""
|
| 437 |
+
stored_tokens = _read_stored_tokens_full()
|
| 438 |
+
fields = {"hf_token": token}
|
| 439 |
+
if refresh_token is not None:
|
| 440 |
+
fields["refresh_token"] = refresh_token
|
| 441 |
+
if expires_at is not None:
|
| 442 |
+
fields["expires_at"] = str(expires_at)
|
| 443 |
+
# Replace the whole section: re-logging in under the same name must drop stale metadata.
|
| 444 |
+
stored_tokens[token_name] = fields
|
| 445 |
+
_save_stored_tokens_full(stored_tokens)
|
| 446 |
+
logger.info(f"The token `{token_name}` has been saved to {constants.HF_STORED_TOKENS_PATH}")
|
| 447 |
+
|
| 448 |
+
|
| 449 |
+
def _clean_token(token: str | None) -> str | None:
|
| 450 |
+
"""Clean token by removing trailing and leading spaces and newlines.
|
| 451 |
+
|
| 452 |
+
If token is an empty string, return None.
|
| 453 |
+
"""
|
| 454 |
+
if token is None:
|
| 455 |
+
return None
|
| 456 |
+
return token.replace("\r", "").replace("\n", "").strip() or None
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/_cache_assets.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2019-present, the HuggingFace Inc. team.
|
| 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 |
+
from pathlib import Path
|
| 15 |
+
|
| 16 |
+
from ..constants import HF_ASSETS_CACHE
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def cached_assets_path(
|
| 20 |
+
library_name: str,
|
| 21 |
+
namespace: str = "default",
|
| 22 |
+
subfolder: str = "default",
|
| 23 |
+
*,
|
| 24 |
+
assets_dir: str | Path | None = None,
|
| 25 |
+
) -> Path:
|
| 26 |
+
"""Return a folder path to cache arbitrary files.
|
| 27 |
+
|
| 28 |
+
`huggingface_hub` provides a canonical folder path to store assets. This is the
|
| 29 |
+
recommended way to integrate cache in a downstream library as it will benefit from
|
| 30 |
+
the builtins tools to scan and delete the cache properly.
|
| 31 |
+
|
| 32 |
+
The distinction is made between files cached from the Hub and assets. Files from the
|
| 33 |
+
Hub are cached in a git-aware manner and entirely managed by `huggingface_hub`. See
|
| 34 |
+
[related documentation](https://huggingface.co/docs/huggingface_hub/how-to-cache).
|
| 35 |
+
All other files that a downstream library caches are considered to be "assets"
|
| 36 |
+
(files downloaded from external sources, extracted from a .tar archive, preprocessed
|
| 37 |
+
for training,...).
|
| 38 |
+
|
| 39 |
+
Once the folder path is generated, it is guaranteed to exist and to be a directory.
|
| 40 |
+
The path is based on 3 levels of depth: the library name, a namespace and a
|
| 41 |
+
subfolder. Those 3 levels grants flexibility while allowing `huggingface_hub` to
|
| 42 |
+
expect folders when scanning/deleting parts of the assets cache. Within a library,
|
| 43 |
+
it is expected that all namespaces share the same subset of subfolder names but this
|
| 44 |
+
is not a mandatory rule. The downstream library has then full control on which file
|
| 45 |
+
structure to adopt within its cache. Namespace and subfolder are optional (would
|
| 46 |
+
default to a `"default/"` subfolder) but library name is mandatory as we want every
|
| 47 |
+
downstream library to manage its own cache.
|
| 48 |
+
|
| 49 |
+
Expected tree:
|
| 50 |
+
```text
|
| 51 |
+
assets/
|
| 52 |
+
└── datasets/
|
| 53 |
+
│ ├── SQuAD/
|
| 54 |
+
│ │ ├── downloaded/
|
| 55 |
+
│ │ ├── extracted/
|
| 56 |
+
│ │ └── processed/
|
| 57 |
+
│ ├── Helsinki-NLP--tatoeba_mt/
|
| 58 |
+
│ ├── downloaded/
|
| 59 |
+
│ ├── extracted/
|
| 60 |
+
│ └── processed/
|
| 61 |
+
└── transformers/
|
| 62 |
+
├── default/
|
| 63 |
+
│ ├── something/
|
| 64 |
+
├── bert-base-cased/
|
| 65 |
+
│ ├── default/
|
| 66 |
+
│ └── training/
|
| 67 |
+
hub/
|
| 68 |
+
└── models--julien-c--EsperBERTo-small/
|
| 69 |
+
├── blobs/
|
| 70 |
+
│ ├── (...)
|
| 71 |
+
│ ├── (...)
|
| 72 |
+
├── refs/
|
| 73 |
+
│ └── (...)
|
| 74 |
+
└── [ 128] snapshots/
|
| 75 |
+
├── 2439f60ef33a0d46d85da5001d52aeda5b00ce9f/
|
| 76 |
+
│ ├── (...)
|
| 77 |
+
└── bbc77c8132af1cc5cf678da3f1ddf2de43606d48/
|
| 78 |
+
└── (...)
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
Args:
|
| 83 |
+
library_name (`str`):
|
| 84 |
+
Name of the library that will manage the cache folder. Example: `"dataset"`.
|
| 85 |
+
namespace (`str`, *optional*, defaults to "default"):
|
| 86 |
+
Namespace to which the data belongs. Example: `"SQuAD"`.
|
| 87 |
+
subfolder (`str`, *optional*, defaults to "default"):
|
| 88 |
+
Subfolder in which the data will be stored. Example: `extracted`.
|
| 89 |
+
assets_dir (`str`, `Path`, *optional*):
|
| 90 |
+
Path to the folder where assets are cached. This must not be the same folder
|
| 91 |
+
where Hub files are cached. Defaults to `HF_HOME / "assets"` if not provided.
|
| 92 |
+
Can also be set with `HF_ASSETS_CACHE` environment variable.
|
| 93 |
+
|
| 94 |
+
Returns:
|
| 95 |
+
Path to the cache folder (`Path`).
|
| 96 |
+
|
| 97 |
+
Example:
|
| 98 |
+
```py
|
| 99 |
+
>>> from huggingface_hub import cached_assets_path
|
| 100 |
+
|
| 101 |
+
>>> cached_assets_path(library_name="datasets", namespace="SQuAD", subfolder="download")
|
| 102 |
+
PosixPath('/home/wauplin/.cache/huggingface/extra/datasets/SQuAD/download')
|
| 103 |
+
|
| 104 |
+
>>> cached_assets_path(library_name="datasets", namespace="SQuAD", subfolder="extracted")
|
| 105 |
+
PosixPath('/home/wauplin/.cache/huggingface/extra/datasets/SQuAD/extracted')
|
| 106 |
+
|
| 107 |
+
>>> cached_assets_path(library_name="datasets", namespace="Helsinki-NLP/tatoeba_mt")
|
| 108 |
+
PosixPath('/home/wauplin/.cache/huggingface/extra/datasets/Helsinki-NLP--tatoeba_mt/default')
|
| 109 |
+
|
| 110 |
+
>>> cached_assets_path(library_name="datasets", assets_dir="/tmp/tmp123456")
|
| 111 |
+
PosixPath('/tmp/tmp123456/datasets/default/default')
|
| 112 |
+
```
|
| 113 |
+
"""
|
| 114 |
+
# Resolve assets_dir
|
| 115 |
+
if assets_dir is None:
|
| 116 |
+
assets_dir = HF_ASSETS_CACHE
|
| 117 |
+
assets_dir = Path(assets_dir).expanduser().resolve()
|
| 118 |
+
|
| 119 |
+
# Avoid names that could create path issues
|
| 120 |
+
for part in (" ", "/", "\\"):
|
| 121 |
+
library_name = library_name.replace(part, "--")
|
| 122 |
+
namespace = namespace.replace(part, "--")
|
| 123 |
+
subfolder = subfolder.replace(part, "--")
|
| 124 |
+
|
| 125 |
+
# Path to subfolder is created
|
| 126 |
+
path = assets_dir / library_name / namespace / subfolder
|
| 127 |
+
try:
|
| 128 |
+
path.mkdir(exist_ok=True, parents=True)
|
| 129 |
+
except (FileExistsError, NotADirectoryError):
|
| 130 |
+
raise ValueError(f"Corrupted assets folder: cannot create directory because of an existing file ({path}).")
|
| 131 |
+
|
| 132 |
+
# Return
|
| 133 |
+
return path
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/_cache_manager.py
ADDED
|
@@ -0,0 +1,890 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022-present, the HuggingFace Inc. team.
|
| 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 utilities to manage the HF cache directory."""
|
| 15 |
+
|
| 16 |
+
import os
|
| 17 |
+
import shutil
|
| 18 |
+
from collections import defaultdict
|
| 19 |
+
from dataclasses import dataclass
|
| 20 |
+
from pathlib import Path
|
| 21 |
+
from typing import Literal
|
| 22 |
+
|
| 23 |
+
from huggingface_hub.errors import CacheNotFound, CorruptedCacheException
|
| 24 |
+
|
| 25 |
+
from ..constants import HF_HUB_CACHE
|
| 26 |
+
from . import logging
|
| 27 |
+
from ._parsing import format_timesince
|
| 28 |
+
from ._terminal import tabulate
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
logger = logging.get_logger(__name__)
|
| 32 |
+
|
| 33 |
+
REPO_TYPE_T = Literal["model", "dataset", "space"]
|
| 34 |
+
|
| 35 |
+
# List of OS-created helper files that need to be ignored
|
| 36 |
+
FILES_TO_IGNORE = [".DS_Store", "Thumbs.db", "desktop.ini"]
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
@dataclass(frozen=True)
|
| 40 |
+
class CachedFileInfo:
|
| 41 |
+
"""Frozen data structure holding information about a single cached file.
|
| 42 |
+
|
| 43 |
+
Args:
|
| 44 |
+
file_name (`str`):
|
| 45 |
+
Name of the file. Example: `config.json`.
|
| 46 |
+
file_path (`Path`):
|
| 47 |
+
Path of the file in the `snapshots` directory. The file path is a symlink
|
| 48 |
+
referring to a blob in the `blobs` folder.
|
| 49 |
+
blob_path (`Path`):
|
| 50 |
+
Path of the blob file. This is equivalent to `file_path.resolve()`.
|
| 51 |
+
size_on_disk (`int`):
|
| 52 |
+
Size of the blob file in bytes.
|
| 53 |
+
blob_last_accessed (`float`):
|
| 54 |
+
Timestamp of the last time the blob file has been accessed (from any
|
| 55 |
+
revision).
|
| 56 |
+
blob_last_modified (`float`):
|
| 57 |
+
Timestamp of the last time the blob file has been modified/created.
|
| 58 |
+
|
| 59 |
+
> [!WARNING]
|
| 60 |
+
> `blob_last_accessed` and `blob_last_modified` reliability can depend on the OS you
|
| 61 |
+
> are using. See [python documentation](https://docs.python.org/3/library/os.html#os.stat_result)
|
| 62 |
+
> for more details.
|
| 63 |
+
"""
|
| 64 |
+
|
| 65 |
+
file_name: str
|
| 66 |
+
file_path: Path
|
| 67 |
+
blob_path: Path
|
| 68 |
+
size_on_disk: int
|
| 69 |
+
|
| 70 |
+
blob_last_accessed: float
|
| 71 |
+
blob_last_modified: float
|
| 72 |
+
|
| 73 |
+
@property
|
| 74 |
+
def blob_last_accessed_str(self) -> str:
|
| 75 |
+
"""
|
| 76 |
+
(property) Timestamp of the last time the blob file has been accessed (from any
|
| 77 |
+
revision), returned as a human-readable string.
|
| 78 |
+
|
| 79 |
+
Example: "2 weeks ago".
|
| 80 |
+
"""
|
| 81 |
+
return format_timesince(self.blob_last_accessed)
|
| 82 |
+
|
| 83 |
+
@property
|
| 84 |
+
def blob_last_modified_str(self) -> str:
|
| 85 |
+
"""
|
| 86 |
+
(property) Timestamp of the last time the blob file has been modified, returned
|
| 87 |
+
as a human-readable string.
|
| 88 |
+
|
| 89 |
+
Example: "2 weeks ago".
|
| 90 |
+
"""
|
| 91 |
+
return format_timesince(self.blob_last_modified)
|
| 92 |
+
|
| 93 |
+
@property
|
| 94 |
+
def size_on_disk_str(self) -> str:
|
| 95 |
+
"""
|
| 96 |
+
(property) Size of the blob file as a human-readable string.
|
| 97 |
+
|
| 98 |
+
Example: "42.2K".
|
| 99 |
+
"""
|
| 100 |
+
return _format_size(self.size_on_disk)
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
@dataclass(frozen=True)
|
| 104 |
+
class CachedRevisionInfo:
|
| 105 |
+
"""Frozen data structure holding information about a revision.
|
| 106 |
+
|
| 107 |
+
A revision correspond to a folder in the `snapshots` folder and is populated with
|
| 108 |
+
the exact tree structure as the repo on the Hub but contains only symlinks. A
|
| 109 |
+
revision can be either referenced by 1 or more `refs` or be "detached" (no refs).
|
| 110 |
+
|
| 111 |
+
Args:
|
| 112 |
+
commit_hash (`str`):
|
| 113 |
+
Hash of the revision (unique).
|
| 114 |
+
Example: `"9338f7b671827df886678df2bdd7cc7b4f36dffd"`.
|
| 115 |
+
snapshot_path (`Path`):
|
| 116 |
+
Path to the revision directory in the `snapshots` folder. It contains the
|
| 117 |
+
exact tree structure as the repo on the Hub.
|
| 118 |
+
files: (`frozenset[CachedFileInfo]`):
|
| 119 |
+
Set of [`~CachedFileInfo`] describing all files contained in the snapshot.
|
| 120 |
+
refs (`frozenset[str]`):
|
| 121 |
+
Set of `refs` pointing to this revision. If the revision has no `refs`, it
|
| 122 |
+
is considered detached.
|
| 123 |
+
Example: `{"main", "2.4.0"}` or `{"refs/pr/1"}`.
|
| 124 |
+
size_on_disk (`int`):
|
| 125 |
+
Sum of the blob file sizes that are symlink-ed by the revision.
|
| 126 |
+
last_modified (`float`):
|
| 127 |
+
Timestamp of the last time the revision has been created/modified.
|
| 128 |
+
|
| 129 |
+
> [!WARNING]
|
| 130 |
+
> `last_accessed` cannot be determined correctly on a single revision as blob files
|
| 131 |
+
> are shared across revisions.
|
| 132 |
+
|
| 133 |
+
> [!WARNING]
|
| 134 |
+
> `size_on_disk` is not necessarily the sum of all file sizes because of possible
|
| 135 |
+
> duplicated files. Besides, only blobs are taken into account, not the (negligible)
|
| 136 |
+
> size of folders and symlinks.
|
| 137 |
+
"""
|
| 138 |
+
|
| 139 |
+
commit_hash: str
|
| 140 |
+
snapshot_path: Path
|
| 141 |
+
size_on_disk: int
|
| 142 |
+
files: frozenset[CachedFileInfo]
|
| 143 |
+
refs: frozenset[str]
|
| 144 |
+
|
| 145 |
+
last_modified: float
|
| 146 |
+
|
| 147 |
+
@property
|
| 148 |
+
def last_modified_str(self) -> str:
|
| 149 |
+
"""
|
| 150 |
+
(property) Timestamp of the last time the revision has been modified, returned
|
| 151 |
+
as a human-readable string.
|
| 152 |
+
|
| 153 |
+
Example: "2 weeks ago".
|
| 154 |
+
"""
|
| 155 |
+
return format_timesince(self.last_modified)
|
| 156 |
+
|
| 157 |
+
@property
|
| 158 |
+
def size_on_disk_str(self) -> str:
|
| 159 |
+
"""
|
| 160 |
+
(property) Sum of the blob file sizes as a human-readable string.
|
| 161 |
+
|
| 162 |
+
Example: "42.2K".
|
| 163 |
+
"""
|
| 164 |
+
return _format_size(self.size_on_disk)
|
| 165 |
+
|
| 166 |
+
@property
|
| 167 |
+
def nb_files(self) -> int:
|
| 168 |
+
"""
|
| 169 |
+
(property) Total number of files in the revision.
|
| 170 |
+
"""
|
| 171 |
+
return len(self.files)
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
@dataclass(frozen=True)
|
| 175 |
+
class CachedRepoInfo:
|
| 176 |
+
"""Frozen data structure holding information about a cached repository.
|
| 177 |
+
|
| 178 |
+
Args:
|
| 179 |
+
repo_id (`str`):
|
| 180 |
+
Repo id of the repo on the Hub. Example: `"google/fleurs"`.
|
| 181 |
+
repo_type (`Literal["dataset", "model", "space"]`):
|
| 182 |
+
Type of the cached repo.
|
| 183 |
+
repo_path (`Path`):
|
| 184 |
+
Local path to the cached repo.
|
| 185 |
+
size_on_disk (`int`):
|
| 186 |
+
Sum of the blob file sizes in the cached repo.
|
| 187 |
+
nb_files (`int`):
|
| 188 |
+
Total number of blob files in the cached repo.
|
| 189 |
+
revisions (`frozenset[CachedRevisionInfo]`):
|
| 190 |
+
Set of [`~CachedRevisionInfo`] describing all revisions cached in the repo.
|
| 191 |
+
last_accessed (`float`):
|
| 192 |
+
Timestamp of the last time a blob file of the repo has been accessed.
|
| 193 |
+
last_modified (`float`):
|
| 194 |
+
Timestamp of the last time a blob file of the repo has been modified/created.
|
| 195 |
+
|
| 196 |
+
> [!WARNING]
|
| 197 |
+
> `size_on_disk` is not necessarily the sum of all revisions sizes because of
|
| 198 |
+
> duplicated files. Besides, only blobs are taken into account, not the (negligible)
|
| 199 |
+
> size of folders and symlinks.
|
| 200 |
+
|
| 201 |
+
> [!WARNING]
|
| 202 |
+
> `last_accessed` and `last_modified` reliability can depend on the OS you are using.
|
| 203 |
+
> See [python documentation](https://docs.python.org/3/library/os.html#os.stat_result)
|
| 204 |
+
> for more details.
|
| 205 |
+
"""
|
| 206 |
+
|
| 207 |
+
repo_id: str
|
| 208 |
+
repo_type: REPO_TYPE_T
|
| 209 |
+
repo_path: Path
|
| 210 |
+
size_on_disk: int
|
| 211 |
+
nb_files: int
|
| 212 |
+
revisions: frozenset[CachedRevisionInfo]
|
| 213 |
+
|
| 214 |
+
last_accessed: float
|
| 215 |
+
last_modified: float
|
| 216 |
+
|
| 217 |
+
@property
|
| 218 |
+
def last_accessed_str(self) -> str:
|
| 219 |
+
"""
|
| 220 |
+
(property) Last time a blob file of the repo has been accessed, returned as a
|
| 221 |
+
human-readable string.
|
| 222 |
+
|
| 223 |
+
Example: "2 weeks ago".
|
| 224 |
+
"""
|
| 225 |
+
return format_timesince(self.last_accessed)
|
| 226 |
+
|
| 227 |
+
@property
|
| 228 |
+
def last_modified_str(self) -> str:
|
| 229 |
+
"""
|
| 230 |
+
(property) Last time a blob file of the repo has been modified, returned as a
|
| 231 |
+
human-readable string.
|
| 232 |
+
|
| 233 |
+
Example: "2 weeks ago".
|
| 234 |
+
"""
|
| 235 |
+
return format_timesince(self.last_modified)
|
| 236 |
+
|
| 237 |
+
@property
|
| 238 |
+
def size_on_disk_str(self) -> str:
|
| 239 |
+
"""
|
| 240 |
+
(property) Sum of the blob file sizes as a human-readable string.
|
| 241 |
+
|
| 242 |
+
Example: "42.2K".
|
| 243 |
+
"""
|
| 244 |
+
return _format_size(self.size_on_disk)
|
| 245 |
+
|
| 246 |
+
@property
|
| 247 |
+
def cache_id(self) -> str:
|
| 248 |
+
"""Canonical `type/id` identifier used across cache tooling."""
|
| 249 |
+
return f"{self.repo_type}/{self.repo_id}"
|
| 250 |
+
|
| 251 |
+
@property
|
| 252 |
+
def refs(self) -> dict[str, CachedRevisionInfo]:
|
| 253 |
+
"""
|
| 254 |
+
(property) Mapping between `refs` and revision data structures.
|
| 255 |
+
"""
|
| 256 |
+
return {ref: revision for revision in self.revisions for ref in revision.refs}
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
@dataclass(frozen=True)
|
| 260 |
+
class DeleteCacheStrategy:
|
| 261 |
+
"""Frozen data structure holding the strategy to delete cached revisions.
|
| 262 |
+
|
| 263 |
+
This object is not meant to be instantiated programmatically but to be returned by
|
| 264 |
+
[`~utils.HFCacheInfo.delete_revisions`]. See documentation for usage example.
|
| 265 |
+
|
| 266 |
+
Args:
|
| 267 |
+
expected_freed_size (`float`):
|
| 268 |
+
Expected freed size once strategy is executed.
|
| 269 |
+
blobs (`frozenset[Path]`):
|
| 270 |
+
Set of blob file paths to be deleted.
|
| 271 |
+
refs (`frozenset[Path]`):
|
| 272 |
+
Set of reference file paths to be deleted.
|
| 273 |
+
repos (`frozenset[Path]`):
|
| 274 |
+
Set of entire repo paths to be deleted.
|
| 275 |
+
snapshots (`frozenset[Path]`):
|
| 276 |
+
Set of snapshots to be deleted (directory of symlinks).
|
| 277 |
+
"""
|
| 278 |
+
|
| 279 |
+
expected_freed_size: int
|
| 280 |
+
blobs: frozenset[Path]
|
| 281 |
+
refs: frozenset[Path]
|
| 282 |
+
repos: frozenset[Path]
|
| 283 |
+
snapshots: frozenset[Path]
|
| 284 |
+
|
| 285 |
+
@property
|
| 286 |
+
def expected_freed_size_str(self) -> str:
|
| 287 |
+
"""
|
| 288 |
+
(property) Expected size that will be freed as a human-readable string.
|
| 289 |
+
|
| 290 |
+
Example: "42.2K".
|
| 291 |
+
"""
|
| 292 |
+
return _format_size(self.expected_freed_size)
|
| 293 |
+
|
| 294 |
+
def execute(self) -> None:
|
| 295 |
+
"""Execute the defined strategy.
|
| 296 |
+
|
| 297 |
+
> [!WARNING]
|
| 298 |
+
> If this method is interrupted, the cache might get corrupted. Deletion order is
|
| 299 |
+
> implemented so that references and symlinks are deleted before the actual blob
|
| 300 |
+
> files.
|
| 301 |
+
|
| 302 |
+
> [!WARNING]
|
| 303 |
+
> This method is irreversible. If executed, cached files are erased and must be
|
| 304 |
+
> downloaded again.
|
| 305 |
+
"""
|
| 306 |
+
# Deletion order matters. Blobs are deleted in last so that the user can't end
|
| 307 |
+
# up in a state where a `ref`` refers to a missing snapshot or a snapshot
|
| 308 |
+
# symlink refers to a deleted blob.
|
| 309 |
+
|
| 310 |
+
# Delete entire repos
|
| 311 |
+
for path in self.repos:
|
| 312 |
+
_try_delete_path(path, path_type="repo")
|
| 313 |
+
|
| 314 |
+
# Delete snapshot directories
|
| 315 |
+
for path in self.snapshots:
|
| 316 |
+
_try_delete_path(path, path_type="snapshot")
|
| 317 |
+
|
| 318 |
+
# Delete refs files
|
| 319 |
+
for path in self.refs:
|
| 320 |
+
_try_delete_path(path, path_type="ref")
|
| 321 |
+
|
| 322 |
+
# Delete blob files
|
| 323 |
+
for path in self.blobs:
|
| 324 |
+
_try_delete_path(path, path_type="blob")
|
| 325 |
+
|
| 326 |
+
logger.info(f"Cache deletion done. Saved {self.expected_freed_size_str}.")
|
| 327 |
+
|
| 328 |
+
|
| 329 |
+
@dataclass(frozen=True)
|
| 330 |
+
class CachedIncompleteFileInfo:
|
| 331 |
+
"""Frozen data structure holding information about a single incomplete download.
|
| 332 |
+
|
| 333 |
+
Interrupted downloads leave `<cache>/<repo>/blobs/<etag>.incomplete` files behind.
|
| 334 |
+
These are not part of any committed revision, so they are surfaced separately by
|
| 335 |
+
[`scan_cache_dir`].
|
| 336 |
+
|
| 337 |
+
Args:
|
| 338 |
+
file_path (`Path`):
|
| 339 |
+
Path of the `.incomplete` file in the `blobs` folder.
|
| 340 |
+
size_on_disk (`int`):
|
| 341 |
+
Size of the partially-downloaded file in bytes.
|
| 342 |
+
"""
|
| 343 |
+
|
| 344 |
+
file_path: Path
|
| 345 |
+
size_on_disk: int
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
@dataclass(frozen=True)
|
| 349 |
+
class HFCacheInfo:
|
| 350 |
+
"""Frozen data structure holding information about the entire cache-system.
|
| 351 |
+
|
| 352 |
+
This data structure is returned by [`scan_cache_dir`] and is immutable.
|
| 353 |
+
|
| 354 |
+
Args:
|
| 355 |
+
size_on_disk (`int`):
|
| 356 |
+
Sum of all valid repo sizes in the cache-system.
|
| 357 |
+
repos (`frozenset[CachedRepoInfo]`):
|
| 358 |
+
Set of [`~CachedRepoInfo`] describing all valid cached repos found on the
|
| 359 |
+
cache-system while scanning.
|
| 360 |
+
incomplete_files (`frozenset[CachedIncompleteFileInfo]`):
|
| 361 |
+
Set of [`~CachedIncompleteFileInfo`] describing orphaned `*.incomplete`
|
| 362 |
+
files left behind by interrupted downloads.
|
| 363 |
+
warnings (`list[CorruptedCacheException]`):
|
| 364 |
+
List of [`~CorruptedCacheException`] that occurred while scanning the cache.
|
| 365 |
+
Those exceptions are captured so that the scan can continue. Corrupted repos
|
| 366 |
+
are skipped from the scan.
|
| 367 |
+
|
| 368 |
+
> [!WARNING]
|
| 369 |
+
> Here `size_on_disk` is equal to the sum of all repo sizes (only blobs). However if
|
| 370 |
+
> some cached repos are corrupted, their sizes are not taken into account.
|
| 371 |
+
"""
|
| 372 |
+
|
| 373 |
+
size_on_disk: int
|
| 374 |
+
repos: frozenset[CachedRepoInfo]
|
| 375 |
+
incomplete_files: frozenset[CachedIncompleteFileInfo]
|
| 376 |
+
warnings: list[CorruptedCacheException]
|
| 377 |
+
|
| 378 |
+
@property
|
| 379 |
+
def size_on_disk_str(self) -> str:
|
| 380 |
+
"""
|
| 381 |
+
(property) Sum of all valid repo sizes in the cache-system as a human-readable
|
| 382 |
+
string.
|
| 383 |
+
|
| 384 |
+
Example: "42.2K".
|
| 385 |
+
"""
|
| 386 |
+
return _format_size(self.size_on_disk)
|
| 387 |
+
|
| 388 |
+
@property
|
| 389 |
+
def incomplete_size_on_disk(self) -> int:
|
| 390 |
+
"""(property) Sum of all incomplete download sizes in bytes."""
|
| 391 |
+
return sum(file.size_on_disk for file in self.incomplete_files)
|
| 392 |
+
|
| 393 |
+
def delete_revisions(self, *revisions: str) -> DeleteCacheStrategy:
|
| 394 |
+
"""Prepare the strategy to delete one or more revisions cached locally.
|
| 395 |
+
|
| 396 |
+
Input revisions can be any revision hash. If a revision hash is not found in the
|
| 397 |
+
local cache, a warning is thrown but no error is raised. Revisions can be from
|
| 398 |
+
different cached repos since hashes are unique across repos,
|
| 399 |
+
|
| 400 |
+
Examples:
|
| 401 |
+
```py
|
| 402 |
+
>>> from huggingface_hub import scan_cache_dir
|
| 403 |
+
>>> cache_info = scan_cache_dir()
|
| 404 |
+
>>> delete_strategy = cache_info.delete_revisions(
|
| 405 |
+
... "81fd1d6e7847c99f5862c9fb81387956d99ec7aa"
|
| 406 |
+
... )
|
| 407 |
+
>>> print(f"Will free {delete_strategy.expected_freed_size_str}.")
|
| 408 |
+
Will free 7.9K.
|
| 409 |
+
>>> delete_strategy.execute()
|
| 410 |
+
Cache deletion done. Saved 7.9K.
|
| 411 |
+
```
|
| 412 |
+
|
| 413 |
+
```py
|
| 414 |
+
>>> from huggingface_hub import scan_cache_dir
|
| 415 |
+
>>> scan_cache_dir().delete_revisions(
|
| 416 |
+
... "81fd1d6e7847c99f5862c9fb81387956d99ec7aa",
|
| 417 |
+
... "e2983b237dccf3ab4937c97fa717319a9ca1a96d",
|
| 418 |
+
... "6c0e6080953db56375760c0471a8c5f2929baf11",
|
| 419 |
+
... ).execute()
|
| 420 |
+
Cache deletion done. Saved 8.6G.
|
| 421 |
+
```
|
| 422 |
+
|
| 423 |
+
> [!WARNING]
|
| 424 |
+
> `delete_revisions` returns a [`~utils.DeleteCacheStrategy`] object that needs to
|
| 425 |
+
> be executed. The [`~utils.DeleteCacheStrategy`] is not meant to be modified but
|
| 426 |
+
> allows having a dry run before actually executing the deletion.
|
| 427 |
+
"""
|
| 428 |
+
hashes_to_delete: set[str] = set(revisions)
|
| 429 |
+
|
| 430 |
+
repos_with_revisions: dict[CachedRepoInfo, set[CachedRevisionInfo]] = defaultdict(set)
|
| 431 |
+
|
| 432 |
+
for repo in self.repos:
|
| 433 |
+
for revision in repo.revisions:
|
| 434 |
+
if revision.commit_hash in hashes_to_delete:
|
| 435 |
+
repos_with_revisions[repo].add(revision)
|
| 436 |
+
hashes_to_delete.remove(revision.commit_hash)
|
| 437 |
+
|
| 438 |
+
if len(hashes_to_delete) > 0:
|
| 439 |
+
logger.warning(f"Revision(s) not found - cannot delete them: {', '.join(hashes_to_delete)}")
|
| 440 |
+
|
| 441 |
+
delete_strategy_blobs: set[Path] = set()
|
| 442 |
+
delete_strategy_refs: set[Path] = set()
|
| 443 |
+
delete_strategy_repos: set[Path] = set()
|
| 444 |
+
delete_strategy_snapshots: set[Path] = set()
|
| 445 |
+
delete_strategy_expected_freed_size = 0
|
| 446 |
+
|
| 447 |
+
for affected_repo, revisions_to_delete in repos_with_revisions.items():
|
| 448 |
+
other_revisions = affected_repo.revisions - revisions_to_delete
|
| 449 |
+
|
| 450 |
+
# If no other revisions, it means all revisions are deleted
|
| 451 |
+
# -> delete the entire cached repo
|
| 452 |
+
if len(other_revisions) == 0:
|
| 453 |
+
delete_strategy_repos.add(affected_repo.repo_path)
|
| 454 |
+
delete_strategy_expected_freed_size += affected_repo.size_on_disk
|
| 455 |
+
continue
|
| 456 |
+
|
| 457 |
+
# Some revisions of the repo will be deleted but not all. We need to filter
|
| 458 |
+
# which blob files will not be linked anymore.
|
| 459 |
+
for revision_to_delete in revisions_to_delete:
|
| 460 |
+
# Snapshot dir
|
| 461 |
+
delete_strategy_snapshots.add(revision_to_delete.snapshot_path)
|
| 462 |
+
|
| 463 |
+
# Refs dir
|
| 464 |
+
for ref in revision_to_delete.refs:
|
| 465 |
+
delete_strategy_refs.add(affected_repo.repo_path / "refs" / ref)
|
| 466 |
+
|
| 467 |
+
# Blobs dir
|
| 468 |
+
for file in revision_to_delete.files:
|
| 469 |
+
if file.blob_path not in delete_strategy_blobs:
|
| 470 |
+
is_file_alone = True
|
| 471 |
+
for revision in other_revisions:
|
| 472 |
+
for rev_file in revision.files:
|
| 473 |
+
if file.blob_path == rev_file.blob_path:
|
| 474 |
+
is_file_alone = False
|
| 475 |
+
break
|
| 476 |
+
if not is_file_alone:
|
| 477 |
+
break
|
| 478 |
+
|
| 479 |
+
# Blob file not referenced by remaining revisions -> delete
|
| 480 |
+
if is_file_alone:
|
| 481 |
+
delete_strategy_blobs.add(file.blob_path)
|
| 482 |
+
delete_strategy_expected_freed_size += file.size_on_disk
|
| 483 |
+
|
| 484 |
+
# Return the strategy instead of executing it.
|
| 485 |
+
return DeleteCacheStrategy(
|
| 486 |
+
blobs=frozenset(delete_strategy_blobs),
|
| 487 |
+
refs=frozenset(delete_strategy_refs),
|
| 488 |
+
repos=frozenset(delete_strategy_repos),
|
| 489 |
+
snapshots=frozenset(delete_strategy_snapshots),
|
| 490 |
+
expected_freed_size=delete_strategy_expected_freed_size,
|
| 491 |
+
)
|
| 492 |
+
|
| 493 |
+
def export_as_table(self, *, verbosity: int = 0) -> str:
|
| 494 |
+
"""Generate a table from the [`HFCacheInfo`] object.
|
| 495 |
+
|
| 496 |
+
Pass `verbosity=0` to get a table with a single row per repo, with columns
|
| 497 |
+
"repo_id", "repo_type", "size_on_disk", "nb_files", "last_accessed", "last_modified", "refs", "local_path".
|
| 498 |
+
|
| 499 |
+
Pass `verbosity=1` to get a table with a row per repo and revision (thus multiple rows can appear for a single repo), with columns
|
| 500 |
+
"repo_id", "repo_type", "revision", "size_on_disk", "nb_files", "last_modified", "refs", "local_path".
|
| 501 |
+
|
| 502 |
+
Example:
|
| 503 |
+
```py
|
| 504 |
+
>>> from huggingface_hub.utils import scan_cache_dir
|
| 505 |
+
|
| 506 |
+
>>> hf_cache_info = scan_cache_dir()
|
| 507 |
+
HFCacheInfo(...)
|
| 508 |
+
|
| 509 |
+
>>> print(hf_cache_info.export_as_table())
|
| 510 |
+
REPO ID REPO TYPE SIZE ON DISK NB FILES LAST_ACCESSED LAST_MODIFIED REFS LOCAL PATH
|
| 511 |
+
--------------------------------------------------- --------- ------------ -------- ------------- ------------- ---- --------------------------------------------------------------------------------------------------
|
| 512 |
+
roberta-base model 2.7M 5 1 day ago 1 week ago main ~/.cache/huggingface/hub/models--roberta-base
|
| 513 |
+
suno/bark model 8.8K 1 1 week ago 1 week ago main ~/.cache/huggingface/hub/models--suno--bark
|
| 514 |
+
t5-base model 893.8M 4 4 days ago 7 months ago main ~/.cache/huggingface/hub/models--t5-base
|
| 515 |
+
t5-large model 3.0G 4 5 weeks ago 5 months ago main ~/.cache/huggingface/hub/models--t5-large
|
| 516 |
+
|
| 517 |
+
>>> print(hf_cache_info.export_as_table(verbosity=1))
|
| 518 |
+
REPO ID REPO TYPE REVISION SIZE ON DISK NB FILES LAST_MODIFIED REFS LOCAL PATH
|
| 519 |
+
--------------------------------------------------- --------- ---------------------------------------- ------------ -------- ------------- ---- -----------------------------------------------------------------------------------------------------------------------------------------------------
|
| 520 |
+
roberta-base model e2da8e2f811d1448a5b465c236feacd80ffbac7b 2.7M 5 1 week ago main ~/.cache/huggingface/hub/models--roberta-base/snapshots/e2da8e2f811d1448a5b465c236feacd80ffbac7b
|
| 521 |
+
suno/bark model 70a8a7d34168586dc5d028fa9666aceade177992 8.8K 1 1 week ago main ~/.cache/huggingface/hub/models--suno--bark/snapshots/70a8a7d34168586dc5d028fa9666aceade177992
|
| 522 |
+
t5-base model a9723ea7f1b39c1eae772870f3b547bf6ef7e6c1 893.8M 4 7 months ago main ~/.cache/huggingface/hub/models--t5-base/snapshots/a9723ea7f1b39c1eae772870f3b547bf6ef7e6c1
|
| 523 |
+
t5-large model 150ebc2c4b72291e770f58e6057481c8d2ed331a 3.0G 4 5 months ago main ~/.cache/huggingface/hub/models--t5-large/snapshots/150ebc2c4b72291e770f58e6057481c8d2ed331a
|
| 524 |
+
```
|
| 525 |
+
|
| 526 |
+
Args:
|
| 527 |
+
verbosity (`int`, *optional*):
|
| 528 |
+
The verbosity level. Defaults to 0.
|
| 529 |
+
|
| 530 |
+
Returns:
|
| 531 |
+
`str`: The table as a string.
|
| 532 |
+
"""
|
| 533 |
+
if verbosity == 0:
|
| 534 |
+
return tabulate(
|
| 535 |
+
rows=[
|
| 536 |
+
[
|
| 537 |
+
repo.repo_id,
|
| 538 |
+
repo.repo_type,
|
| 539 |
+
f"{repo.size_on_disk_str:>12}",
|
| 540 |
+
repo.nb_files,
|
| 541 |
+
repo.last_accessed_str,
|
| 542 |
+
repo.last_modified_str,
|
| 543 |
+
", ".join(sorted(repo.refs)),
|
| 544 |
+
str(repo.repo_path),
|
| 545 |
+
]
|
| 546 |
+
for repo in sorted(self.repos, key=lambda repo: repo.repo_path)
|
| 547 |
+
],
|
| 548 |
+
headers=[
|
| 549 |
+
"REPO ID",
|
| 550 |
+
"REPO TYPE",
|
| 551 |
+
"SIZE ON DISK",
|
| 552 |
+
"NB FILES",
|
| 553 |
+
"LAST_ACCESSED",
|
| 554 |
+
"LAST_MODIFIED",
|
| 555 |
+
"REFS",
|
| 556 |
+
"LOCAL PATH",
|
| 557 |
+
],
|
| 558 |
+
)
|
| 559 |
+
else:
|
| 560 |
+
return tabulate(
|
| 561 |
+
rows=[
|
| 562 |
+
[
|
| 563 |
+
repo.repo_id,
|
| 564 |
+
repo.repo_type,
|
| 565 |
+
revision.commit_hash,
|
| 566 |
+
f"{revision.size_on_disk_str:>12}",
|
| 567 |
+
revision.nb_files,
|
| 568 |
+
revision.last_modified_str,
|
| 569 |
+
", ".join(sorted(revision.refs)),
|
| 570 |
+
str(revision.snapshot_path),
|
| 571 |
+
]
|
| 572 |
+
for repo in sorted(self.repos, key=lambda repo: repo.repo_path)
|
| 573 |
+
for revision in sorted(repo.revisions, key=lambda revision: revision.commit_hash)
|
| 574 |
+
],
|
| 575 |
+
headers=[
|
| 576 |
+
"REPO ID",
|
| 577 |
+
"REPO TYPE",
|
| 578 |
+
"REVISION",
|
| 579 |
+
"SIZE ON DISK",
|
| 580 |
+
"NB FILES",
|
| 581 |
+
"LAST_MODIFIED",
|
| 582 |
+
"REFS",
|
| 583 |
+
"LOCAL PATH",
|
| 584 |
+
],
|
| 585 |
+
)
|
| 586 |
+
|
| 587 |
+
|
| 588 |
+
def scan_cache_dir(cache_dir: str | Path | None = None) -> HFCacheInfo:
|
| 589 |
+
"""Scan the entire HF cache-system and return a [`~HFCacheInfo`] structure.
|
| 590 |
+
|
| 591 |
+
Use `scan_cache_dir` in order to programmatically scan your cache-system. The cache
|
| 592 |
+
will be scanned repo by repo. If a repo is corrupted, a [`~CorruptedCacheException`]
|
| 593 |
+
will be thrown internally but captured and returned in the [`~HFCacheInfo`]
|
| 594 |
+
structure. Only valid repos get a proper report.
|
| 595 |
+
|
| 596 |
+
```py
|
| 597 |
+
>>> from huggingface_hub import scan_cache_dir
|
| 598 |
+
|
| 599 |
+
>>> hf_cache_info = scan_cache_dir()
|
| 600 |
+
HFCacheInfo(
|
| 601 |
+
size_on_disk=3398085269,
|
| 602 |
+
repos=frozenset({
|
| 603 |
+
CachedRepoInfo(
|
| 604 |
+
repo_id='t5-small',
|
| 605 |
+
repo_type='model',
|
| 606 |
+
repo_path=PosixPath(...),
|
| 607 |
+
size_on_disk=970726914,
|
| 608 |
+
nb_files=11,
|
| 609 |
+
revisions=frozenset({
|
| 610 |
+
CachedRevisionInfo(
|
| 611 |
+
commit_hash='d78aea13fa7ecd06c29e3e46195d6341255065d5',
|
| 612 |
+
size_on_disk=970726339,
|
| 613 |
+
snapshot_path=PosixPath(...),
|
| 614 |
+
files=frozenset({
|
| 615 |
+
CachedFileInfo(
|
| 616 |
+
file_name='config.json',
|
| 617 |
+
size_on_disk=1197
|
| 618 |
+
file_path=PosixPath(...),
|
| 619 |
+
blob_path=PosixPath(...),
|
| 620 |
+
),
|
| 621 |
+
CachedFileInfo(...),
|
| 622 |
+
...
|
| 623 |
+
}),
|
| 624 |
+
),
|
| 625 |
+
CachedRevisionInfo(...),
|
| 626 |
+
...
|
| 627 |
+
}),
|
| 628 |
+
),
|
| 629 |
+
CachedRepoInfo(...),
|
| 630 |
+
...
|
| 631 |
+
}),
|
| 632 |
+
warnings=[
|
| 633 |
+
CorruptedCacheException("Snapshots dir doesn't exist in cached repo: ..."),
|
| 634 |
+
CorruptedCacheException(...),
|
| 635 |
+
...
|
| 636 |
+
],
|
| 637 |
+
)
|
| 638 |
+
```
|
| 639 |
+
|
| 640 |
+
You can also print a detailed report directly from the `hf` command line using:
|
| 641 |
+
```text
|
| 642 |
+
> hf cache ls
|
| 643 |
+
ID SIZE LAST_ACCESSED LAST_MODIFIED REFS
|
| 644 |
+
--------------------------- -------- ------------- ------------- -----------
|
| 645 |
+
dataset/nyu-mll/glue 157.4M 2 days ago 2 days ago main script
|
| 646 |
+
model/LiquidAI/LFM2-VL-1.6B 3.2G 4 days ago 4 days ago main
|
| 647 |
+
model/microsoft/UserLM-8b 32.1G 4 days ago 4 days ago main
|
| 648 |
+
|
| 649 |
+
Done in 0.0s. Scanned 6 repo(s) for a total of 3.4G.
|
| 650 |
+
Got 1 warning(s) while scanning. Use -vvv to print details.
|
| 651 |
+
```
|
| 652 |
+
|
| 653 |
+
Args:
|
| 654 |
+
cache_dir (`str` or `Path`, `optional`):
|
| 655 |
+
Cache directory to cache. Defaults to the default HF cache directory.
|
| 656 |
+
|
| 657 |
+
> [!WARNING]
|
| 658 |
+
> Raises:
|
| 659 |
+
>
|
| 660 |
+
> `CacheNotFound`
|
| 661 |
+
> If the cache directory does not exist.
|
| 662 |
+
>
|
| 663 |
+
> [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
| 664 |
+
> If the cache directory is a file, instead of a directory.
|
| 665 |
+
|
| 666 |
+
Returns: a [`~HFCacheInfo`] object.
|
| 667 |
+
"""
|
| 668 |
+
if cache_dir is None:
|
| 669 |
+
cache_dir = HF_HUB_CACHE
|
| 670 |
+
|
| 671 |
+
cache_dir = Path(cache_dir).expanduser().resolve()
|
| 672 |
+
if not cache_dir.exists():
|
| 673 |
+
raise CacheNotFound(
|
| 674 |
+
f"Cache directory not found: {cache_dir}. Please use `cache_dir` argument or set `HF_HUB_CACHE` environment variable.",
|
| 675 |
+
cache_dir=cache_dir,
|
| 676 |
+
)
|
| 677 |
+
|
| 678 |
+
if cache_dir.is_file():
|
| 679 |
+
raise ValueError(
|
| 680 |
+
f"Scan cache expects a directory but found a file: {cache_dir}. Please use `cache_dir` argument or set `HF_HUB_CACHE` environment variable."
|
| 681 |
+
)
|
| 682 |
+
|
| 683 |
+
repos: set[CachedRepoInfo] = set()
|
| 684 |
+
warnings: list[CorruptedCacheException] = []
|
| 685 |
+
for repo_path in cache_dir.iterdir():
|
| 686 |
+
if repo_path.name in FILES_TO_IGNORE:
|
| 687 |
+
continue
|
| 688 |
+
if repo_path.name == ".locks": # skip './.locks/' folder
|
| 689 |
+
continue
|
| 690 |
+
if repo_path.name == "CACHEDIR.TAG": # skip CACHEDIR.TAG file
|
| 691 |
+
continue
|
| 692 |
+
try:
|
| 693 |
+
repos.add(_scan_cached_repo(repo_path))
|
| 694 |
+
except CorruptedCacheException as e:
|
| 695 |
+
warnings.append(e)
|
| 696 |
+
|
| 697 |
+
return HFCacheInfo(
|
| 698 |
+
repos=frozenset(repos),
|
| 699 |
+
size_on_disk=sum(repo.size_on_disk for repo in repos),
|
| 700 |
+
incomplete_files=_scan_incomplete_files(cache_dir),
|
| 701 |
+
warnings=warnings,
|
| 702 |
+
)
|
| 703 |
+
|
| 704 |
+
|
| 705 |
+
def _scan_incomplete_files(cache_dir: Path) -> frozenset[CachedIncompleteFileInfo]:
|
| 706 |
+
"""Find orphaned `*.incomplete` partial-download files in the cache.
|
| 707 |
+
|
| 708 |
+
Interrupted downloads leave `<cache>/<repo>/blobs/<etag>.incomplete` files behind.
|
| 709 |
+
These are not part of any committed revision, so they are reported separately in the
|
| 710 |
+
[`~HFCacheInfo`] returned by [`scan_cache_dir`].
|
| 711 |
+
"""
|
| 712 |
+
files: set[CachedIncompleteFileInfo] = set()
|
| 713 |
+
for path in cache_dir.glob("*/blobs/*.incomplete"):
|
| 714 |
+
try:
|
| 715 |
+
size_on_disk = path.stat().st_size
|
| 716 |
+
except OSError:
|
| 717 |
+
continue
|
| 718 |
+
files.add(CachedIncompleteFileInfo(file_path=path, size_on_disk=size_on_disk))
|
| 719 |
+
return frozenset(files)
|
| 720 |
+
|
| 721 |
+
|
| 722 |
+
def _scan_cached_repo(repo_path: Path) -> CachedRepoInfo:
|
| 723 |
+
"""Scan a single cache repo and return information about it.
|
| 724 |
+
|
| 725 |
+
Any unexpected behavior will raise a [`~CorruptedCacheException`].
|
| 726 |
+
"""
|
| 727 |
+
if not repo_path.is_dir():
|
| 728 |
+
raise CorruptedCacheException(f"Repo path is not a directory: {repo_path}")
|
| 729 |
+
|
| 730 |
+
if "--" not in repo_path.name:
|
| 731 |
+
raise CorruptedCacheException(f"Repo path is not a valid HuggingFace cache directory: {repo_path}")
|
| 732 |
+
|
| 733 |
+
repo_type, repo_id = repo_path.name.split("--", maxsplit=1)
|
| 734 |
+
repo_type = repo_type[:-1] # "models" -> "model"
|
| 735 |
+
repo_id = repo_id.replace("--", "/") # google/fleurs -> "google/fleurs"
|
| 736 |
+
|
| 737 |
+
if repo_type not in {"dataset", "model", "space"}:
|
| 738 |
+
raise CorruptedCacheException(
|
| 739 |
+
f"Repo type must be `dataset`, `model` or `space`, found `{repo_type}` ({repo_path})."
|
| 740 |
+
)
|
| 741 |
+
|
| 742 |
+
blob_stats: dict[Path, os.stat_result] = {} # Key is blob_path, value is blob stats
|
| 743 |
+
|
| 744 |
+
snapshots_path = repo_path / "snapshots"
|
| 745 |
+
refs_path = repo_path / "refs"
|
| 746 |
+
|
| 747 |
+
if not snapshots_path.exists() or not snapshots_path.is_dir():
|
| 748 |
+
raise CorruptedCacheException(f"Snapshots dir doesn't exist in cached repo: {snapshots_path}")
|
| 749 |
+
|
| 750 |
+
# Scan over `refs` directory
|
| 751 |
+
|
| 752 |
+
# key is revision hash, value is set of refs
|
| 753 |
+
refs_by_hash: dict[str, set[str]] = defaultdict(set)
|
| 754 |
+
if refs_path.exists():
|
| 755 |
+
# Example of `refs` directory
|
| 756 |
+
# ── refs
|
| 757 |
+
# ├── main
|
| 758 |
+
# └── refs
|
| 759 |
+
# └── pr
|
| 760 |
+
# └── 1
|
| 761 |
+
if refs_path.is_file():
|
| 762 |
+
raise CorruptedCacheException(f"Refs directory cannot be a file: {refs_path}")
|
| 763 |
+
|
| 764 |
+
for ref_path in refs_path.glob("**/*"):
|
| 765 |
+
# glob("**/*") iterates over all files and directories -> skip directories
|
| 766 |
+
if ref_path.is_dir() or ref_path.name in FILES_TO_IGNORE:
|
| 767 |
+
continue
|
| 768 |
+
|
| 769 |
+
ref_name = str(ref_path.relative_to(refs_path))
|
| 770 |
+
with ref_path.open() as f:
|
| 771 |
+
commit_hash = f.read()
|
| 772 |
+
|
| 773 |
+
refs_by_hash[commit_hash].add(ref_name)
|
| 774 |
+
|
| 775 |
+
# Scan snapshots directory
|
| 776 |
+
cached_revisions: set[CachedRevisionInfo] = set()
|
| 777 |
+
for revision_path in snapshots_path.iterdir():
|
| 778 |
+
# Ignore OS-created helper files
|
| 779 |
+
if revision_path.name in FILES_TO_IGNORE:
|
| 780 |
+
continue
|
| 781 |
+
if revision_path.is_file():
|
| 782 |
+
raise CorruptedCacheException(f"Snapshots folder corrupted. Found a file: {revision_path}")
|
| 783 |
+
|
| 784 |
+
cached_files = set()
|
| 785 |
+
for file_path in revision_path.glob("**/*"):
|
| 786 |
+
# glob("**/*") iterates over all files and directories -> skip directories
|
| 787 |
+
if file_path.is_dir():
|
| 788 |
+
continue
|
| 789 |
+
|
| 790 |
+
blob_path = Path(file_path).resolve()
|
| 791 |
+
if not blob_path.exists():
|
| 792 |
+
raise CorruptedCacheException(f"Blob missing (broken symlink): {blob_path}")
|
| 793 |
+
|
| 794 |
+
if blob_path not in blob_stats:
|
| 795 |
+
blob_stats[blob_path] = blob_path.stat()
|
| 796 |
+
|
| 797 |
+
cached_files.add(
|
| 798 |
+
CachedFileInfo(
|
| 799 |
+
file_name=file_path.name,
|
| 800 |
+
file_path=file_path,
|
| 801 |
+
size_on_disk=blob_stats[blob_path].st_size,
|
| 802 |
+
blob_path=blob_path,
|
| 803 |
+
blob_last_accessed=blob_stats[blob_path].st_atime,
|
| 804 |
+
blob_last_modified=blob_stats[blob_path].st_mtime,
|
| 805 |
+
)
|
| 806 |
+
)
|
| 807 |
+
|
| 808 |
+
# Last modified is either the last modified blob file or the revision folder
|
| 809 |
+
# itself if it is empty
|
| 810 |
+
if len(cached_files) > 0:
|
| 811 |
+
revision_last_modified = max(blob_stats[file.blob_path].st_mtime for file in cached_files)
|
| 812 |
+
else:
|
| 813 |
+
revision_last_modified = revision_path.stat().st_mtime
|
| 814 |
+
|
| 815 |
+
cached_revisions.add(
|
| 816 |
+
CachedRevisionInfo(
|
| 817 |
+
commit_hash=revision_path.name,
|
| 818 |
+
files=frozenset(cached_files),
|
| 819 |
+
refs=frozenset(refs_by_hash.pop(revision_path.name, set())),
|
| 820 |
+
size_on_disk=sum(
|
| 821 |
+
blob_stats[blob_path].st_size for blob_path in {file.blob_path for file in cached_files}
|
| 822 |
+
),
|
| 823 |
+
snapshot_path=revision_path,
|
| 824 |
+
last_modified=revision_last_modified,
|
| 825 |
+
)
|
| 826 |
+
)
|
| 827 |
+
|
| 828 |
+
# Check that all refs referred to an existing revision
|
| 829 |
+
if len(refs_by_hash) > 0:
|
| 830 |
+
raise CorruptedCacheException(
|
| 831 |
+
f"Reference(s) refer to missing commit hashes: {dict(refs_by_hash)} ({repo_path})."
|
| 832 |
+
)
|
| 833 |
+
|
| 834 |
+
# Last modified is either the last modified blob file or the repo folder itself if
|
| 835 |
+
# no blob files has been found. Same for last accessed.
|
| 836 |
+
if len(blob_stats) > 0:
|
| 837 |
+
repo_last_accessed = max(stat.st_atime for stat in blob_stats.values())
|
| 838 |
+
repo_last_modified = max(stat.st_mtime for stat in blob_stats.values())
|
| 839 |
+
else:
|
| 840 |
+
repo_stats = repo_path.stat()
|
| 841 |
+
repo_last_accessed = repo_stats.st_atime
|
| 842 |
+
repo_last_modified = repo_stats.st_mtime
|
| 843 |
+
|
| 844 |
+
# Build and return frozen structure
|
| 845 |
+
return CachedRepoInfo(
|
| 846 |
+
nb_files=len(blob_stats),
|
| 847 |
+
repo_id=repo_id,
|
| 848 |
+
repo_path=repo_path,
|
| 849 |
+
repo_type=repo_type, # type: ignore
|
| 850 |
+
revisions=frozenset(cached_revisions),
|
| 851 |
+
size_on_disk=sum(stat.st_size for stat in blob_stats.values()),
|
| 852 |
+
last_accessed=repo_last_accessed,
|
| 853 |
+
last_modified=repo_last_modified,
|
| 854 |
+
)
|
| 855 |
+
|
| 856 |
+
|
| 857 |
+
def _format_size(num: int) -> str:
|
| 858 |
+
"""Format size in bytes into a human-readable string.
|
| 859 |
+
|
| 860 |
+
Taken from https://stackoverflow.com/a/1094933
|
| 861 |
+
"""
|
| 862 |
+
num_f = float(num)
|
| 863 |
+
for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]:
|
| 864 |
+
if abs(num_f) < 1000.0:
|
| 865 |
+
return f"{num_f:3.1f}{unit}"
|
| 866 |
+
num_f /= 1000.0
|
| 867 |
+
return f"{num_f:.1f}Y"
|
| 868 |
+
|
| 869 |
+
|
| 870 |
+
def _try_delete_path(path: Path, path_type: str) -> None:
|
| 871 |
+
"""Try to delete a local file or folder.
|
| 872 |
+
|
| 873 |
+
If the path does not exist, error is logged as a warning and then ignored.
|
| 874 |
+
|
| 875 |
+
Args:
|
| 876 |
+
path (`Path`)
|
| 877 |
+
Path to delete. Can be a file or a folder.
|
| 878 |
+
path_type (`str`)
|
| 879 |
+
What path are we deleting ? Only for logging purposes. Example: "snapshot".
|
| 880 |
+
"""
|
| 881 |
+
logger.info(f"Delete {path_type}: {path}")
|
| 882 |
+
try:
|
| 883 |
+
if path.is_file():
|
| 884 |
+
os.remove(path)
|
| 885 |
+
else:
|
| 886 |
+
shutil.rmtree(path)
|
| 887 |
+
except FileNotFoundError:
|
| 888 |
+
logger.warning(f"Couldn't delete {path_type}: file not found ({path})", exc_info=True)
|
| 889 |
+
except PermissionError:
|
| 890 |
+
logger.warning(f"Couldn't delete {path_type}: permission denied ({path})", exc_info=True)
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/_chunk_utils.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022-present, the HuggingFace Inc. team.
|
| 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 to iterate by chunks over an iterator."""
|
| 15 |
+
|
| 16 |
+
import itertools
|
| 17 |
+
from collections.abc import Iterable
|
| 18 |
+
from typing import TypeVar
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
T = TypeVar("T")
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def chunk_iterable(iterable: Iterable[T], chunk_size: int) -> Iterable[Iterable[T]]:
|
| 25 |
+
"""Iterates over an iterator chunk by chunk.
|
| 26 |
+
|
| 27 |
+
Taken from https://stackoverflow.com/a/8998040.
|
| 28 |
+
See also https://github.com/huggingface/huggingface_hub/pull/920#discussion_r938793088.
|
| 29 |
+
|
| 30 |
+
Args:
|
| 31 |
+
iterable (`Iterable`):
|
| 32 |
+
The iterable on which we want to iterate.
|
| 33 |
+
chunk_size (`int`):
|
| 34 |
+
Size of the chunks. Must be a strictly positive integer (e.g. >0).
|
| 35 |
+
|
| 36 |
+
Example:
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
>>> from huggingface_hub.utils import chunk_iterable
|
| 40 |
+
|
| 41 |
+
>>> for items in chunk_iterable(range(17), chunk_size=8):
|
| 42 |
+
... print(items)
|
| 43 |
+
# [0, 1, 2, 3, 4, 5, 6, 7]
|
| 44 |
+
# [8, 9, 10, 11, 12, 13, 14, 15]
|
| 45 |
+
# [16] # smaller last chunk
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
Raises:
|
| 49 |
+
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
| 50 |
+
If `chunk_size` <= 0.
|
| 51 |
+
|
| 52 |
+
> [!WARNING]
|
| 53 |
+
> The last chunk can be smaller than `chunk_size`.
|
| 54 |
+
"""
|
| 55 |
+
if not isinstance(chunk_size, int) or chunk_size <= 0:
|
| 56 |
+
raise ValueError("`chunk_size` must be a strictly positive integer (>0).")
|
| 57 |
+
|
| 58 |
+
iterator = iter(iterable)
|
| 59 |
+
while True:
|
| 60 |
+
try:
|
| 61 |
+
next_item = next(iterator)
|
| 62 |
+
except StopIteration:
|
| 63 |
+
return
|
| 64 |
+
yield itertools.chain((next_item,), itertools.islice(iterator, chunk_size - 1))
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/_datetime.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022-present, the HuggingFace Inc. team.
|
| 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 utilities to handle datetimes in Huggingface Hub."""
|
| 15 |
+
|
| 16 |
+
from datetime import datetime, timezone
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def parse_datetime(date_string: str) -> datetime:
|
| 20 |
+
"""
|
| 21 |
+
Parses a date_string returned from the server to a datetime object.
|
| 22 |
+
|
| 23 |
+
This parser is a weak-parser is the sense that it handles only a single format of
|
| 24 |
+
date_string. It is expected that the server format will never change. The
|
| 25 |
+
implementation depends only on the standard lib to avoid an external dependency
|
| 26 |
+
(python-dateutil). See full discussion about this decision on PR:
|
| 27 |
+
https://github.com/huggingface/huggingface_hub/pull/999.
|
| 28 |
+
|
| 29 |
+
Example:
|
| 30 |
+
```py
|
| 31 |
+
> parse_datetime('2022-08-19T07:19:38.123Z')
|
| 32 |
+
datetime.datetime(2022, 8, 19, 7, 19, 38, 123000, tzinfo=timezone.utc)
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
Args:
|
| 36 |
+
date_string (`str`):
|
| 37 |
+
A string representing a datetime returned by the Hub server.
|
| 38 |
+
String is expected to follow '%Y-%m-%dT%H:%M:%S.%fZ' pattern.
|
| 39 |
+
|
| 40 |
+
Returns:
|
| 41 |
+
A python datetime object.
|
| 42 |
+
|
| 43 |
+
Raises:
|
| 44 |
+
:class:`ValueError`:
|
| 45 |
+
If `date_string` cannot be parsed.
|
| 46 |
+
"""
|
| 47 |
+
try:
|
| 48 |
+
# Normalize the string to always have 6 digits of fractional seconds
|
| 49 |
+
if date_string.endswith("Z"):
|
| 50 |
+
# Case 1: No decimal point (e.g., "2024-11-16T00:27:02Z")
|
| 51 |
+
if "." not in date_string:
|
| 52 |
+
# No fractional seconds - insert .000000
|
| 53 |
+
date_string = date_string[:-1] + ".000000Z"
|
| 54 |
+
# Case 2: Has decimal point (e.g., "2022-08-19T07:19:38.123456789Z")
|
| 55 |
+
else:
|
| 56 |
+
# Get the fractional and base parts
|
| 57 |
+
base, fraction = date_string[:-1].split(".")
|
| 58 |
+
# fraction[:6] takes first 6 digits and :0<6 pads with zeros if less than 6 digits
|
| 59 |
+
date_string = f"{base}.{fraction[:6]:0<6}Z"
|
| 60 |
+
|
| 61 |
+
return datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=timezone.utc)
|
| 62 |
+
except ValueError as e:
|
| 63 |
+
raise ValueError(
|
| 64 |
+
f"Cannot parse '{date_string}' as a datetime. Date string is expected to"
|
| 65 |
+
" follow '%Y-%m-%dT%H:%M:%S.%fZ' pattern."
|
| 66 |
+
) from e
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/_deprecation.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import warnings
|
| 2 |
+
from collections.abc import Iterable
|
| 3 |
+
from functools import wraps
|
| 4 |
+
from inspect import Parameter, signature
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def _deprecate_positional_args(*, version: str):
|
| 8 |
+
"""Decorator for methods that issues warnings for positional arguments.
|
| 9 |
+
Using the keyword-only argument syntax in pep 3102, arguments after the
|
| 10 |
+
* will issue a warning when passed as a positional argument.
|
| 11 |
+
|
| 12 |
+
Args:
|
| 13 |
+
version (`str`):
|
| 14 |
+
The version when positional arguments will result in error.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
def _inner_deprecate_positional_args(f):
|
| 18 |
+
sig = signature(f)
|
| 19 |
+
kwonly_args = []
|
| 20 |
+
all_args = []
|
| 21 |
+
for name, param in sig.parameters.items():
|
| 22 |
+
if param.kind == Parameter.POSITIONAL_OR_KEYWORD:
|
| 23 |
+
all_args.append(name)
|
| 24 |
+
elif param.kind == Parameter.KEYWORD_ONLY:
|
| 25 |
+
kwonly_args.append(name)
|
| 26 |
+
|
| 27 |
+
@wraps(f)
|
| 28 |
+
def inner_f(*args, **kwargs):
|
| 29 |
+
extra_args = len(args) - len(all_args)
|
| 30 |
+
if extra_args <= 0:
|
| 31 |
+
return f(*args, **kwargs)
|
| 32 |
+
# extra_args > 0
|
| 33 |
+
args_msg = [
|
| 34 |
+
f"{name}='{arg}'" if isinstance(arg, str) else f"{name}={arg}"
|
| 35 |
+
for name, arg in zip(kwonly_args[:extra_args], args[-extra_args:])
|
| 36 |
+
]
|
| 37 |
+
args_msg = ", ".join(args_msg)
|
| 38 |
+
warnings.warn(
|
| 39 |
+
f"Deprecated positional argument(s) used in '{f.__name__}': pass"
|
| 40 |
+
f" {args_msg} as keyword args. From version {version} passing these"
|
| 41 |
+
" as positional arguments will result in an error,",
|
| 42 |
+
FutureWarning,
|
| 43 |
+
)
|
| 44 |
+
kwargs.update(zip(sig.parameters, args))
|
| 45 |
+
return f(**kwargs)
|
| 46 |
+
|
| 47 |
+
return inner_f
|
| 48 |
+
|
| 49 |
+
return _inner_deprecate_positional_args
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def _deprecate_arguments(
|
| 53 |
+
*,
|
| 54 |
+
version: str,
|
| 55 |
+
deprecated_args: Iterable[str],
|
| 56 |
+
custom_message: str | None = None,
|
| 57 |
+
):
|
| 58 |
+
"""Decorator to issue warnings when using deprecated arguments.
|
| 59 |
+
|
| 60 |
+
TODO: could be useful to be able to set a custom error message.
|
| 61 |
+
|
| 62 |
+
Args:
|
| 63 |
+
version (`str`):
|
| 64 |
+
The version when deprecated arguments will result in error.
|
| 65 |
+
deprecated_args (`list[str]`):
|
| 66 |
+
List of the arguments to be deprecated.
|
| 67 |
+
custom_message (`str`, *optional*):
|
| 68 |
+
Warning message that is raised. If not passed, a default warning message
|
| 69 |
+
will be created.
|
| 70 |
+
"""
|
| 71 |
+
|
| 72 |
+
def _inner_deprecate_positional_args(f):
|
| 73 |
+
sig = signature(f)
|
| 74 |
+
|
| 75 |
+
@wraps(f)
|
| 76 |
+
def inner_f(*args, **kwargs):
|
| 77 |
+
# Check for used deprecated arguments
|
| 78 |
+
used_deprecated_args = []
|
| 79 |
+
for _, parameter in zip(args, sig.parameters.values()):
|
| 80 |
+
if parameter.name in deprecated_args:
|
| 81 |
+
used_deprecated_args.append(parameter.name)
|
| 82 |
+
for kwarg_name, kwarg_value in kwargs.items():
|
| 83 |
+
if (
|
| 84 |
+
# If argument is deprecated but still used
|
| 85 |
+
kwarg_name in deprecated_args
|
| 86 |
+
# And then the value is not the default value
|
| 87 |
+
and kwarg_value != sig.parameters[kwarg_name].default
|
| 88 |
+
):
|
| 89 |
+
used_deprecated_args.append(kwarg_name)
|
| 90 |
+
|
| 91 |
+
# Warn and proceed
|
| 92 |
+
if len(used_deprecated_args) > 0:
|
| 93 |
+
message = (
|
| 94 |
+
f"Deprecated argument(s) used in '{f.__name__}':"
|
| 95 |
+
f" {', '.join(used_deprecated_args)}. Will not be supported from"
|
| 96 |
+
f" version '{version}'."
|
| 97 |
+
)
|
| 98 |
+
if custom_message is not None:
|
| 99 |
+
message += "\n\n" + custom_message
|
| 100 |
+
warnings.warn(message, FutureWarning)
|
| 101 |
+
return f(*args, **kwargs)
|
| 102 |
+
|
| 103 |
+
return inner_f
|
| 104 |
+
|
| 105 |
+
return _inner_deprecate_positional_args
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def _deprecate_method(*, version: str, message: str | None = None):
|
| 109 |
+
"""Decorator to issue warnings when using a deprecated method.
|
| 110 |
+
|
| 111 |
+
Args:
|
| 112 |
+
version (`str`):
|
| 113 |
+
The version when deprecated arguments will result in error.
|
| 114 |
+
message (`str`, *optional*):
|
| 115 |
+
Warning message that is raised. If not passed, a default warning message
|
| 116 |
+
will be created.
|
| 117 |
+
"""
|
| 118 |
+
|
| 119 |
+
def _inner_deprecate_method(f):
|
| 120 |
+
name = f.__name__
|
| 121 |
+
if name == "__init__":
|
| 122 |
+
name = f.__qualname__.split(".")[0] # class name instead of method name
|
| 123 |
+
|
| 124 |
+
@wraps(f)
|
| 125 |
+
def inner_f(*args, **kwargs):
|
| 126 |
+
warning_message = (
|
| 127 |
+
f"'{name}' (from '{f.__module__}') is deprecated and will be removed from version '{version}'."
|
| 128 |
+
)
|
| 129 |
+
if message is not None:
|
| 130 |
+
warning_message += " " + message
|
| 131 |
+
warnings.warn(warning_message, FutureWarning)
|
| 132 |
+
return f(*args, **kwargs)
|
| 133 |
+
|
| 134 |
+
return inner_f
|
| 135 |
+
|
| 136 |
+
return _inner_deprecate_method
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/_detect_agent.py
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2026 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 |
+
"""Detect whether the process is being invoked by an AI coding agent.
|
| 15 |
+
|
| 16 |
+
Detection is based on environment variables that AI agents set in their shell
|
| 17 |
+
sessions. `AI_AGENT` and `AGENT` are treated as a universal standard (any
|
| 18 |
+
tool can set its harness id there); the remaining checks are tool-specific and
|
| 19 |
+
ordered by priority (first match wins).
|
| 20 |
+
|
| 21 |
+
The list of known harnesses is maintained on the Hub and exposed at
|
| 22 |
+
`{ENDPOINT}/api/agent-harnesses`. We fetch it at most once a day and cache it
|
| 23 |
+
locally so the list can be updated without requiring a new client release.
|
| 24 |
+
|
| 25 |
+
Detection is entirely best-effort: there is no hardcoded list of harnesses. When
|
| 26 |
+
the registry cannot be fetched (and no cached copy is available), detection simply
|
| 27 |
+
reports "no agent". Any error while fetching/reading the registry is swallowed —
|
| 28 |
+
detection must never make a process fail.
|
| 29 |
+
|
| 30 |
+
More details: https://huggingface.co/docs/hub/agents-overview#register-your-agent-harness
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
import json
|
| 34 |
+
import os
|
| 35 |
+
import time
|
| 36 |
+
from pathlib import Path
|
| 37 |
+
from typing import Optional, TypedDict
|
| 38 |
+
|
| 39 |
+
from .. import constants
|
| 40 |
+
from . import logging
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
logger = logging.get_logger(__name__)
|
| 44 |
+
|
| 45 |
+
# Refresh the cached registry at most once every 24 hours.
|
| 46 |
+
_REGISTRY_TTL_SECONDS = 24 * 3600
|
| 47 |
+
|
| 48 |
+
# Short timeout: fetching the registry is best-effort telemetry, never block the caller for long.
|
| 49 |
+
_REGISTRY_FETCH_TIMEOUT = 3
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
class HarnessInfo(TypedDict, total=False):
|
| 53 |
+
"""A single harness entry. `envVars` maps an env var name to a match pattern (see `_env_vars_match`)."""
|
| 54 |
+
|
| 55 |
+
envVars: dict[str, str]
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class Registry(TypedDict):
|
| 59 |
+
"""The agent harness registry, as served by `{ENDPOINT}/api/agent-harnesses`."""
|
| 60 |
+
|
| 61 |
+
standardEnvVars: list[str]
|
| 62 |
+
harnesses: dict[str, HarnessInfo]
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
# Empty registry: detection is disabled (no agent ever detected). Used when the
|
| 66 |
+
# Hub is unreachable and no cached copy is available.
|
| 67 |
+
_EMPTY_REGISTRY: Registry = {"standardEnvVars": [], "harnesses": {}}
|
| 68 |
+
|
| 69 |
+
# In-process cache of the resolved registry. Populated lazily on first detection.
|
| 70 |
+
_registry: Registry | None = None
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def detect_agent() -> Optional[str]:
|
| 74 |
+
"""Return the id of the detected AI agent harness or `None`.
|
| 75 |
+
|
| 76 |
+
Harnesses are checked in registry order; for each one we match its env var
|
| 77 |
+
pattern(s) and, failing that, the standard `AI_AGENT` / `AGENT` vars
|
| 78 |
+
against the harness id. The first match wins. When a standard var is set to
|
| 79 |
+
an unrecognized value, `"unknown"` is returned.
|
| 80 |
+
"""
|
| 81 |
+
registry = _get_registry()
|
| 82 |
+
standard_vars = registry.get("standardEnvVars") or []
|
| 83 |
+
harnesses = registry.get("harnesses") or {}
|
| 84 |
+
|
| 85 |
+
for harness_id, info in harnesses.items():
|
| 86 |
+
env_vars = (info or {}).get("envVars")
|
| 87 |
+
if env_vars and _env_vars_match(env_vars):
|
| 88 |
+
return harness_id
|
| 89 |
+
for var in standard_vars:
|
| 90 |
+
if os.environ.get(var, "").strip() == harness_id:
|
| 91 |
+
return harness_id
|
| 92 |
+
|
| 93 |
+
# No harness matched but a standard var is set => unrecognized agent.
|
| 94 |
+
lowercased_harnesses = {k.lower() for k in harnesses.keys()}
|
| 95 |
+
for var in standard_vars:
|
| 96 |
+
if value := os.environ.get(var, "").strip().lower():
|
| 97 |
+
if value in lowercased_harnesses:
|
| 98 |
+
return value
|
| 99 |
+
return "unknown"
|
| 100 |
+
|
| 101 |
+
return None
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def is_agent() -> bool:
|
| 105 |
+
"""Return `True` if the process is being invoked by an AI coding agent."""
|
| 106 |
+
return detect_agent() is not None
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def _env_vars_match(env_vars: dict[str, str]) -> bool:
|
| 110 |
+
"""Return `True` if any `(var, pattern)` from the harness matches the environment.
|
| 111 |
+
|
| 112 |
+
Supported patterns:
|
| 113 |
+
- `"*"`: the variable is set to any non-empty value
|
| 114 |
+
- `"<value>"`: the variable equals this exact value
|
| 115 |
+
"""
|
| 116 |
+
for var, pattern in env_vars.items():
|
| 117 |
+
value = os.environ.get(var)
|
| 118 |
+
if not value:
|
| 119 |
+
continue
|
| 120 |
+
if pattern == "*":
|
| 121 |
+
return True
|
| 122 |
+
if value == pattern:
|
| 123 |
+
return True
|
| 124 |
+
return False
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def _get_registry() -> Registry:
|
| 128 |
+
"""Return the harness registry, loading (and caching in-process) on first call.
|
| 129 |
+
|
| 130 |
+
Best-effort: any unexpected error degrades to an empty registry so detection
|
| 131 |
+
never raises.
|
| 132 |
+
"""
|
| 133 |
+
global _registry
|
| 134 |
+
if _registry is None:
|
| 135 |
+
try:
|
| 136 |
+
_registry = _load_registry()
|
| 137 |
+
except Exception:
|
| 138 |
+
logger.debug("Could not resolve agent harnesses registry.", exc_info=True)
|
| 139 |
+
_registry = _EMPTY_REGISTRY
|
| 140 |
+
return _registry
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def _load_registry() -> Registry:
|
| 144 |
+
"""Resolve the registry from the local cache or the Hub.
|
| 145 |
+
|
| 146 |
+
No hardcoded list: if the Hub is unreachable and no cached copy exists, an
|
| 147 |
+
empty registry is returned (i.e. no agent is detected).
|
| 148 |
+
"""
|
| 149 |
+
path = constants.AGENT_HARNESSES_PATH
|
| 150 |
+
|
| 151 |
+
# 1. Use the cached file if it was refreshed within the last 24 hours.
|
| 152 |
+
if cached := _read_cached_registry(path, max_age=_REGISTRY_TTL_SECONDS):
|
| 153 |
+
return cached
|
| 154 |
+
|
| 155 |
+
# 2. Otherwise refresh it from the Hub and persist it for next time.
|
| 156 |
+
if (fetched := _fetch_registry()) is not None:
|
| 157 |
+
_write_cached_registry(path, fetched)
|
| 158 |
+
return fetched
|
| 159 |
+
|
| 160 |
+
# 3. Fetch failed: reuse a stale cache if available, else give up (no detection).
|
| 161 |
+
if stale := _read_cached_registry(path, max_age=None):
|
| 162 |
+
return stale
|
| 163 |
+
return _EMPTY_REGISTRY
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
def _read_cached_registry(path: str, max_age: int | None) -> Registry | None:
|
| 167 |
+
"""Return the cached registry, or `None` if missing/stale/unreadable."""
|
| 168 |
+
try:
|
| 169 |
+
if not os.path.exists(path):
|
| 170 |
+
return None
|
| 171 |
+
if max_age is not None and (time.time() - os.path.getmtime(path)) >= max_age:
|
| 172 |
+
return None
|
| 173 |
+
with open(path, encoding="utf-8") as f:
|
| 174 |
+
return json.load(f)
|
| 175 |
+
except Exception:
|
| 176 |
+
logger.debug("Could not read cached agent harnesses registry.", exc_info=True)
|
| 177 |
+
return None
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
def _write_cached_registry(path: str, registry: Registry) -> None:
|
| 181 |
+
try:
|
| 182 |
+
Path(path).parent.mkdir(parents=True, exist_ok=True)
|
| 183 |
+
with open(path, "w", encoding="utf-8") as f:
|
| 184 |
+
json.dump(registry, f)
|
| 185 |
+
except Exception:
|
| 186 |
+
logger.debug("Could not cache agent harnesses registry.", exc_info=True)
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
def _fetch_registry() -> Registry | None:
|
| 190 |
+
"""Fetch the registry from the Hub. Returns `None` when offline or on any error."""
|
| 191 |
+
if constants.HF_HUB_OFFLINE:
|
| 192 |
+
return None
|
| 193 |
+
try:
|
| 194 |
+
from ._http import get_session
|
| 195 |
+
|
| 196 |
+
response = get_session().get(
|
| 197 |
+
f"{constants.ENDPOINT}/api/agent-harnesses",
|
| 198 |
+
timeout=_REGISTRY_FETCH_TIMEOUT,
|
| 199 |
+
)
|
| 200 |
+
response.raise_for_status()
|
| 201 |
+
return response.json()
|
| 202 |
+
except Exception:
|
| 203 |
+
logger.debug("Could not fetch agent harnesses registry from the Hub.", exc_info=True)
|
| 204 |
+
return None
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/_dotenv.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AI-generated module (ChatGPT)
|
| 2 |
+
import re
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
# Escape sequences expanded inside quoted values. Double-quoted values additionally
|
| 6 |
+
# expand "\$" to "$"; single-quoted values keep it verbatim.
|
| 7 |
+
_ESCAPES = {"n": "\n", "t": "\t", '"': '"', "\\": "\\"}
|
| 8 |
+
_DOUBLE_QUOTE_ESCAPES = {**_ESCAPES, "$": "$"}
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def _unescape(value: str, escapes: dict[str, str]) -> str:
|
| 12 |
+
r"""Expand backslash escapes in a single left-to-right pass.
|
| 13 |
+
|
| 14 |
+
Processing in one pass (rather than chained `str.replace` calls) ensures an escaped
|
| 15 |
+
backslash (`\\`) is consumed as a unit and cannot merge with the following character,
|
| 16 |
+
e.g. `\\n` is a backslash followed by `n`, not a newline. Unknown escapes are kept as-is.
|
| 17 |
+
"""
|
| 18 |
+
return re.sub(r"\\(.)", lambda match: escapes.get(match.group(1), match.group(0)), value)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def load_dotenv(dotenv_str: str, environ: dict[str, str] | None = None) -> dict[str, str]:
|
| 22 |
+
"""
|
| 23 |
+
Parse a DOTENV-format string and return a dictionary of key-value pairs.
|
| 24 |
+
Handles quoted values, comments, export keyword, and blank lines.
|
| 25 |
+
"""
|
| 26 |
+
env: dict[str, str] = {}
|
| 27 |
+
line_pattern = re.compile(
|
| 28 |
+
r"""
|
| 29 |
+
^\s*
|
| 30 |
+
(?:export[^\S\n]+)? # optional export
|
| 31 |
+
([A-Za-z_][A-Za-z0-9_]*) # key
|
| 32 |
+
[^\S\n]*(=)?[^\S\n]*
|
| 33 |
+
( # value group
|
| 34 |
+
(?:
|
| 35 |
+
'(?:\\'|[^'])*' # single-quoted value
|
| 36 |
+
| \"(?:\\\"|[^\"])*\" # double-quoted value
|
| 37 |
+
| [^#\n\r]+? # unquoted value
|
| 38 |
+
)
|
| 39 |
+
)?
|
| 40 |
+
[^\S\n]*(?:\#.*)?$ # optional inline comment
|
| 41 |
+
""",
|
| 42 |
+
re.VERBOSE,
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
for line in dotenv_str.splitlines():
|
| 46 |
+
line = line.strip()
|
| 47 |
+
if not line or line.startswith("#"):
|
| 48 |
+
continue # Skip comments and empty lines
|
| 49 |
+
|
| 50 |
+
match = line_pattern.match(line)
|
| 51 |
+
if match:
|
| 52 |
+
key = match.group(1)
|
| 53 |
+
val = None
|
| 54 |
+
if match.group(2): # if there is '='
|
| 55 |
+
raw_val = match.group(3) or ""
|
| 56 |
+
val = raw_val.strip()
|
| 57 |
+
# Remove surrounding quotes if quoted
|
| 58 |
+
if (val.startswith('"') and val.endswith('"')) or (val.startswith("'") and val.endswith("'")):
|
| 59 |
+
escapes = _DOUBLE_QUOTE_ESCAPES if raw_val.startswith('"') else _ESCAPES
|
| 60 |
+
val = _unescape(val[1:-1], escapes)
|
| 61 |
+
elif environ is not None:
|
| 62 |
+
# Get it from the current environment
|
| 63 |
+
val = environ.get(key)
|
| 64 |
+
|
| 65 |
+
if val is not None:
|
| 66 |
+
env[key] = val
|
| 67 |
+
|
| 68 |
+
return env
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/_experimental.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2023-present, the HuggingFace Inc. team.
|
| 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 utilities to flag a feature as "experimental" in Huggingface Hub."""
|
| 15 |
+
|
| 16 |
+
import warnings
|
| 17 |
+
from collections.abc import Callable
|
| 18 |
+
from functools import wraps
|
| 19 |
+
|
| 20 |
+
from .. import constants
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def experimental(fn: Callable) -> Callable:
|
| 24 |
+
"""Decorator to flag a feature as experimental.
|
| 25 |
+
|
| 26 |
+
An experimental feature triggers a warning when used as it might be subject to breaking changes without prior notice
|
| 27 |
+
in the future.
|
| 28 |
+
|
| 29 |
+
Warnings can be disabled by setting `HF_HUB_DISABLE_EXPERIMENTAL_WARNING=1` as environment variable.
|
| 30 |
+
|
| 31 |
+
Args:
|
| 32 |
+
fn (`Callable`):
|
| 33 |
+
The function to flag as experimental.
|
| 34 |
+
|
| 35 |
+
Returns:
|
| 36 |
+
`Callable`: The decorated function.
|
| 37 |
+
|
| 38 |
+
Example:
|
| 39 |
+
|
| 40 |
+
```python
|
| 41 |
+
>>> from huggingface_hub.utils import experimental
|
| 42 |
+
|
| 43 |
+
>>> @experimental
|
| 44 |
+
... def my_function():
|
| 45 |
+
... print("Hello world!")
|
| 46 |
+
|
| 47 |
+
>>> my_function()
|
| 48 |
+
UserWarning: 'my_function' is experimental and might be subject to breaking changes in the future without prior
|
| 49 |
+
notice. You can disable this warning by setting `HF_HUB_DISABLE_EXPERIMENTAL_WARNING=1` as environment variable.
|
| 50 |
+
Hello world!
|
| 51 |
+
```
|
| 52 |
+
"""
|
| 53 |
+
# For classes, put the "experimental" around the "__new__" method => __new__ will be removed in warning message
|
| 54 |
+
name = fn.__qualname__[: -len(".__new__")] if fn.__qualname__.endswith(".__new__") else fn.__qualname__
|
| 55 |
+
|
| 56 |
+
@wraps(fn)
|
| 57 |
+
def _inner_fn(*args, **kwargs):
|
| 58 |
+
if not constants.HF_HUB_DISABLE_EXPERIMENTAL_WARNING:
|
| 59 |
+
warnings.warn(
|
| 60 |
+
f"'{name}' is experimental and might be subject to breaking changes in the future without prior notice."
|
| 61 |
+
" You can disable this warning by setting `HF_HUB_DISABLE_EXPERIMENTAL_WARNING=1` as environment"
|
| 62 |
+
" variable.",
|
| 63 |
+
UserWarning,
|
| 64 |
+
)
|
| 65 |
+
return fn(*args, **kwargs)
|
| 66 |
+
|
| 67 |
+
return _inner_fn
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/_fixes.py
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import contextlib
|
| 2 |
+
import os
|
| 3 |
+
import shutil
|
| 4 |
+
import stat
|
| 5 |
+
import tempfile
|
| 6 |
+
import time
|
| 7 |
+
from collections.abc import Callable, Generator
|
| 8 |
+
from functools import partial
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
import yaml
|
| 12 |
+
from filelock import BaseFileLock, FileLock, SoftFileLock, Timeout
|
| 13 |
+
|
| 14 |
+
from .. import constants
|
| 15 |
+
from . import logging
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
logger = logging.get_logger(__name__)
|
| 19 |
+
|
| 20 |
+
# Wrap `yaml.dump` to set `allow_unicode=True` by default.
|
| 21 |
+
#
|
| 22 |
+
# Example:
|
| 23 |
+
# ```py
|
| 24 |
+
# >>> yaml.dump({"emoji": "👀", "some unicode": "日本か"})
|
| 25 |
+
# 'emoji: "\\U0001F440"\nsome unicode: "\\u65E5\\u672C\\u304B"\n'
|
| 26 |
+
#
|
| 27 |
+
# >>> yaml_dump({"emoji": "👀", "some unicode": "日本か"})
|
| 28 |
+
# 'emoji: "👀"\nsome unicode: "日本か"\n'
|
| 29 |
+
# ```
|
| 30 |
+
yaml_dump: Callable[..., str] = partial(yaml.dump, stream=None, allow_unicode=True) # type: ignore
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
@contextlib.contextmanager
|
| 34 |
+
def SoftTemporaryDirectory(
|
| 35 |
+
suffix: str | None = None,
|
| 36 |
+
prefix: str | None = None,
|
| 37 |
+
dir: Path | str | None = None,
|
| 38 |
+
**kwargs,
|
| 39 |
+
) -> Generator[Path, None, None]:
|
| 40 |
+
"""
|
| 41 |
+
Context manager to create a temporary directory and safely delete it.
|
| 42 |
+
|
| 43 |
+
If tmp directory cannot be deleted normally, we set the WRITE permission and retry.
|
| 44 |
+
If cleanup still fails, we give up but don't raise an exception. This is equivalent
|
| 45 |
+
to `tempfile.TemporaryDirectory(..., ignore_cleanup_errors=True)` introduced in
|
| 46 |
+
Python 3.10.
|
| 47 |
+
|
| 48 |
+
See https://www.scivision.dev/python-tempfile-permission-error-windows/.
|
| 49 |
+
"""
|
| 50 |
+
tmpdir = tempfile.TemporaryDirectory(prefix=prefix, suffix=suffix, dir=dir, **kwargs)
|
| 51 |
+
yield Path(tmpdir.name).resolve()
|
| 52 |
+
|
| 53 |
+
try:
|
| 54 |
+
# First once with normal cleanup
|
| 55 |
+
shutil.rmtree(tmpdir.name)
|
| 56 |
+
except Exception:
|
| 57 |
+
# If failed, try to set write permission and retry
|
| 58 |
+
try:
|
| 59 |
+
shutil.rmtree(tmpdir.name, onerror=_set_write_permission_and_retry)
|
| 60 |
+
except Exception:
|
| 61 |
+
pass
|
| 62 |
+
|
| 63 |
+
# And finally, cleanup the tmpdir.
|
| 64 |
+
# If it fails again, give up but do not throw error
|
| 65 |
+
try:
|
| 66 |
+
tmpdir.cleanup()
|
| 67 |
+
except Exception:
|
| 68 |
+
pass
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def _set_write_permission_and_retry(func, path, excinfo):
|
| 72 |
+
os.chmod(path, stat.S_IWRITE)
|
| 73 |
+
func(path)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
@contextlib.contextmanager
|
| 77 |
+
def WeakFileLock(lock_file: str | Path, *, timeout: float | None = None) -> Generator[BaseFileLock, None, None]:
|
| 78 |
+
"""A filelock with some custom logic.
|
| 79 |
+
|
| 80 |
+
This filelock is weaker than the default filelock in that:
|
| 81 |
+
1. It won't raise an exception if release fails.
|
| 82 |
+
2. It will default to a SoftFileLock if the filesystem does not support flock.
|
| 83 |
+
3. Lock files are created with mode 0o664 (group-writable) instead of the default 0o644.
|
| 84 |
+
This allows multiple users sharing a cache directory to wait for locks.
|
| 85 |
+
|
| 86 |
+
An INFO log message is emitted every 10 seconds if the lock is not acquired immediately.
|
| 87 |
+
If a timeout is provided, a `filelock.Timeout` exception is raised if the lock is not acquired within the timeout.
|
| 88 |
+
"""
|
| 89 |
+
log_interval = constants.FILELOCK_LOG_EVERY_SECONDS
|
| 90 |
+
lock = FileLock(lock_file, timeout=log_interval, mode=0o664)
|
| 91 |
+
start_time = time.time()
|
| 92 |
+
|
| 93 |
+
while True:
|
| 94 |
+
elapsed_time = time.time() - start_time
|
| 95 |
+
if timeout is not None and elapsed_time >= timeout:
|
| 96 |
+
raise Timeout(str(lock_file))
|
| 97 |
+
|
| 98 |
+
try:
|
| 99 |
+
lock.acquire(timeout=min(log_interval, timeout - elapsed_time) if timeout else log_interval)
|
| 100 |
+
except Timeout:
|
| 101 |
+
logger.info(
|
| 102 |
+
f"Still waiting to acquire lock on {lock_file} (elapsed: {time.time() - start_time:.1f} seconds)"
|
| 103 |
+
)
|
| 104 |
+
except NotImplementedError as e:
|
| 105 |
+
if "use SoftFileLock instead" in str(e):
|
| 106 |
+
logger.warning(
|
| 107 |
+
"FileSystem does not appear to support flock. Falling back to SoftFileLock for %s", lock_file
|
| 108 |
+
)
|
| 109 |
+
lock = SoftFileLock(lock_file, timeout=log_interval)
|
| 110 |
+
continue
|
| 111 |
+
else:
|
| 112 |
+
break
|
| 113 |
+
|
| 114 |
+
try:
|
| 115 |
+
yield lock
|
| 116 |
+
finally:
|
| 117 |
+
try:
|
| 118 |
+
lock.release()
|
| 119 |
+
except OSError:
|
| 120 |
+
try:
|
| 121 |
+
Path(lock_file).unlink()
|
| 122 |
+
except OSError:
|
| 123 |
+
pass
|
.venv/lib/python3.12/site-packages/huggingface_hub/utils/_git_credential.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022-present, the HuggingFace Inc. team.
|
| 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 utilities to manage Git credentials."""
|
| 15 |
+
|
| 16 |
+
import re
|
| 17 |
+
import subprocess
|
| 18 |
+
|
| 19 |
+
from ..constants import ENDPOINT
|
| 20 |
+
from ._subprocess import run_interactive_subprocess, run_subprocess
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
GIT_CREDENTIAL_REGEX = re.compile(
|
| 24 |
+
r"""
|
| 25 |
+
^\s* # start of line
|
| 26 |
+
credential\.helper # credential.helper value
|
| 27 |
+
\s*=\s* # separator
|
| 28 |
+
([\w\-\/]+) # the helper name or absolute path (group 1)
|
| 29 |
+
(\s|$) # whitespace or end of line
|
| 30 |
+
""",
|
| 31 |
+
flags=re.MULTILINE | re.IGNORECASE | re.VERBOSE,
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def list_credential_helpers(folder: str | None = None) -> list[str]:
|
| 36 |
+
"""Return the list of git credential helpers configured.
|
| 37 |
+
|
| 38 |
+
See https://git-scm.com/docs/gitcredentials.
|
| 39 |
+
|
| 40 |
+
Credentials are saved in all configured helpers (store, cache, macOS keychain,...).
|
| 41 |
+
Calls "`git credential approve`" internally. See https://git-scm.com/docs/git-credential.
|
| 42 |
+
|
| 43 |
+
Args:
|
| 44 |
+
folder (`str`, *optional*):
|
| 45 |
+
The folder in which to check the configured helpers.
|
| 46 |
+
"""
|
| 47 |
+
try:
|
| 48 |
+
output = run_subprocess("git config --list", folder=folder).stdout
|
| 49 |
+
parsed = _parse_credential_output(output)
|
| 50 |
+
return parsed
|
| 51 |
+
except subprocess.CalledProcessError as exc:
|
| 52 |
+
raise OSError(exc.stderr)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def set_git_credential(token: str, username: str = "hf_user", folder: str | None = None) -> None:
|
| 56 |
+
"""Save a username/token pair in git credential for HF Hub registry.
|
| 57 |
+
|
| 58 |
+
Credentials are saved in all configured helpers (store, cache, macOS keychain,...).
|
| 59 |
+
Calls "`git credential approve`" internally. See https://git-scm.com/docs/git-credential.
|
| 60 |
+
|
| 61 |
+
Args:
|
| 62 |
+
username (`str`, defaults to `"hf_user"`):
|
| 63 |
+
A git username. Defaults to `"hf_user"`, the default user used in the Hub.
|
| 64 |
+
token (`str`, defaults to `"hf_user"`):
|
| 65 |
+
A git password. In practice, the User Access Token for the Hub.
|
| 66 |
+
See https://huggingface.co/settings/tokens.
|
| 67 |
+
folder (`str`, *optional*):
|
| 68 |
+
The folder in which to check the configured helpers.
|
| 69 |
+
"""
|
| 70 |
+
with run_interactive_subprocess("git credential approve", folder=folder) as (
|
| 71 |
+
stdin,
|
| 72 |
+
_,
|
| 73 |
+
):
|
| 74 |
+
stdin.write(f"url={ENDPOINT}\nusername={username.lower()}\npassword={token}\n\n")
|
| 75 |
+
stdin.flush()
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def unset_git_credential(username: str = "hf_user", folder: str | None = None) -> None:
|
| 79 |
+
"""Erase credentials from git credential for HF Hub registry.
|
| 80 |
+
|
| 81 |
+
Credentials are erased from the configured helpers (store, cache, macOS
|
| 82 |
+
keychain,...), if any. If `username` is not provided, any credential configured for
|
| 83 |
+
HF Hub endpoint is erased.
|
| 84 |
+
Calls "`git credential erase`" internally. See https://git-scm.com/docs/git-credential.
|
| 85 |
+
|
| 86 |
+
Args:
|
| 87 |
+
username (`str`, defaults to `"hf_user"`):
|
| 88 |
+
A git username. Defaults to `"hf_user"`, the default user used in the Hub.
|
| 89 |
+
folder (`str`, *optional*):
|
| 90 |
+
The folder in which to check the configured helpers.
|
| 91 |
+
"""
|
| 92 |
+
with run_interactive_subprocess("git credential reject", folder=folder) as (
|
| 93 |
+
stdin,
|
| 94 |
+
_,
|
| 95 |
+
):
|
| 96 |
+
standard_input = f"url={ENDPOINT}\n"
|
| 97 |
+
if username is not None:
|
| 98 |
+
standard_input += f"username={username.lower()}\n"
|
| 99 |
+
standard_input += "\n"
|
| 100 |
+
|
| 101 |
+
stdin.write(standard_input)
|
| 102 |
+
stdin.flush()
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def _parse_credential_output(output: str) -> list[str]:
|
| 106 |
+
"""Parse the output of `git credential fill` to extract the password.
|
| 107 |
+
|
| 108 |
+
Args:
|
| 109 |
+
output (`str`):
|
| 110 |
+
The output of `git credential fill`.
|
| 111 |
+
"""
|
| 112 |
+
# NOTE: If user has set a helper for a custom URL, it will not be caught here.
|
| 113 |
+
# Example: `credential.https://huggingface.co.helper=store`
|
| 114 |
+
# See: https://github.com/huggingface/huggingface_hub/pull/1138#discussion_r1013324508
|
| 115 |
+
return sorted( # Sort for nice printing
|
| 116 |
+
{ # Might have some duplicates
|
| 117 |
+
match[0] for match in GIT_CREDENTIAL_REGEX.findall(output)
|
| 118 |
+
}
|
| 119 |
+
)
|