huggingface-hub 0.12.0rc0__py3-none-any.whl → 0.13.0rc0__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.
- huggingface_hub/__init__.py +166 -126
- huggingface_hub/_commit_api.py +25 -51
- huggingface_hub/_login.py +4 -13
- huggingface_hub/_snapshot_download.py +45 -23
- huggingface_hub/_space_api.py +7 -0
- huggingface_hub/commands/delete_cache.py +13 -39
- huggingface_hub/commands/env.py +1 -3
- huggingface_hub/commands/huggingface_cli.py +1 -3
- huggingface_hub/commands/lfs.py +4 -8
- huggingface_hub/commands/scan_cache.py +5 -16
- huggingface_hub/commands/user.py +27 -45
- huggingface_hub/community.py +4 -4
- huggingface_hub/constants.py +22 -19
- huggingface_hub/fastai_utils.py +14 -23
- huggingface_hub/file_download.py +210 -121
- huggingface_hub/hf_api.py +500 -255
- huggingface_hub/hub_mixin.py +181 -176
- huggingface_hub/inference_api.py +4 -10
- huggingface_hub/keras_mixin.py +39 -71
- huggingface_hub/lfs.py +8 -24
- huggingface_hub/repocard.py +33 -48
- huggingface_hub/repocard_data.py +141 -30
- huggingface_hub/repository.py +41 -112
- huggingface_hub/templates/modelcard_template.md +39 -34
- huggingface_hub/utils/__init__.py +1 -0
- huggingface_hub/utils/_cache_assets.py +1 -4
- huggingface_hub/utils/_cache_manager.py +17 -39
- huggingface_hub/utils/_deprecation.py +8 -12
- huggingface_hub/utils/_errors.py +10 -57
- huggingface_hub/utils/_fixes.py +2 -6
- huggingface_hub/utils/_git_credential.py +5 -16
- huggingface_hub/utils/_headers.py +22 -11
- huggingface_hub/utils/_http.py +1 -4
- huggingface_hub/utils/_paths.py +5 -12
- huggingface_hub/utils/_runtime.py +2 -1
- huggingface_hub/utils/_telemetry.py +120 -0
- huggingface_hub/utils/_validators.py +5 -13
- huggingface_hub/utils/endpoint_helpers.py +1 -3
- huggingface_hub/utils/logging.py +10 -8
- {huggingface_hub-0.12.0rc0.dist-info → huggingface_hub-0.13.0rc0.dist-info}/METADATA +7 -14
- huggingface_hub-0.13.0rc0.dist-info/RECORD +56 -0
- huggingface_hub/py.typed +0 -0
- huggingface_hub-0.12.0rc0.dist-info/RECORD +0 -56
- {huggingface_hub-0.12.0rc0.dist-info → huggingface_hub-0.13.0rc0.dist-info}/LICENSE +0 -0
- {huggingface_hub-0.12.0rc0.dist-info → huggingface_hub-0.13.0rc0.dist-info}/WHEEL +0 -0
- {huggingface_hub-0.12.0rc0.dist-info → huggingface_hub-0.13.0rc0.dist-info}/entry_points.txt +0 -0
- {huggingface_hub-0.12.0rc0.dist-info → huggingface_hub-0.13.0rc0.dist-info}/top_level.txt +0 -0
huggingface_hub/fastai_utils.py
CHANGED
|
@@ -144,16 +144,11 @@ def _check_fastai_fastcore_pyproject_versions(
|
|
|
144
144
|
# If the package is specified but not the version (e.g. "fastai" instead of "fastai=2.4"), the default versions are the highest.
|
|
145
145
|
fastai_packages = [pck for pck in package_versions if pck.startswith("fastai")]
|
|
146
146
|
if len(fastai_packages) == 0:
|
|
147
|
-
logger.warning(
|
|
148
|
-
"The repository does not have a fastai version specified in the"
|
|
149
|
-
" `pyproject.toml`."
|
|
150
|
-
)
|
|
147
|
+
logger.warning("The repository does not have a fastai version specified in the `pyproject.toml`.")
|
|
151
148
|
# fastai_version is an empty string if not specified
|
|
152
149
|
else:
|
|
153
150
|
fastai_version = str(fastai_packages[0]).partition("=")[2]
|
|
154
|
-
if fastai_version != "" and version.Version(fastai_version) < version.Version(
|
|
155
|
-
fastai_min_version
|
|
156
|
-
):
|
|
151
|
+
if fastai_version != "" and version.Version(fastai_version) < version.Version(fastai_min_version):
|
|
157
152
|
raise ImportError(
|
|
158
153
|
"`from_pretrained_fastai` requires"
|
|
159
154
|
f" fastai>={fastai_min_version} version but the model to load uses"
|
|
@@ -162,16 +157,11 @@ def _check_fastai_fastcore_pyproject_versions(
|
|
|
162
157
|
|
|
163
158
|
fastcore_packages = [pck for pck in package_versions if pck.startswith("fastcore")]
|
|
164
159
|
if len(fastcore_packages) == 0:
|
|
165
|
-
logger.warning(
|
|
166
|
-
"The repository does not have a fastcore version specified in the"
|
|
167
|
-
" `pyproject.toml`."
|
|
168
|
-
)
|
|
160
|
+
logger.warning("The repository does not have a fastcore version specified in the `pyproject.toml`.")
|
|
169
161
|
# fastcore_version is an empty string if not specified
|
|
170
162
|
else:
|
|
171
163
|
fastcore_version = str(fastcore_packages[0]).partition("=")[2]
|
|
172
|
-
if fastcore_version != "" and version.Version(
|
|
173
|
-
fastcore_version
|
|
174
|
-
) < version.Version(fastcore_min_version):
|
|
164
|
+
if fastcore_version != "" and version.Version(fastcore_version) < version.Version(fastcore_min_version):
|
|
175
165
|
raise ImportError(
|
|
176
166
|
"`from_pretrained_fastai` requires"
|
|
177
167
|
f" fastcore>={fastcore_min_version} version, but you are using fastcore"
|
|
@@ -281,9 +271,7 @@ def _save_pretrained_fastai(
|
|
|
281
271
|
# if the user provides config then we update it with the fastai and fastcore versions in CONFIG_TEMPLATE.
|
|
282
272
|
if config is not None:
|
|
283
273
|
if not isinstance(config, dict):
|
|
284
|
-
raise RuntimeError(
|
|
285
|
-
f"Provided config should be a dict. Got: '{type(config)}'"
|
|
286
|
-
)
|
|
274
|
+
raise RuntimeError(f"Provided config should be a dict. Got: '{type(config)}'")
|
|
287
275
|
path = os.path.join(save_directory, CONFIG_NAME)
|
|
288
276
|
with open(path, "w") as f:
|
|
289
277
|
json.dump(config, f)
|
|
@@ -365,13 +353,15 @@ def push_to_hub_fastai(
|
|
|
365
353
|
create_pr: Optional[bool] = None,
|
|
366
354
|
allow_patterns: Optional[Union[List[str], str]] = None,
|
|
367
355
|
ignore_patterns: Optional[Union[List[str], str]] = None,
|
|
356
|
+
delete_patterns: Optional[Union[List[str], str]] = None,
|
|
368
357
|
api_endpoint: Optional[str] = None,
|
|
369
358
|
):
|
|
370
359
|
"""
|
|
371
360
|
Upload learner checkpoint files to the Hub.
|
|
372
361
|
|
|
373
|
-
Use `allow_patterns` and `ignore_patterns` to precisely filter which files should be
|
|
374
|
-
|
|
362
|
+
Use `allow_patterns` and `ignore_patterns` to precisely filter which files should be pushed to the hub. Use
|
|
363
|
+
`delete_patterns` to delete existing remote files in the same commit. See [`upload_folder`] reference for more
|
|
364
|
+
details.
|
|
375
365
|
|
|
376
366
|
Args:
|
|
377
367
|
learner (`Learner`):
|
|
@@ -399,6 +389,9 @@ def push_to_hub_fastai(
|
|
|
399
389
|
If provided, only files matching at least one pattern are pushed.
|
|
400
390
|
ignore_patterns (`List[str]` or `str`, *optional*):
|
|
401
391
|
If provided, files matching any of the patterns are not pushed.
|
|
392
|
+
delete_patterns (`List[str]` or `str`, *optional*):
|
|
393
|
+
If provided, remote files matching any of the patterns will be deleted from the repo.
|
|
394
|
+
|
|
402
395
|
Returns:
|
|
403
396
|
The url of the commit of your model in the given repository.
|
|
404
397
|
|
|
@@ -413,9 +406,7 @@ def push_to_hub_fastai(
|
|
|
413
406
|
"""
|
|
414
407
|
_check_fastai_fastcore_versions()
|
|
415
408
|
api = HfApi(endpoint=api_endpoint)
|
|
416
|
-
api.create_repo(
|
|
417
|
-
repo_id=repo_id, repo_type="model", token=token, private=private, exist_ok=True
|
|
418
|
-
)
|
|
409
|
+
repo_id = api.create_repo(repo_id=repo_id, token=token, private=private, exist_ok=True).repo_id
|
|
419
410
|
|
|
420
411
|
# Push the files to the repo in a single commit
|
|
421
412
|
with SoftTemporaryDirectory() as tmp:
|
|
@@ -423,7 +414,6 @@ def push_to_hub_fastai(
|
|
|
423
414
|
_save_pretrained_fastai(learner, saved_path, config=config)
|
|
424
415
|
return api.upload_folder(
|
|
425
416
|
repo_id=repo_id,
|
|
426
|
-
repo_type="model",
|
|
427
417
|
token=token,
|
|
428
418
|
folder_path=saved_path,
|
|
429
419
|
commit_message=commit_message,
|
|
@@ -431,4 +421,5 @@ def push_to_hub_fastai(
|
|
|
431
421
|
create_pr=create_pr,
|
|
432
422
|
allow_patterns=allow_patterns,
|
|
433
423
|
ignore_patterns=ignore_patterns,
|
|
424
|
+
delete_patterns=delete_patterns,
|
|
434
425
|
)
|