|
136 | 136 | validate_hf_hub_args, |
137 | 137 | ) |
138 | 138 | from .utils import tqdm as hf_tqdm |
| 139 | +from .utils._deprecation import _deprecate_method |
139 | 140 | from .utils._typing import CallableT |
140 | 141 | from .utils.endpoint_helpers import _is_emission_within_threshold |
141 | 142 |
|
@@ -4018,6 +4019,9 @@ def _payload_as_ndjson() -> Iterable[bytes]: |
4018 | 4019 |
|
4019 | 4020 | @experimental |
4020 | 4021 | @validate_hf_hub_args |
| 4022 | + @_deprecate_method( |
| 4023 | + version="0.27", message="This is an experimental feature. Please use `upload_large_folder` instead." |
| 4024 | + ) |
4021 | 4025 | def create_commits_on_pr( |
4022 | 4026 | self, |
4023 | 4027 | *, |
@@ -4856,8 +4860,10 @@ def upload_folder( |
4856 | 4860 | new files. This is useful if you don't know which files have already been uploaded. |
4857 | 4861 | Note: to avoid discrepancies the `.gitattributes` file is not deleted even if it matches the pattern. |
4858 | 4862 | multi_commits (`bool`): |
| 4863 | + Deprecated. For large uploads, use `upload_large_folder` instead. |
4859 | 4864 | If True, changes are pushed to a PR using a multi-commit process. Defaults to `False`. |
4860 | 4865 | multi_commits_verbose (`bool`): |
| 4866 | + Deprecated. For large uploads, use `upload_large_folder` instead. |
4861 | 4867 | If True and `multi_commits` is used, more information will be displayed to the user. |
4862 | 4868 | run_as_future (`bool`, *optional*): |
4863 | 4869 | Whether or not to run this method in the background. Background jobs are run sequentially without |
@@ -9472,14 +9478,24 @@ def _prepare_upload_folder_additions( |
9472 | 9478 | repo_type=repo_type, |
9473 | 9479 | token=token, |
9474 | 9480 | ) |
| 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 | + ) |
9475 | 9488 |
|
9476 | | - return [ |
| 9489 | + logger.info(f"Start hashing {len(filtered_repo_objects)} files.") |
| 9490 | + operations = [ |
9477 | 9491 | CommitOperationAdd( |
9478 | 9492 | path_or_fileobj=relpath_to_abspath[relpath], # absolute path on disk |
9479 | 9493 | path_in_repo=prefix + relpath, # "absolute" path in repo |
9480 | 9494 | ) |
9481 | 9495 | for relpath in filtered_repo_objects |
9482 | 9496 | ] |
| 9497 | + logger.info(f"Finished hashing {len(filtered_repo_objects)} files.") |
| 9498 | + return operations |
9483 | 9499 |
|
9484 | 9500 | def _validate_yaml(self, content: str, *, repo_type: Optional[str] = None, token: Union[bool, str, None] = None): |
9485 | 9501 | """ |
|
0 commit comments