huggingface-hub 1.0.0rc1__py3-none-any.whl → 1.0.0rc2__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.
Potentially problematic release.
This version of huggingface-hub might be problematic. Click here for more details.
- huggingface_hub/__init__.py +1 -1
- huggingface_hub/_commit_api.py +126 -66
- huggingface_hub/_commit_scheduler.py +4 -7
- huggingface_hub/_login.py +9 -15
- huggingface_hub/_tensorboard_logger.py +2 -5
- huggingface_hub/_webhooks_server.py +8 -20
- huggingface_hub/cli/repo.py +137 -5
- huggingface_hub/dataclasses.py +3 -12
- huggingface_hub/fastai_utils.py +22 -32
- huggingface_hub/file_download.py +18 -21
- huggingface_hub/hf_api.py +258 -410
- huggingface_hub/hf_file_system.py +17 -44
- huggingface_hub/inference/_client.py +25 -47
- huggingface_hub/inference/_generated/_async_client.py +25 -47
- huggingface_hub/inference/_mcp/agent.py +2 -5
- huggingface_hub/inference/_mcp/mcp_client.py +2 -5
- huggingface_hub/inference/_providers/__init__.py +11 -0
- huggingface_hub/inference/_providers/_common.py +1 -0
- huggingface_hub/inference/_providers/publicai.py +6 -0
- huggingface_hub/inference/_providers/scaleway.py +28 -0
- huggingface_hub/lfs.py +14 -8
- huggingface_hub/repocard.py +12 -16
- huggingface_hub/serialization/_base.py +3 -6
- huggingface_hub/serialization/_torch.py +16 -34
- huggingface_hub/utils/_cache_manager.py +41 -71
- huggingface_hub/utils/_chunk_utils.py +2 -3
- huggingface_hub/utils/_http.py +27 -30
- huggingface_hub/utils/logging.py +8 -11
- {huggingface_hub-1.0.0rc1.dist-info → huggingface_hub-1.0.0rc2.dist-info}/METADATA +2 -2
- {huggingface_hub-1.0.0rc1.dist-info → huggingface_hub-1.0.0rc2.dist-info}/RECORD +34 -32
- {huggingface_hub-1.0.0rc1.dist-info → huggingface_hub-1.0.0rc2.dist-info}/LICENSE +0 -0
- {huggingface_hub-1.0.0rc1.dist-info → huggingface_hub-1.0.0rc2.dist-info}/WHEEL +0 -0
- {huggingface_hub-1.0.0rc1.dist-info → huggingface_hub-1.0.0rc2.dist-info}/entry_points.txt +0 -0
- {huggingface_hub-1.0.0rc1.dist-info → huggingface_hub-1.0.0rc2.dist-info}/top_level.txt +0 -0
huggingface_hub/hf_api.py
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import inspect
|
|
18
|
-
import io
|
|
19
18
|
import json
|
|
20
19
|
import re
|
|
21
20
|
import struct
|
|
@@ -42,7 +41,7 @@ from typing import (
|
|
|
42
41
|
Union,
|
|
43
42
|
overload,
|
|
44
43
|
)
|
|
45
|
-
from urllib.parse import quote
|
|
44
|
+
from urllib.parse import quote
|
|
46
45
|
|
|
47
46
|
import httpx
|
|
48
47
|
from tqdm.auto import tqdm as base_tqdm
|
|
@@ -57,8 +56,7 @@ from ._commit_api import (
|
|
|
57
56
|
_fetch_files_to_copy,
|
|
58
57
|
_fetch_upload_modes,
|
|
59
58
|
_prepare_commit_payload,
|
|
60
|
-
|
|
61
|
-
_upload_xet_files,
|
|
59
|
+
_upload_files,
|
|
62
60
|
_warn_on_overwriting_operations,
|
|
63
61
|
)
|
|
64
62
|
from ._inference_endpoints import InferenceEndpoint, InferenceEndpointType
|
|
@@ -104,13 +102,8 @@ from .utils import (
|
|
|
104
102
|
validate_hf_hub_args,
|
|
105
103
|
)
|
|
106
104
|
from .utils import tqdm as hf_tqdm
|
|
107
|
-
from .utils._auth import
|
|
108
|
-
_get_token_from_environment,
|
|
109
|
-
_get_token_from_file,
|
|
110
|
-
_get_token_from_google_colab,
|
|
111
|
-
)
|
|
105
|
+
from .utils._auth import _get_token_from_environment, _get_token_from_file, _get_token_from_google_colab
|
|
112
106
|
from .utils._deprecation import _deprecate_arguments
|
|
113
|
-
from .utils._runtime import is_xet_available
|
|
114
107
|
from .utils._typing import CallableT
|
|
115
108
|
from .utils.endpoint_helpers import _is_emission_within_threshold
|
|
116
109
|
|
|
@@ -562,15 +555,12 @@ class RepoSibling:
|
|
|
562
555
|
"""
|
|
563
556
|
Contains basic information about a repo file inside a repo on the Hub.
|
|
564
557
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
retrieve these.
|
|
572
|
-
|
|
573
|
-
</Tip>
|
|
558
|
+
> [!TIP]
|
|
559
|
+
> All attributes of this class are optional except `rfilename`. This is because only the file names are returned when
|
|
560
|
+
> listing repositories on the Hub (with [`list_models`], [`list_datasets`] or [`list_spaces`]). If you need more
|
|
561
|
+
> information like file size, blob id or lfs details, you must request them specifically from one repo at a time
|
|
562
|
+
> (using [`model_info`], [`dataset_info`] or [`space_info`]) as it adds more constraints on the backend server to
|
|
563
|
+
> retrieve these.
|
|
574
564
|
|
|
575
565
|
Attributes:
|
|
576
566
|
rfilename (str):
|
|
@@ -711,13 +701,10 @@ class ModelInfo:
|
|
|
711
701
|
"""
|
|
712
702
|
Contains information about a model on the Hub. This object is returned by [`model_info`] and [`list_models`].
|
|
713
703
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
using [`list_models`] only a subset of the attributes are returned.
|
|
719
|
-
|
|
720
|
-
</Tip>
|
|
704
|
+
> [!TIP]
|
|
705
|
+
> Most attributes of this class are optional. This is because the data returned by the Hub depends on the query made.
|
|
706
|
+
> In general, the more specific the query, the more information is returned. On the contrary, when listing models
|
|
707
|
+
> using [`list_models`] only a subset of the attributes are returned.
|
|
721
708
|
|
|
722
709
|
Attributes:
|
|
723
710
|
id (`str`):
|
|
@@ -910,13 +897,10 @@ class DatasetInfo:
|
|
|
910
897
|
"""
|
|
911
898
|
Contains information about a dataset on the Hub. This object is returned by [`dataset_info`] and [`list_datasets`].
|
|
912
899
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
using [`list_datasets`] only a subset of the attributes are returned.
|
|
918
|
-
|
|
919
|
-
</Tip>
|
|
900
|
+
> [!TIP]
|
|
901
|
+
> Most attributes of this class are optional. This is because the data returned by the Hub depends on the query made.
|
|
902
|
+
> In general, the more specific the query, the more information is returned. On the contrary, when listing datasets
|
|
903
|
+
> using [`list_datasets`] only a subset of the attributes are returned.
|
|
920
904
|
|
|
921
905
|
Attributes:
|
|
922
906
|
id (`str`):
|
|
@@ -1029,13 +1013,10 @@ class SpaceInfo:
|
|
|
1029
1013
|
"""
|
|
1030
1014
|
Contains information about a Space on the Hub. This object is returned by [`space_info`] and [`list_spaces`].
|
|
1031
1015
|
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
using [`list_spaces`] only a subset of the attributes are returned.
|
|
1037
|
-
|
|
1038
|
-
</Tip>
|
|
1016
|
+
> [!TIP]
|
|
1017
|
+
> Most attributes of this class are optional. This is because the data returned by the Hub depends on the query made.
|
|
1018
|
+
> In general, the more specific the query, the more information is returned. On the contrary, when listing spaces
|
|
1019
|
+
> using [`list_spaces`] only a subset of the attributes are returned.
|
|
1039
1020
|
|
|
1040
1021
|
Attributes:
|
|
1041
1022
|
id (`str`):
|
|
@@ -2512,17 +2493,14 @@ class HfApi:
|
|
|
2512
2493
|
Returns:
|
|
2513
2494
|
[`huggingface_hub.hf_api.ModelInfo`]: The model repository information.
|
|
2514
2495
|
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
If the revision to download from cannot be found.
|
|
2524
|
-
|
|
2525
|
-
</Tip>
|
|
2496
|
+
> [!TIP]
|
|
2497
|
+
> Raises the following errors:
|
|
2498
|
+
>
|
|
2499
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
2500
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
2501
|
+
> or because it is set to `private` and you do not have access.
|
|
2502
|
+
> - [`~utils.RevisionNotFoundError`]
|
|
2503
|
+
> If the revision to download from cannot be found.
|
|
2526
2504
|
"""
|
|
2527
2505
|
if expand and (securityStatus or files_metadata):
|
|
2528
2506
|
raise ValueError("`expand` cannot be used if `securityStatus` or `files_metadata` are set.")
|
|
@@ -2586,17 +2564,14 @@ class HfApi:
|
|
|
2586
2564
|
Returns:
|
|
2587
2565
|
[`hf_api.DatasetInfo`]: The dataset repository information.
|
|
2588
2566
|
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
If the revision to download from cannot be found.
|
|
2598
|
-
|
|
2599
|
-
</Tip>
|
|
2567
|
+
> [!TIP]
|
|
2568
|
+
> Raises the following errors:
|
|
2569
|
+
>
|
|
2570
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
2571
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
2572
|
+
> or because it is set to `private` and you do not have access.
|
|
2573
|
+
> - [`~utils.RevisionNotFoundError`]
|
|
2574
|
+
> If the revision to download from cannot be found.
|
|
2600
2575
|
"""
|
|
2601
2576
|
if expand and files_metadata:
|
|
2602
2577
|
raise ValueError("`expand` cannot be used if `files_metadata` is set.")
|
|
@@ -2659,17 +2634,14 @@ class HfApi:
|
|
|
2659
2634
|
Returns:
|
|
2660
2635
|
[`~hf_api.SpaceInfo`]: The space repository information.
|
|
2661
2636
|
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
If the revision to download from cannot be found.
|
|
2671
|
-
|
|
2672
|
-
</Tip>
|
|
2637
|
+
> [!TIP]
|
|
2638
|
+
> Raises the following errors:
|
|
2639
|
+
>
|
|
2640
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
2641
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
2642
|
+
> or because it is set to `private` and you do not have access.
|
|
2643
|
+
> - [`~utils.RevisionNotFoundError`]
|
|
2644
|
+
> If the revision to download from cannot be found.
|
|
2673
2645
|
"""
|
|
2674
2646
|
if expand and files_metadata:
|
|
2675
2647
|
raise ValueError("`expand` cannot be used if `files_metadata` is set.")
|
|
@@ -2736,17 +2708,14 @@ class HfApi:
|
|
|
2736
2708
|
[`huggingface_hub.hf_api.DatasetInfo`], [`huggingface_hub.hf_api.ModelInfo`]
|
|
2737
2709
|
or [`huggingface_hub.hf_api.SpaceInfo`] object.
|
|
2738
2710
|
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
If the revision to download from cannot be found.
|
|
2748
|
-
|
|
2749
|
-
</Tip>
|
|
2711
|
+
> [!TIP]
|
|
2712
|
+
> Raises the following errors:
|
|
2713
|
+
>
|
|
2714
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
2715
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
2716
|
+
> or because it is set to `private` and you do not have access.
|
|
2717
|
+
> - [`~utils.RevisionNotFoundError`]
|
|
2718
|
+
> If the revision to download from cannot be found.
|
|
2750
2719
|
"""
|
|
2751
2720
|
if repo_type is None or repo_type == "model":
|
|
2752
2721
|
method = self.model_info
|
|
@@ -3333,18 +3302,12 @@ class HfApi:
|
|
|
3333
3302
|
Squashing the repo history is useful when you know you'll make hundreds of commits and you don't want to
|
|
3334
3303
|
clutter the history. Squashing commits can only be performed from the head of a branch.
|
|
3335
3304
|
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
Once squashed, the commit history cannot be retrieved. This is a non-revertible operation.
|
|
3305
|
+
> [!WARNING]
|
|
3306
|
+
> Once squashed, the commit history cannot be retrieved. This is a non-revertible operation.
|
|
3339
3307
|
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
Once the history of a branch has been squashed, it is not possible to merge it back into another branch since
|
|
3345
|
-
their history will have diverged.
|
|
3346
|
-
|
|
3347
|
-
</Tip>
|
|
3308
|
+
> [!WARNING]
|
|
3309
|
+
> Once the history of a branch has been squashed, it is not possible to merge it back into another branch since
|
|
3310
|
+
> their history will have diverged.
|
|
3348
3311
|
|
|
3349
3312
|
Args:
|
|
3350
3313
|
repo_id (`str`):
|
|
@@ -3471,12 +3434,9 @@ class HfApi:
|
|
|
3471
3434
|
"""
|
|
3472
3435
|
Permanently delete LFS files from a repo on the Hub.
|
|
3473
3436
|
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
This is a
|
|
3477
|
-
repository. This is a non-revertible operation. Use it only if you know what you are doing.
|
|
3478
|
-
|
|
3479
|
-
</Tip>
|
|
3437
|
+
> [!WARNING]
|
|
3438
|
+
> This is a permanent action that will affect all commits referencing the deleted files and might corrupt your
|
|
3439
|
+
> repository. This is a non-revertible operation. Use it only if you know what you are doing.
|
|
3480
3440
|
|
|
3481
3441
|
Args:
|
|
3482
3442
|
repo_id (`str`):
|
|
@@ -3841,15 +3801,12 @@ class HfApi:
|
|
|
3841
3801
|
https://huggingface.co/docs/huggingface_hub/quick-start#authentication).
|
|
3842
3802
|
To disable authentication, pass `False`.
|
|
3843
3803
|
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
or because it is set to `private` and you do not have access.
|
|
3851
|
-
|
|
3852
|
-
</Tip>
|
|
3804
|
+
> [!TIP]
|
|
3805
|
+
> Raises the following errors:
|
|
3806
|
+
>
|
|
3807
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
3808
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
3809
|
+
> or because it is set to `private` and you do not have access.
|
|
3853
3810
|
"""
|
|
3854
3811
|
if len(from_id.split("/")) != 2:
|
|
3855
3812
|
raise ValueError(f"Invalid repo_id: {from_id}. It should have a namespace (:namespace:/:repo_name:)")
|
|
@@ -3928,27 +3885,18 @@ class HfApi:
|
|
|
3928
3885
|
"""
|
|
3929
3886
|
Creates a commit in the given repo, deleting & uploading files as needed.
|
|
3930
3887
|
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
for multiple commits.
|
|
3935
|
-
|
|
3936
|
-
</Tip>
|
|
3937
|
-
|
|
3938
|
-
<Tip warning={true}>
|
|
3939
|
-
|
|
3940
|
-
`create_commit` assumes that the repo already exists on the Hub. If you get a
|
|
3941
|
-
Client error 404, please make sure you are authenticated and that `repo_id` and
|
|
3942
|
-
`repo_type` are set correctly. If repo does not exist, create it first using
|
|
3943
|
-
[`~hf_api.create_repo`].
|
|
3888
|
+
> [!WARNING]
|
|
3889
|
+
> The input list of `CommitOperation` will be mutated during the commit process. Do not reuse the same objects
|
|
3890
|
+
> for multiple commits.
|
|
3944
3891
|
|
|
3945
|
-
|
|
3892
|
+
> [!WARNING]
|
|
3893
|
+
> `create_commit` assumes that the repo already exists on the Hub. If you get a
|
|
3894
|
+
> Client error 404, please make sure you are authenticated and that `repo_id` and
|
|
3895
|
+
> `repo_type` are set correctly. If repo does not exist, create it first using
|
|
3896
|
+
> [`~hf_api.create_repo`].
|
|
3946
3897
|
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
`create_commit` is limited to 25k LFS files and a 1GB payload for regular files.
|
|
3950
|
-
|
|
3951
|
-
</Tip>
|
|
3898
|
+
> [!WARNING]
|
|
3899
|
+
> `create_commit` is limited to 25k LFS files and a 1GB payload for regular files.
|
|
3952
3900
|
|
|
3953
3901
|
Args:
|
|
3954
3902
|
repo_id (`str`):
|
|
@@ -4222,21 +4170,15 @@ class HfApi:
|
|
|
4222
4170
|
This method is useful if you are generating the files to upload on-the-fly and you don't want to store them
|
|
4223
4171
|
in memory before uploading them all at once.
|
|
4224
4172
|
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
Use [`create_commit`] directly instead.
|
|
4229
|
-
|
|
4230
|
-
</Tip>
|
|
4173
|
+
> [!WARNING]
|
|
4174
|
+
> This is a power-user method. You shouldn't need to call it directly to make a normal commit.
|
|
4175
|
+
> Use [`create_commit`] directly instead.
|
|
4231
4176
|
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
commit operation object, pass `free_memory=False`.
|
|
4238
|
-
|
|
4239
|
-
</Tip>
|
|
4177
|
+
> [!WARNING]
|
|
4178
|
+
> Commit operations will be mutated during the process. In particular, the attached `path_or_fileobj` will be
|
|
4179
|
+
> removed after the upload to save memory (and replaced by an empty `bytes` object). Do not reuse the same
|
|
4180
|
+
> objects except to pass them to [`create_commit`]. If you don't want to remove the attached content from the
|
|
4181
|
+
> commit operation object, pass `free_memory=False`.
|
|
4240
4182
|
|
|
4241
4183
|
Args:
|
|
4242
4184
|
repo_id (`str`):
|
|
@@ -4342,6 +4284,10 @@ class HfApi:
|
|
|
4342
4284
|
f"Skipped upload for {len(new_lfs_additions) - len(new_lfs_additions_to_upload)} LFS file(s) "
|
|
4343
4285
|
"(ignored by gitignore file)."
|
|
4344
4286
|
)
|
|
4287
|
+
# If no LFS files remain to upload, keep previous behavior and log explicitly
|
|
4288
|
+
if len(new_lfs_additions_to_upload) == 0:
|
|
4289
|
+
logger.debug("No LFS files to upload.")
|
|
4290
|
+
return
|
|
4345
4291
|
# Prepare upload parameters
|
|
4346
4292
|
upload_kwargs = {
|
|
4347
4293
|
"additions": new_lfs_additions_to_upload,
|
|
@@ -4354,32 +4300,7 @@ class HfApi:
|
|
|
4354
4300
|
# PR (i.e. `revision`).
|
|
4355
4301
|
"revision": revision if not create_pr else None,
|
|
4356
4302
|
}
|
|
4357
|
-
|
|
4358
|
-
# - xet is enabled for the repo,
|
|
4359
|
-
# - the files are provided as str or paths objects,
|
|
4360
|
-
# - the library is installed.
|
|
4361
|
-
# Otherwise, default back to LFS.
|
|
4362
|
-
xet_enabled = self.repo_info(
|
|
4363
|
-
repo_id=repo_id,
|
|
4364
|
-
repo_type=repo_type,
|
|
4365
|
-
revision=unquote(revision) if revision is not None else revision,
|
|
4366
|
-
expand="xetEnabled",
|
|
4367
|
-
token=token,
|
|
4368
|
-
).xet_enabled
|
|
4369
|
-
has_buffered_io_data = any(
|
|
4370
|
-
isinstance(addition.path_or_fileobj, io.BufferedIOBase) for addition in new_lfs_additions_to_upload
|
|
4371
|
-
)
|
|
4372
|
-
if xet_enabled and not has_buffered_io_data and is_xet_available():
|
|
4373
|
-
logger.debug("Uploading files using Xet Storage..")
|
|
4374
|
-
_upload_xet_files(**upload_kwargs, create_pr=create_pr) # type: ignore [arg-type]
|
|
4375
|
-
else:
|
|
4376
|
-
if xet_enabled and is_xet_available():
|
|
4377
|
-
if has_buffered_io_data:
|
|
4378
|
-
logger.warning(
|
|
4379
|
-
"Uploading files as a binary IO buffer is not supported by Xet Storage. "
|
|
4380
|
-
"Falling back to HTTP upload."
|
|
4381
|
-
)
|
|
4382
|
-
_upload_lfs_files(**upload_kwargs, num_threads=num_threads) # type: ignore [arg-type]
|
|
4303
|
+
_upload_files(**upload_kwargs, num_threads=num_threads, create_pr=create_pr) # type: ignore [arg-type]
|
|
4383
4304
|
for addition in new_lfs_additions_to_upload:
|
|
4384
4305
|
addition._is_uploaded = True
|
|
4385
4306
|
if free_memory:
|
|
@@ -4489,30 +4410,24 @@ class HfApi:
|
|
|
4489
4410
|
Instance of [`CommitInfo`] containing information about the newly created commit (commit hash, commit
|
|
4490
4411
|
url, pr url, commit message,...). If `run_as_future=True` is passed, returns a Future object which will
|
|
4491
4412
|
contain the result when executed.
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
`upload_file` assumes that the repo already exists on the Hub. If you get a
|
|
4511
|
-
Client error 404, please make sure you are authenticated and that `repo_id` and
|
|
4512
|
-
`repo_type` are set correctly. If repo does not exist, create it first using
|
|
4513
|
-
[`~hf_api.create_repo`].
|
|
4514
|
-
|
|
4515
|
-
</Tip>
|
|
4413
|
+
> [!TIP]
|
|
4414
|
+
> Raises the following errors:
|
|
4415
|
+
>
|
|
4416
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
4417
|
+
> if the HuggingFace API returned an error
|
|
4418
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
4419
|
+
> if some parameter value is invalid
|
|
4420
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
4421
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
4422
|
+
> or because it is set to `private` and you do not have access.
|
|
4423
|
+
> - [`~utils.RevisionNotFoundError`]
|
|
4424
|
+
> If the revision to download from cannot be found.
|
|
4425
|
+
|
|
4426
|
+
> [!WARNING]
|
|
4427
|
+
> `upload_file` assumes that the repo already exists on the Hub. If you get a
|
|
4428
|
+
> Client error 404, please make sure you are authenticated and that `repo_id` and
|
|
4429
|
+
> `repo_type` are set correctly. If repo does not exist, create it first using
|
|
4430
|
+
> [`~hf_api.create_repo`].
|
|
4516
4431
|
|
|
4517
4432
|
Example:
|
|
4518
4433
|
|
|
@@ -4705,30 +4620,21 @@ class HfApi:
|
|
|
4705
4620
|
url, pr url, commit message,...). If `run_as_future=True` is passed, returns a Future object which will
|
|
4706
4621
|
contain the result when executed.
|
|
4707
4622
|
|
|
4708
|
-
|
|
4623
|
+
> [!TIP]
|
|
4624
|
+
> Raises the following errors:
|
|
4625
|
+
>
|
|
4626
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
4627
|
+
> if the HuggingFace API returned an error
|
|
4628
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
4629
|
+
> if some parameter value is invalid
|
|
4709
4630
|
|
|
4710
|
-
|
|
4631
|
+
> [!WARNING]
|
|
4632
|
+
> `upload_folder` assumes that the repo already exists on the Hub. If you get a Client error 404, please make
|
|
4633
|
+
> sure you are authenticated and that `repo_id` and `repo_type` are set correctly. If repo does not exist, create
|
|
4634
|
+
> it first using [`~hf_api.create_repo`].
|
|
4711
4635
|
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
- [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
4715
|
-
if some parameter value is invalid
|
|
4716
|
-
|
|
4717
|
-
</Tip>
|
|
4718
|
-
|
|
4719
|
-
<Tip warning={true}>
|
|
4720
|
-
|
|
4721
|
-
`upload_folder` assumes that the repo already exists on the Hub. If you get a Client error 404, please make
|
|
4722
|
-
sure you are authenticated and that `repo_id` and `repo_type` are set correctly. If repo does not exist, create
|
|
4723
|
-
it first using [`~hf_api.create_repo`].
|
|
4724
|
-
|
|
4725
|
-
</Tip>
|
|
4726
|
-
|
|
4727
|
-
<Tip>
|
|
4728
|
-
|
|
4729
|
-
When dealing with a large folder (thousands of files or hundreds of GB), we recommend using [`~hf_api.upload_large_folder`] instead.
|
|
4730
|
-
|
|
4731
|
-
</Tip>
|
|
4636
|
+
> [!TIP]
|
|
4637
|
+
> When dealing with a large folder (thousands of files or hundreds of GB), we recommend using [`~hf_api.upload_large_folder`] instead.
|
|
4732
4638
|
|
|
4733
4639
|
Example:
|
|
4734
4640
|
|
|
@@ -4871,23 +4777,20 @@ class HfApi:
|
|
|
4871
4777
|
especially useful if the repo is updated / committed to concurrently.
|
|
4872
4778
|
|
|
4873
4779
|
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
If the file to download cannot be found.
|
|
4889
|
-
|
|
4890
|
-
</Tip>
|
|
4780
|
+
> [!TIP]
|
|
4781
|
+
> Raises the following errors:
|
|
4782
|
+
>
|
|
4783
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
4784
|
+
> if the HuggingFace API returned an error
|
|
4785
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
4786
|
+
> if some parameter value is invalid
|
|
4787
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
4788
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
4789
|
+
> or because it is set to `private` and you do not have access.
|
|
4790
|
+
> - [`~utils.RevisionNotFoundError`]
|
|
4791
|
+
> If the revision to download from cannot be found.
|
|
4792
|
+
> - [`~utils.EntryNotFoundError`]
|
|
4793
|
+
> If the file to download cannot be found.
|
|
4891
4794
|
|
|
4892
4795
|
"""
|
|
4893
4796
|
commit_message = (
|
|
@@ -5104,25 +5007,19 @@ class HfApi:
|
|
|
5104
5007
|
print_report_every (`int`, *optional*):
|
|
5105
5008
|
Frequency at which the report is printed. Defaults to 60 seconds.
|
|
5106
5009
|
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
- Do not upload the same folder to several repositories. If you need to do so, you must delete the local `.cache/.huggingface/` folder first.
|
|
5010
|
+
> [!TIP]
|
|
5011
|
+
> A few things to keep in mind:
|
|
5012
|
+
> - Repository limits still apply: https://huggingface.co/docs/hub/repositories-recommendations
|
|
5013
|
+
> - Do not start several processes in parallel.
|
|
5014
|
+
> - You can interrupt and resume the process at any time.
|
|
5015
|
+
> - Do not upload the same folder to several repositories. If you need to do so, you must delete the local `.cache/.huggingface/` folder first.
|
|
5114
5016
|
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
- you cannot set a custom `commit_message` and `commit_description` since multiple commits are created.
|
|
5122
|
-
- you cannot delete from the repo while uploading. Please make a separate commit first.
|
|
5123
|
-
- you cannot create a PR directly. Please create a PR first (from the UI or using [`create_pull_request`]) and then commit to it by passing `revision`.
|
|
5124
|
-
|
|
5125
|
-
</Tip>
|
|
5017
|
+
> [!WARNING]
|
|
5018
|
+
> While being much more robust to upload large folders, `upload_large_folder` is more limited than [`upload_folder`] feature-wise. In practice:
|
|
5019
|
+
> - you cannot set a custom `path_in_repo`. If you want to upload to a subfolder, you need to set the proper structure locally.
|
|
5020
|
+
> - you cannot set a custom `commit_message` and `commit_description` since multiple commits are created.
|
|
5021
|
+
> - you cannot delete from the repo while uploading. Please make a separate commit first.
|
|
5022
|
+
> - you cannot create a PR directly. Please create a PR first (from the UI or using [`create_pull_request`]) and then commit to it by passing `revision`.
|
|
5126
5023
|
|
|
5127
5024
|
**Technical details:**
|
|
5128
5025
|
|
|
@@ -6129,19 +6026,16 @@ class HfApi:
|
|
|
6129
6026
|
|
|
6130
6027
|
Returns: [`DiscussionWithDetails`]
|
|
6131
6028
|
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
or because it is set to `private` and you do not have access.
|
|
6143
|
-
|
|
6144
|
-
</Tip>
|
|
6029
|
+
> [!TIP]
|
|
6030
|
+
> Raises the following errors:
|
|
6031
|
+
>
|
|
6032
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
6033
|
+
> if the HuggingFace API returned an error
|
|
6034
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
6035
|
+
> if some parameter value is invalid
|
|
6036
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
6037
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
6038
|
+
> or because it is set to `private` and you do not have access.
|
|
6145
6039
|
"""
|
|
6146
6040
|
if not isinstance(discussion_num, int) or discussion_num <= 0:
|
|
6147
6041
|
raise ValueError("Invalid discussion_num, must be a positive integer")
|
|
@@ -6222,19 +6116,16 @@ class HfApi:
|
|
|
6222
6116
|
|
|
6223
6117
|
Returns: [`DiscussionWithDetails`]
|
|
6224
6118
|
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
or because it is set to `private` and you do not have access.
|
|
6236
|
-
|
|
6237
|
-
</Tip>"""
|
|
6119
|
+
> [!TIP]
|
|
6120
|
+
> Raises the following errors:
|
|
6121
|
+
>
|
|
6122
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
6123
|
+
> if the HuggingFace API returned an error
|
|
6124
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
6125
|
+
> if some parameter value is invalid
|
|
6126
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
6127
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
6128
|
+
> or because it is set to `private` and you do not have access."""
|
|
6238
6129
|
if repo_type not in constants.REPO_TYPES:
|
|
6239
6130
|
raise ValueError(f"Invalid repo type, must be one of {constants.REPO_TYPES}")
|
|
6240
6131
|
if repo_type is None:
|
|
@@ -6310,19 +6201,16 @@ class HfApi:
|
|
|
6310
6201
|
|
|
6311
6202
|
Returns: [`DiscussionWithDetails`]
|
|
6312
6203
|
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
or because it is set to `private` and you do not have access.
|
|
6324
|
-
|
|
6325
|
-
</Tip>"""
|
|
6204
|
+
> [!TIP]
|
|
6205
|
+
> Raises the following errors:
|
|
6206
|
+
>
|
|
6207
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
6208
|
+
> if the HuggingFace API returned an error
|
|
6209
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
6210
|
+
> if some parameter value is invalid
|
|
6211
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
6212
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
6213
|
+
> or because it is set to `private` and you do not have access."""
|
|
6326
6214
|
return self.create_discussion(
|
|
6327
6215
|
repo_id=repo_id,
|
|
6328
6216
|
title=title,
|
|
@@ -6413,19 +6301,16 @@ class HfApi:
|
|
|
6413
6301
|
|
|
6414
6302
|
```
|
|
6415
6303
|
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
or because it is set to `private` and you do not have access.
|
|
6427
|
-
|
|
6428
|
-
</Tip>
|
|
6304
|
+
> [!TIP]
|
|
6305
|
+
> Raises the following errors:
|
|
6306
|
+
>
|
|
6307
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
6308
|
+
> if the HuggingFace API returned an error
|
|
6309
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
6310
|
+
> if some parameter value is invalid
|
|
6311
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
6312
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
6313
|
+
> or because it is set to `private` and you do not have access.
|
|
6429
6314
|
"""
|
|
6430
6315
|
resp = self._post_discussion_changes(
|
|
6431
6316
|
repo_id=repo_id,
|
|
@@ -6483,19 +6368,16 @@ class HfApi:
|
|
|
6483
6368
|
|
|
6484
6369
|
```
|
|
6485
6370
|
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
or because it is set to `private` and you do not have access.
|
|
6497
|
-
|
|
6498
|
-
</Tip>
|
|
6371
|
+
> [!TIP]
|
|
6372
|
+
> Raises the following errors:
|
|
6373
|
+
>
|
|
6374
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
6375
|
+
> if the HuggingFace API returned an error
|
|
6376
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
6377
|
+
> if some parameter value is invalid
|
|
6378
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
6379
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
6380
|
+
> or because it is set to `private` and you do not have access.
|
|
6499
6381
|
"""
|
|
6500
6382
|
resp = self._post_discussion_changes(
|
|
6501
6383
|
repo_id=repo_id,
|
|
@@ -6556,19 +6438,16 @@ class HfApi:
|
|
|
6556
6438
|
|
|
6557
6439
|
```
|
|
6558
6440
|
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
or because it is set to `private` and you do not have access.
|
|
6570
|
-
|
|
6571
|
-
</Tip>
|
|
6441
|
+
> [!TIP]
|
|
6442
|
+
> Raises the following errors:
|
|
6443
|
+
>
|
|
6444
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
6445
|
+
> if the HuggingFace API returned an error
|
|
6446
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
6447
|
+
> if some parameter value is invalid
|
|
6448
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
6449
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
6450
|
+
> or because it is set to `private` and you do not have access.
|
|
6572
6451
|
"""
|
|
6573
6452
|
if new_status not in ["open", "closed"]:
|
|
6574
6453
|
raise ValueError("Invalid status, valid statuses are: 'open' and 'closed'")
|
|
@@ -6618,19 +6497,16 @@ class HfApi:
|
|
|
6618
6497
|
Returns:
|
|
6619
6498
|
[`DiscussionStatusChange`]: the status change event
|
|
6620
6499
|
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
or because it is set to `private` and you do not have access.
|
|
6632
|
-
|
|
6633
|
-
</Tip>
|
|
6500
|
+
> [!TIP]
|
|
6501
|
+
> Raises the following errors:
|
|
6502
|
+
>
|
|
6503
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
6504
|
+
> if the HuggingFace API returned an error
|
|
6505
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
6506
|
+
> if some parameter value is invalid
|
|
6507
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
6508
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
6509
|
+
> or because it is set to `private` and you do not have access.
|
|
6634
6510
|
"""
|
|
6635
6511
|
self._post_discussion_changes(
|
|
6636
6512
|
repo_id=repo_id,
|
|
@@ -6677,19 +6553,16 @@ class HfApi:
|
|
|
6677
6553
|
Returns:
|
|
6678
6554
|
[`DiscussionComment`]: the edited comment
|
|
6679
6555
|
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
or because it is set to `private` and you do not have access.
|
|
6691
|
-
|
|
6692
|
-
</Tip>
|
|
6556
|
+
> [!TIP]
|
|
6557
|
+
> Raises the following errors:
|
|
6558
|
+
>
|
|
6559
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
6560
|
+
> if the HuggingFace API returned an error
|
|
6561
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
6562
|
+
> if some parameter value is invalid
|
|
6563
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
6564
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
6565
|
+
> or because it is set to `private` and you do not have access.
|
|
6693
6566
|
"""
|
|
6694
6567
|
resp = self._post_discussion_changes(
|
|
6695
6568
|
repo_id=repo_id,
|
|
@@ -6713,9 +6586,8 @@ class HfApi:
|
|
|
6713
6586
|
) -> DiscussionComment:
|
|
6714
6587
|
"""Hides a comment on a Discussion / Pull Request.
|
|
6715
6588
|
|
|
6716
|
-
|
|
6717
|
-
Hidden comments' content cannot be retrieved anymore. Hiding a comment is irreversible.
|
|
6718
|
-
</Tip>
|
|
6589
|
+
> [!WARNING]
|
|
6590
|
+
> Hidden comments' content cannot be retrieved anymore. Hiding a comment is irreversible.
|
|
6719
6591
|
|
|
6720
6592
|
Args:
|
|
6721
6593
|
repo_id (`str`):
|
|
@@ -6738,19 +6610,16 @@ class HfApi:
|
|
|
6738
6610
|
Returns:
|
|
6739
6611
|
[`DiscussionComment`]: the hidden comment
|
|
6740
6612
|
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
or because it is set to `private` and you do not have access.
|
|
6752
|
-
|
|
6753
|
-
</Tip>
|
|
6613
|
+
> [!TIP]
|
|
6614
|
+
> Raises the following errors:
|
|
6615
|
+
>
|
|
6616
|
+
> - [`HTTPError`](https://requests.readthedocs.io/en/latest/api/#requests.HTTPError)
|
|
6617
|
+
> if the HuggingFace API returned an error
|
|
6618
|
+
> - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
|
|
6619
|
+
> if some parameter value is invalid
|
|
6620
|
+
> - [`~utils.RepositoryNotFoundError`]
|
|
6621
|
+
> If the repository to download from cannot be found. This may be because it doesn't exist,
|
|
6622
|
+
> or because it is set to `private` and you do not have access.
|
|
6754
6623
|
"""
|
|
6755
6624
|
warnings.warn(
|
|
6756
6625
|
"Hidden comments' content cannot be retrieved anymore. Hiding a comment is irreversible.",
|
|
@@ -6974,11 +6843,8 @@ class HfApi:
|
|
|
6974
6843
|
Returns:
|
|
6975
6844
|
[`SpaceRuntime`]: Runtime information about a Space including Space stage and hardware.
|
|
6976
6845
|
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
It is also possible to request hardware directly when creating the Space repo! See [`create_repo`] for details.
|
|
6980
|
-
|
|
6981
|
-
</Tip>
|
|
6846
|
+
> [!TIP]
|
|
6847
|
+
> It is also possible to request hardware directly when creating the Space repo! See [`create_repo`] for details.
|
|
6982
6848
|
"""
|
|
6983
6849
|
if sleep_time is not None and hardware == SpaceHardware.CPU_BASIC:
|
|
6984
6850
|
warnings.warn(
|
|
@@ -7025,11 +6891,8 @@ class HfApi:
|
|
|
7025
6891
|
Returns:
|
|
7026
6892
|
[`SpaceRuntime`]: Runtime information about a Space including Space stage and hardware.
|
|
7027
6893
|
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
It is also possible to set a custom sleep time when requesting hardware with [`request_space_hardware`].
|
|
7031
|
-
|
|
7032
|
-
</Tip>
|
|
6894
|
+
> [!TIP]
|
|
6895
|
+
> It is also possible to set a custom sleep time when requesting hardware with [`request_space_hardware`].
|
|
7033
6896
|
"""
|
|
7034
6897
|
r = get_session().post(
|
|
7035
6898
|
f"{self.endpoint}/api/spaces/{repo_id}/sleeptime",
|
|
@@ -7275,12 +7138,9 @@ class HfApi:
|
|
|
7275
7138
|
Returns:
|
|
7276
7139
|
[`SpaceRuntime`]: Runtime information about a Space including Space stage and hardware.
|
|
7277
7140
|
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
via [`delete_space_storage`].
|
|
7282
|
-
|
|
7283
|
-
</Tip>
|
|
7141
|
+
> [!TIP]
|
|
7142
|
+
> It is not possible to decrease persistent storage after its granted. To do so, you must delete it
|
|
7143
|
+
> via [`delete_space_storage`].
|
|
7284
7144
|
"""
|
|
7285
7145
|
payload: dict[str, SpaceStorage] = {"tier": storage}
|
|
7286
7146
|
r = get_session().post(
|
|
@@ -7644,12 +7504,9 @@ class HfApi:
|
|
|
7644
7504
|
Returns:
|
|
7645
7505
|
[`InferenceEndpoint`]: information about the new Inference Endpoint.
|
|
7646
7506
|
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
if you have any suggestions or requests.
|
|
7651
|
-
|
|
7652
|
-
</Tip>
|
|
7507
|
+
> [!WARNING]
|
|
7508
|
+
> `create_inference_endpoint_from_catalog` is experimental. Its API is subject to change in the future. Please provide feedback
|
|
7509
|
+
> if you have any suggestions or requests.
|
|
7653
7510
|
"""
|
|
7654
7511
|
token = token or self.token or get_token()
|
|
7655
7512
|
payload: dict = {
|
|
@@ -7686,13 +7543,10 @@ class HfApi:
|
|
|
7686
7543
|
https://huggingface.co/docs/huggingface_hub/quick-start#authentication).
|
|
7687
7544
|
|
|
7688
7545
|
Returns:
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
if you have any suggestions or requests.
|
|
7694
|
-
|
|
7695
|
-
</Tip>
|
|
7546
|
+
List[`str`]: A list of model IDs available in the catalog.
|
|
7547
|
+
> [!WARNING]
|
|
7548
|
+
> `list_inference_catalog` is experimental. Its API is subject to change in the future. Please provide feedback
|
|
7549
|
+
> if you have any suggestions or requests.
|
|
7696
7550
|
"""
|
|
7697
7551
|
response = get_session().get(
|
|
7698
7552
|
f"{constants.INFERENCE_CATALOG_ENDPOINT}/repo-list",
|
|
@@ -8055,12 +7909,9 @@ class HfApi:
|
|
|
8055
7909
|
) -> Iterable[Collection]:
|
|
8056
7910
|
"""List collections on the Huggingface Hub, given some filters.
|
|
8057
7911
|
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
from a collection, you must use [`get_collection`].
|
|
8062
|
-
|
|
8063
|
-
</Tip>
|
|
7912
|
+
> [!WARNING]
|
|
7913
|
+
> When listing collections, the item list per collection is truncated to 4 items maximum. To retrieve all items
|
|
7914
|
+
> from a collection, you must use [`get_collection`].
|
|
8064
7915
|
|
|
8065
7916
|
Args:
|
|
8066
7917
|
owner (`list[str]` or `str`, *optional*):
|
|
@@ -8300,11 +8151,8 @@ class HfApi:
|
|
|
8300
8151
|
>>> collection = delete_collection("username/useless-collection-64f9a55bb3115b4f513ec026", missing_ok=True)
|
|
8301
8152
|
```
|
|
8302
8153
|
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
This is a non-revertible action. A deleted collection cannot be restored.
|
|
8306
|
-
|
|
8307
|
-
</Tip>
|
|
8154
|
+
> [!WARNING]
|
|
8155
|
+
> This is a non-revertible action. A deleted collection cannot be restored.
|
|
8308
8156
|
"""
|
|
8309
8157
|
r = get_session().delete(
|
|
8310
8158
|
f"{self.endpoint}/api/collections/{collection_slug}", headers=self._build_hf_headers(token=token)
|