136136 validate_hf_hub_args ,
137137)
138138from .utils import tqdm as hf_tqdm
139+ from .utils ._deprecation import _deprecate_method
139140from .utils ._typing import CallableT
140141from .utils .endpoint_helpers import _is_emission_within_threshold
141142
@@ -1405,6 +1406,10 @@ class User:
14051406 Number of upvotes received by the user.
14061407 num_likes (`int`, *optional*):
14071408 Number of likes given by the user.
1409+ num_following (`int`, *optional*):
1410+ Number of users this user is following.
1411+ num_followers (`int`, *optional*):
1412+ Number of users following this user.
14081413 orgs (list of [`Organization`]):
14091414 List of organizations the user is part of.
14101415 """
@@ -1423,6 +1428,8 @@ class User:
14231428 num_papers : Optional [int ] = None
14241429 num_upvotes : Optional [int ] = None
14251430 num_likes : Optional [int ] = None
1431+ num_following : Optional [int ] = None
1432+ num_followers : Optional [int ] = None
14261433 orgs : List [Organization ] = field (default_factory = list )
14271434
14281435 def __init__ (self , ** kwargs ) -> None :
@@ -1439,6 +1446,8 @@ def __init__(self, **kwargs) -> None:
14391446 self .num_papers = kwargs .pop ("numPapers" , None )
14401447 self .num_upvotes = kwargs .pop ("numUpvotes" , None )
14411448 self .num_likes = kwargs .pop ("numLikes" , None )
1449+ self .num_following = kwargs .pop ("numFollowing" , None )
1450+ self .num_followers = kwargs .pop ("numFollowers" , None )
14421451 self .user_type = kwargs .pop ("type" , None )
14431452 self .orgs = [Organization (** org ) for org in kwargs .pop ("orgs" , [])]
14441453
@@ -4010,6 +4019,9 @@ def _payload_as_ndjson() -> Iterable[bytes]:
40104019
40114020 @experimental
40124021 @validate_hf_hub_args
4022+ @_deprecate_method (
4023+ version = "0.27" , message = "This is an experimental feature. Please use `upload_large_folder` instead."
4024+ )
40134025 def create_commits_on_pr (
40144026 self ,
40154027 * ,
@@ -4848,8 +4860,10 @@ def upload_folder(
48484860 new files. This is useful if you don't know which files have already been uploaded.
48494861 Note: to avoid discrepancies the `.gitattributes` file is not deleted even if it matches the pattern.
48504862 multi_commits (`bool`):
4863+ Deprecated. For large uploads, use `upload_large_folder` instead.
48514864 If True, changes are pushed to a PR using a multi-commit process. Defaults to `False`.
48524865 multi_commits_verbose (`bool`):
4866+ Deprecated. For large uploads, use `upload_large_folder` instead.
48534867 If True and `multi_commits` is used, more information will be displayed to the user.
48544868 run_as_future (`bool`, *optional*):
48554869 Whether or not to run this method in the background. Background jobs are run sequentially without
@@ -5342,15 +5356,16 @@ def upload_large_folder(
53425356
53435357 Order of priority:
53445358 1. Commit if more than 5 minutes since last commit attempt (and at least 1 file).
5345- 2. Commit if at least 25 files are ready to commit.
5359+ 2. Commit if at least 150 files are ready to commit.
53465360 3. Get upload mode if at least 10 files have been hashed.
53475361 4. Pre-upload LFS file if at least 1 file and no worker is pre-uploading.
53485362 5. Hash file if at least 1 file and no worker is hashing.
53495363 6. Get upload mode if at least 1 file and no worker is getting upload mode.
53505364 7. Pre-upload LFS file if at least 1 file (exception: if hf_transfer is enabled, only 1 worker can preupload LFS at a time).
53515365 8. Hash file if at least 1 file to hash.
53525366 9. Get upload mode if at least 1 file to get upload mode.
5353- 10. Commit if at least 1 file to commit.
5367+ 10. Commit if at least 1 file to commit and at least 1 min since last commit attempt.
5368+ 11. Commit if at least 1 file to commit and all other queues are empty.
53545369
53555370 Special rules:
53565371 - If `hf_transfer` is enabled, only 1 LFS uploader at a time. Otherwise the CPU would be bloated by `hf_transfer`.
@@ -9463,14 +9478,24 @@ def _prepare_upload_folder_additions(
94639478 repo_type = repo_type ,
94649479 token = token ,
94659480 )
9481+ if len (filtered_repo_objects ) > 30 :
9482+ logger .info (
9483+ "It seems you are trying to upload a large folder at once. This might take some time and then fail if "
9484+ "the folder is too large. For such cases, it is recommended to upload in smaller batches or to use "
9485+ "`HfApi().upload_large_folder(...)`/`huggingface-cli upload-large-folder` instead. For more details, "
9486+ "check out https://huggingface.co/docs/huggingface_hub/main/en/guides/upload#upload-a-large-folder."
9487+ )
94669488
9467- return [
9489+ logger .info (f"Start hashing { len (filtered_repo_objects )} files." )
9490+ operations = [
94689491 CommitOperationAdd (
94699492 path_or_fileobj = relpath_to_abspath [relpath ], # absolute path on disk
94709493 path_in_repo = prefix + relpath , # "absolute" path in repo
94719494 )
94729495 for relpath in filtered_repo_objects
94739496 ]
9497+ logger .info (f"Finished hashing { len (filtered_repo_objects )} files." )
9498+ return operations
94749499
94759500 def _validate_yaml (self , content : str , * , repo_type : Optional [str ] = None , token : Union [bool , str , None ] = None ):
94769501 """
0 commit comments