clarifai 10.11.2rc1__py3-none-any.whl → 10.11.2rc2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- clarifai/__init__.py +1 -1
- clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/loader.cpython-310.pyc +0 -0
- clarifai/runners/utils/loader.py +42 -9
- {clarifai-10.11.2rc1.dist-info → clarifai-10.11.2rc2.dist-info}/METADATA +1 -1
- {clarifai-10.11.2rc1.dist-info → clarifai-10.11.2rc2.dist-info}/RECORD +10 -10
- {clarifai-10.11.2rc1.dist-info → clarifai-10.11.2rc2.dist-info}/LICENSE +0 -0
- {clarifai-10.11.2rc1.dist-info → clarifai-10.11.2rc2.dist-info}/WHEEL +0 -0
- {clarifai-10.11.2rc1.dist-info → clarifai-10.11.2rc2.dist-info}/entry_points.txt +0 -0
- {clarifai-10.11.2rc1.dist-info → clarifai-10.11.2rc2.dist-info}/top_level.txt +0 -0
clarifai/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "10.11.
|
1
|
+
__version__ = "10.11.2rc2"
|
Binary file
|
Binary file
|
clarifai/runners/utils/loader.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
import fnmatch
|
1
2
|
import importlib.util
|
2
3
|
import json
|
3
4
|
import os
|
5
|
+
import shutil
|
4
6
|
import subprocess
|
5
7
|
|
6
8
|
from clarifai.utils.logging import logger
|
@@ -39,7 +41,7 @@ class HuggingFaceLoader:
|
|
39
41
|
def download_checkpoints(self, checkpoint_path: str):
|
40
42
|
# throw error if huggingface_hub wasn't installed
|
41
43
|
try:
|
42
|
-
from huggingface_hub import
|
44
|
+
from huggingface_hub import snapshot_download
|
43
45
|
except ImportError:
|
44
46
|
raise ImportError(self.HF_DOWNLOAD_TEXT)
|
45
47
|
if os.path.exists(checkpoint_path) and self.validate_download(checkpoint_path):
|
@@ -53,16 +55,17 @@ class HuggingFaceLoader:
|
|
53
55
|
logger.error("Model %s not found on Hugging Face" % (self.repo_id))
|
54
56
|
return False
|
55
57
|
|
56
|
-
ignore_patterns =
|
57
|
-
repo_files = list_repo_files(repo_id=self.repo_id, token=self.token)
|
58
|
-
if any(f.endswith(".safetensors") for f in repo_files):
|
59
|
-
logger.info(f"SafeTensors found in {self.repo_id}, downloading only .safetensors files.")
|
60
|
-
ignore_patterns = ["**/original/*", "**/*.pth", "**/*.bin"]
|
58
|
+
self.ignore_patterns = self._get_ignore_patterns()
|
61
59
|
snapshot_download(
|
62
60
|
repo_id=self.repo_id,
|
63
61
|
local_dir=checkpoint_path,
|
64
62
|
local_dir_use_symlinks=False,
|
65
|
-
ignore_patterns=ignore_patterns)
|
63
|
+
ignore_patterns=self.ignore_patterns)
|
64
|
+
# Remove the `.cache` folder if it exists
|
65
|
+
cache_path = os.path.join(checkpoint_path, ".cache")
|
66
|
+
if os.path.exists(cache_path) and os.path.isdir(cache_path):
|
67
|
+
shutil.rmtree(cache_path)
|
68
|
+
|
66
69
|
except Exception as e:
|
67
70
|
logger.error(f"Error downloading model checkpoints {e}")
|
68
71
|
return False
|
@@ -109,11 +112,41 @@ class HuggingFaceLoader:
|
|
109
112
|
from huggingface_hub import list_repo_files
|
110
113
|
except ImportError:
|
111
114
|
raise ImportError(self.HF_DOWNLOAD_TEXT)
|
115
|
+
# Get the list of files on the repo
|
116
|
+
repo_files = list_repo_files(self.repo_id, token=self.token)
|
117
|
+
|
118
|
+
self.ignore_patterns = self._get_ignore_patterns()
|
119
|
+
# Get the list of files on the repo that are not ignored
|
120
|
+
if getattr(self, "ignore_patterns", None):
|
121
|
+
patterns = self.ignore_patterns
|
122
|
+
|
123
|
+
def should_ignore(file_path):
|
124
|
+
return any(fnmatch.fnmatch(file_path, pattern) for pattern in patterns)
|
125
|
+
|
126
|
+
repo_files = [f for f in repo_files if not should_ignore(f)]
|
127
|
+
|
128
|
+
# Check if downloaded files match the files we expect (ignoring ignored patterns)
|
112
129
|
checkpoint_dir_files = [
|
113
130
|
f for dp, dn, fn in os.walk(os.path.expanduser(checkpoint_path)) for f in fn
|
114
131
|
]
|
115
|
-
|
116
|
-
|
132
|
+
|
133
|
+
# Validate by comparing file lists
|
134
|
+
return len(checkpoint_dir_files) >= len(repo_files) and not (
|
135
|
+
len(set(repo_files) - set(checkpoint_dir_files)) > 0) and len(repo_files) > 0
|
136
|
+
|
137
|
+
def _get_ignore_patterns(self):
|
138
|
+
# check if model exists on HF
|
139
|
+
try:
|
140
|
+
from huggingface_hub import list_repo_files
|
141
|
+
except ImportError:
|
142
|
+
raise ImportError(self.HF_DOWNLOAD_TEXT)
|
143
|
+
|
144
|
+
# Get the list of files on the repo that are not ignored
|
145
|
+
repo_files = list_repo_files(self.repo_id, token=self.token)
|
146
|
+
self.ignore_patterns = None
|
147
|
+
if any(f.endswith(".safetensors") for f in repo_files):
|
148
|
+
self.ignore_patterns = ["**/original/*", "**/*.pth", "**/*.bin", "*.pth", "*.bin"]
|
149
|
+
return self.ignore_patterns
|
117
150
|
|
118
151
|
@staticmethod
|
119
152
|
def validate_config(checkpoint_path: str):
|
@@ -1,4 +1,4 @@
|
|
1
|
-
clarifai/__init__.py,sha256=
|
1
|
+
clarifai/__init__.py,sha256=REHNxfXEu4hO10MzxhqE0eEABGHhr7fJC2K18uUkiFE,27
|
2
2
|
clarifai/cli.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
clarifai/errors.py,sha256=RwzTajwds51wLD0MVlMC5kcpBnzRpreDLlazPSBZxrg,2605
|
4
4
|
clarifai/versions.py,sha256=jctnczzfGk_S3EnVqb2FjRKfSREkNmvNEwAAa_VoKiQ,222
|
@@ -193,19 +193,19 @@ clarifai/runners/models/__pycache__/model_class.cpython-310.pyc,sha256=OxOQDH4G_
|
|
193
193
|
clarifai/runners/models/__pycache__/model_run_locally.cpython-310.pyc,sha256=_vm1H_HBCwWRpl-3mVjRIVbvHDYM6-sz9OheR1BmzcE,17040
|
194
194
|
clarifai/runners/models/__pycache__/model_runner.cpython-310.pyc,sha256=lMrT9MMO3sLTo11zSv5XYTBQte3oY23esUFV4Wdnquw,5108
|
195
195
|
clarifai/runners/models/__pycache__/model_servicer.cpython-310.pyc,sha256=w5kENnKCiiZSpZF6g7N1wljHbnan3pi_mhZBm_VvD4Q,2489
|
196
|
-
clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc,sha256=
|
196
|
+
clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc,sha256=OiN-ZtidnMP_D95E0j-YvimcRS0b8ewSyb27chdkKtg,19274
|
197
197
|
clarifai/runners/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
198
198
|
clarifai/runners/utils/const.py,sha256=eyBrj5ywuGKPF-IFipm7yjiYyLhnsKhMNZ6xF-OvykQ,1250
|
199
199
|
clarifai/runners/utils/data_handler.py,sha256=sxy9zlAgI6ETuxCQhUgEXAn2GCsaW1GxpK6GTaMne0g,6966
|
200
200
|
clarifai/runners/utils/data_utils.py,sha256=R1iQ82TuQ9JwxCJk8yEB1Lyb0BYVhVbWJI9YDi1zGOs,318
|
201
|
-
clarifai/runners/utils/loader.py,sha256=
|
201
|
+
clarifai/runners/utils/loader.py,sha256=u4dSnOf8JcAlR2wKaWxvz4KzMfJ9oL-9orhgwtVGhJU,5975
|
202
202
|
clarifai/runners/utils/logging.py,sha256=xan5ZQH5XHVyNIIjUAQoc_bS3MrjQjEvBYuo0CQKdho,153
|
203
203
|
clarifai/runners/utils/url_fetcher.py,sha256=v_8JOWmkyFAzsBulsieKX7Nfjy1Yg7wGSZeqfEvw2cg,1640
|
204
204
|
clarifai/runners/utils/__pycache__/__init__.cpython-310.pyc,sha256=PRPZOzUV5Z8grWizu5RKOkki0iLYxZDJBgsLfmCcieE,170
|
205
205
|
clarifai/runners/utils/__pycache__/const.cpython-310.pyc,sha256=oEBBn71Dyzuo25Rrt-UwPSUT7EAOliC1QZUYFVhW4vI,1028
|
206
206
|
clarifai/runners/utils/__pycache__/data_handler.cpython-310.pyc,sha256=YVncnM0NaHeMaZAyALxaHCdtUT6n5E3BI99-54Bs6HM,7961
|
207
207
|
clarifai/runners/utils/__pycache__/data_utils.cpython-310.pyc,sha256=1e6NiK6bnJiiAo2KPsDmm91BSlbI3mVkQZKbDfh5hBI,642
|
208
|
-
clarifai/runners/utils/__pycache__/loader.cpython-310.pyc,sha256=
|
208
|
+
clarifai/runners/utils/__pycache__/loader.cpython-310.pyc,sha256=svMKSepeCGYtgtGt3AObNK4t80Y_Q_7oNeoGoHbQ5oo,5058
|
209
209
|
clarifai/runners/utils/__pycache__/logging.cpython-310.pyc,sha256=VV0KFcnuYpFFtaG4EeDIgg7c4QEsBLo-eX_NnsyFEhA,331
|
210
210
|
clarifai/runners/utils/__pycache__/url_fetcher.cpython-310.pyc,sha256=jFxVdOmm7DCkgatv1GwIXeefHthpvlkg4ybBlMnmxss,1739
|
211
211
|
clarifai/schema/search.py,sha256=JjTi8ammJgZZ2OGl4K6tIA4zEJ1Fr2ASZARXavI1j5c,2448
|
@@ -234,9 +234,9 @@ clarifai/workflows/__pycache__/__init__.cpython-310.pyc,sha256=oRKg6B7Z-wWQy0EW2
|
|
234
234
|
clarifai/workflows/__pycache__/export.cpython-310.pyc,sha256=cNmGLnww7xVpm4htd1vRhQJoEZ1dhpN1oD8iLLAtVzM,2418
|
235
235
|
clarifai/workflows/__pycache__/utils.cpython-310.pyc,sha256=rm2kWk4a3GOKWoerXpEAEeRvGhEe7wPd0ZZ6jHtEGqY,1925
|
236
236
|
clarifai/workflows/__pycache__/validate.cpython-310.pyc,sha256=QA1i6YdDpY824cqtQvkEaFPpaCa2iqfOwFouqwZfAKY,2139
|
237
|
-
clarifai-10.11.
|
238
|
-
clarifai-10.11.
|
239
|
-
clarifai-10.11.
|
240
|
-
clarifai-10.11.
|
241
|
-
clarifai-10.11.
|
242
|
-
clarifai-10.11.
|
237
|
+
clarifai-10.11.2rc2.dist-info/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
|
238
|
+
clarifai-10.11.2rc2.dist-info/METADATA,sha256=Agq8Yp740aLqvNaYe4wWY8yIzkotmHxl_-ONWSLscQY,22237
|
239
|
+
clarifai-10.11.2rc2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
240
|
+
clarifai-10.11.2rc2.dist-info/entry_points.txt,sha256=X9FZ4Z-i_r2Ud1RpZ9sNIFYuu_-9fogzCMCRUD9hyX0,51
|
241
|
+
clarifai-10.11.2rc2.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
|
242
|
+
clarifai-10.11.2rc2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|