|
25 | 25 | import warnings |
26 | 26 | from concurrent import futures |
27 | 27 | from pathlib import Path |
28 | | -from typing import Dict, List, Optional, Tuple, Union |
| 28 | +from typing import Dict, List, Optional, Union |
29 | 29 | from urllib.parse import urlparse |
30 | 30 | from uuid import uuid4 |
31 | 31 |
|
|
60 | 60 | hf_raise_for_status, |
61 | 61 | send_telemetry, |
62 | 62 | ) |
63 | | -from huggingface_hub.utils._deprecation import _deprecate_method |
64 | 63 | from requests.exceptions import HTTPError |
65 | 64 |
|
66 | 65 | from . import __version__, logging |
@@ -165,45 +164,6 @@ def is_remote_url(url_or_filename): |
165 | 164 | return parsed.scheme in ("http", "https") |
166 | 165 |
|
167 | 166 |
|
168 | | -# TODO: remove this once fully deprecated |
169 | | -# TODO? remove from './examples/research_projects/lxmert/utils.py' as well |
170 | | -# TODO? remove from './examples/research_projects/visual_bert/utils.py' as well |
171 | | -@_deprecate_method(version="4.39.0", message="This method is outdated and does not support the new cache system.") |
172 | | -def get_cached_models(cache_dir: Union[str, Path] = None) -> List[Tuple]: |
173 | | - """ |
174 | | - Returns a list of tuples representing model binaries that are cached locally. Each tuple has shape `(model_url, |
175 | | - etag, size_MB)`. Filenames in `cache_dir` are use to get the metadata for each model, only urls ending with *.bin* |
176 | | - are added. |
177 | | -
|
178 | | - Args: |
179 | | - cache_dir (`Union[str, Path]`, *optional*): |
180 | | - The cache directory to search for models within. Will default to the transformers cache if unset. |
181 | | -
|
182 | | - Returns: |
183 | | - List[Tuple]: List of tuples each with shape `(model_url, etag, size_MB)` |
184 | | - """ |
185 | | - if cache_dir is None: |
186 | | - cache_dir = TRANSFORMERS_CACHE |
187 | | - elif isinstance(cache_dir, Path): |
188 | | - cache_dir = str(cache_dir) |
189 | | - if not os.path.isdir(cache_dir): |
190 | | - return [] |
191 | | - |
192 | | - cached_models = [] |
193 | | - for file in os.listdir(cache_dir): |
194 | | - if file.endswith(".json"): |
195 | | - meta_path = os.path.join(cache_dir, file) |
196 | | - with open(meta_path, encoding="utf-8") as meta_file: |
197 | | - metadata = json.load(meta_file) |
198 | | - url = metadata["url"] |
199 | | - etag = metadata["etag"] |
200 | | - if url.endswith(".bin"): |
201 | | - size_MB = os.path.getsize(meta_path.strip(".json")) / 1e6 |
202 | | - cached_models.append((url, etag, size_MB)) |
203 | | - |
204 | | - return cached_models |
205 | | - |
206 | | - |
207 | 167 | def define_sagemaker_information(): |
208 | 168 | try: |
209 | 169 | instance_data = requests.get(os.environ["ECS_CONTAINER_METADATA_URI"]).json() |
|
0 commit comments