Skip to content

Commit 082bb08

Browse files
Wauplinhanouticelina
authored andcommitted
[v1.0] Remove more deprecated stuff (#3345)
* remove constants.-hf_cache_home * remove smoothly_deprecate_use_auth_token * remove get_token_permission * remove update_repo_visibility * remove is_write_action arg * remove write_permission arg from login methods * new parameter skip_if_logged_in in login methods * Remove resume_download / force_filename parameters * Remove deprecated local_dir_use_symlinks parameter * Remove deprecated language, library, task, tags from list_models * Return commit URL in upload_file/upload_folder (previously url to file/folder on the Hub) * fix upload_file/upload_folder tests * smoothly_deprecate_legacy_arguments everywhere * code quality * fix tests * fix xet tests
1 parent 048050b commit 082bb08

26 files changed

+137
-625
lines changed

docs/source/de/guides/integrations.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Obwohl dieser Ansatz flexibel ist, hat er einige Nachteile, insbesondere in Bezu
8282
- `token`: zum Herunterladen aus einem privaten Repository
8383
- `revision`: zum Herunterladen von einem spezifischen Branch
8484
- `cache_dir`: um Dateien in einem spezifischen Verzeichnis zu cachen
85-
- `force_download`/`resume_download`/`local_files_only`: um den Cache wieder zu verwenden oder nicht
85+
- `force_download`/`local_files_only`: um den Cache wieder zu verwenden oder nicht
8686
- `api_endpoint`/`proxies`: HTTP-Session konfigurieren
8787

8888
Beim Pushen von Modellen werden ähnliche Parameter unterstützt:
@@ -203,7 +203,6 @@ class PyTorchModelHubMixin(ModelHubMixin):
203203
cache_dir: str,
204204
force_download: bool,
205205
proxies: Optional[dict],
206-
resume_download: bool,
207206
local_files_only: bool,
208207
token: Union[str, bool, None],
209208
map_location: str = "cpu", # zusätzliches Argument
@@ -221,8 +220,6 @@ class PyTorchModelHubMixin(ModelHubMixin):
221220
revision=revision,
222221
cache_dir=cache_dir,
223222
force_download=force_download,
224-
proxies=proxies,
225-
resume_download=resume_download,
226223
token=token,
227224
local_files_only=local_files_only,
228225
)
@@ -242,9 +239,9 @@ Und das war's! Ihre Bibliothek ermöglicht es Benutzern nun, Dateien vom und zum
242239
Lassen Sie uns die beiden Ansätze, die wir gesehen haben, schnell mit ihren Vor- und Nachteilen zusammenfassen. Die untenstehende Tabelle ist nur indikativ. Ihr Framework könnte einige Besonderheiten haben, die Sie berücksichtigen müssen. Dieser Leitfaden soll nur Richtlinien und Ideen geben, wie Sie die Integration handhaben können. Kontaktieren Sie uns in jedem Fall, wenn Sie Fragen haben!
243240

244241
<!-- Generated using https://www.tablesgenerator.com/markdown_tables -->
245-
| Integration | Mit Helfern | Mit [`ModelHubMixin`] |
246-
|:---:|:---:|:---:|
247-
| Benutzererfahrung | `model = load_from_hub(...)`<br>`push_to_hub(model, ...)` | `model = MyModel.from_pretrained(...)`<br>`model.push_to_hub(...)` |
248-
| Flexibilität | Sehr flexibel.<br>Sie haben die volle Kontrolle über die Implementierung. | Weniger flexibel.<br>Ihr Framework muss eine Modellklasse haben. |
249-
| Wartung | Mehr Wartung, um Unterstützung für Konfiguration und neue Funktionen hinzuzufügen. Könnte auch das Beheben von Benutzerproblemen erfordern. | Weniger Wartung, da die meisten Interaktionen mit dem Hub in `huggingface_hub` implementiert sind. |
250-
| Dokumentation/Typ-Annotation| Manuell zu schreiben. | Teilweise durch `huggingface_hub` behandelt. |
242+
| Integration | Mit Helfern | Mit [`ModelHubMixin`] |
243+
| :--------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------: |
244+
| Benutzererfahrung | `model = load_from_hub(...)`<br>`push_to_hub(model, ...)` | `model = MyModel.from_pretrained(...)`<br>`model.push_to_hub(...)` |
245+
| Flexibilität | Sehr flexibel.<br>Sie haben die volle Kontrolle über die Implementierung. | Weniger flexibel.<br>Ihr Framework muss eine Modellklasse haben. |
246+
| Wartung | Mehr Wartung, um Unterstützung für Konfiguration und neue Funktionen hinzuzufügen. Könnte auch das Beheben von Benutzerproblemen erfordern. | Weniger Wartung, da die meisten Interaktionen mit dem Hub in `huggingface_hub` implementiert sind. |
247+
| Dokumentation/Typ-Annotation | Manuell zu schreiben. | Teilweise durch `huggingface_hub` behandelt. |

docs/source/en/guides/integrations.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ class PyTorchModelHubMixin(ModelHubMixin):
244244
revision: str,
245245
cache_dir: str,
246246
force_download: bool,
247-
proxies: Optional[dict],
248-
resume_download: bool,
249247
local_files_only: bool,
250248
token: Union[str, bool, None],
251249
map_location: str = "cpu", # additional argument
@@ -265,8 +263,6 @@ class PyTorchModelHubMixin(ModelHubMixin):
265263
revision=revision,
266264
cache_dir=cache_dir,
267265
force_download=force_download,
268-
proxies=proxies,
269-
resume_download=resume_download,
270266
token=token,
271267
local_files_only=local_files_only,
272268
)
@@ -428,11 +424,11 @@ Your framework might have some specificities that you need to address. This guid
428424
ideas on how to handle integration. In any case, feel free to contact us if you have any questions!
429425

430426
<!-- Generated using https://www.tablesgenerator.com/markdown_tables -->
431-
| Integration | Using helpers | Using [`ModelHubMixin`] |
432-
|:---:|:---:|:---:|
433-
| User experience | `model = load_from_hub(...)`<br>`push_to_hub(model, ...)` | `model = MyModel.from_pretrained(...)`<br>`model.push_to_hub(...)` |
434-
| Flexibility | Very flexible.<br>You fully control the implementation. | Less flexible.<br>Your framework must have a model class. |
435-
| Maintenance | More maintenance to add support for configuration, and new features. Might also require fixing issues reported by users. | Less maintenance as most of the interactions with the Hub are implemented in `huggingface_hub`. |
436-
| Documentation / Type annotation | To be written manually. | Partially handled by `huggingface_hub`. |
437-
| Download counter | To be handled manually. | Enabled by default if class has a `config` attribute. |
438-
| Model card | To be handled manually | Generated by default with library_name, tags, etc. |
427+
| Integration | Using helpers | Using [`ModelHubMixin`] |
428+
| :-----------------------------: | :----------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------: |
429+
| User experience | `model = load_from_hub(...)`<br>`push_to_hub(model, ...)` | `model = MyModel.from_pretrained(...)`<br>`model.push_to_hub(...)` |
430+
| Flexibility | Very flexible.<br>You fully control the implementation. | Less flexible.<br>Your framework must have a model class. |
431+
| Maintenance | More maintenance to add support for configuration, and new features. Might also require fixing issues reported by users. | Less maintenance as most of the interactions with the Hub are implemented in `huggingface_hub`. |
432+
| Documentation / Type annotation | To be written manually. | Partially handled by `huggingface_hub`. |
433+
| Download counter | To be handled manually. | Enabled by default if class has a `config` attribute. |
434+
| Model card | To be handled manually | Generated by default with library_name, tags, etc. |

docs/source/en/package_reference/utilities.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -255,20 +255,6 @@ huggingface_hub.utils._validators.HFValidationError: Cannot have -- or .. in rep
255255

256256
>>> my_cool_method(repo_id="other..repo..id")
257257
huggingface_hub.utils._validators.HFValidationError: Cannot have -- or .. in repo_id: 'other..repo..id'.
258-
259-
>>> @validate_hf_hub_args
260-
... def my_cool_auth_method(token: str):
261-
... print(token)
262-
263-
>>> my_cool_auth_method(token="a token")
264-
"a token"
265-
266-
>>> my_cool_auth_method(use_auth_token="a use_auth_token")
267-
"a use_auth_token"
268-
269-
>>> my_cool_auth_method(token="a token", use_auth_token="a use_auth_token")
270-
UserWarning: Both `token` and `use_auth_token` are passed (...). `use_auth_token` value will be ignored.
271-
"a token"
272258
```
273259

274260
#### validate_hf_hub_args
@@ -288,8 +274,8 @@ validated.
288274

289275
[[autodoc]] utils.validate_repo_id
290276

291-
#### smoothly_deprecate_use_auth_token
277+
#### smoothly_deprecate_legacy_arguments
292278

293279
Not exactly a validator, but ran as well.
294280

295-
[[autodoc]] utils.smoothly_deprecate_use_auth_token
281+
[[autodoc]] utils.smoothly_deprecate_legacy_arguments

docs/source/fr/guides/integrations.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ class PyTorchModelHubMixin(ModelHubMixin):
223223
revision: str,
224224
cache_dir: str,
225225
force_download: bool,
226-
proxies: Optional[dict],
227-
resume_download: bool,
228226
local_files_only: bool,
229227
token: Union[str, bool, None],
230228
map_location: str = "cpu", # argument supplémentaire
@@ -242,8 +240,6 @@ class PyTorchModelHubMixin(ModelHubMixin):
242240
revision=revision,
243241
cache_dir=cache_dir,
244242
force_download=force_download,
245-
proxies=proxies,
246-
resume_download=resume_download,
247243
token=token,
248244
local_files_only=local_files_only,
249245
)

docs/source/ko/guides/integrations.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def push_to_hub(model: MyModelClass, repo_name: str) -> None:
8181
- `token`: 개인 리포지토리에서 다운로드하기 위한 토큰
8282
- `revision`: 특정 브랜치에서 다운로드하기 위한 리비전
8383
- `cache_dir`: 특정 디렉터리에 파일을 캐시하기 위한 디렉터리
84-
- `force_download`/`resume_download`/`local_files_only`: 캐시를 재사용할 것인지 여부를 결정하는 매개변수
84+
- `force_download`/`local_files_only`: 캐시를 재사용할 것인지 여부를 결정하는 매개변수
8585
- `proxies`: HTTP 세션 구성
8686

8787
모델을 푸시할 때는 유사한 매개변수가 지원됩니다:
@@ -212,7 +212,6 @@ class PyTorchModelHubMixin(ModelHubMixin):
212212
cache_dir: str,
213213
force_download: bool,
214214
proxies: Optional[dict],
215-
resume_download: bool,
216215
local_files_only: bool,
217216
token: Union[str, bool, None],
218217
map_location: str = "cpu", # 추가 인자
@@ -232,8 +231,6 @@ class PyTorchModelHubMixin(ModelHubMixin):
232231
revision=revision,
233232
cache_dir=cache_dir,
234233
force_download=force_download,
235-
proxies=proxies,
236-
resume_download=resume_download,
237234
token=token,
238235
local_files_only=local_files_only,
239236
)

docs/source/ko/package_reference/utilities.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -199,20 +199,6 @@ huggingface_hub.utils._validators.HFValidationError: Cannot have -- or .. in rep
199199

200200
>>> my_cool_method(repo_id="other..repo..id")
201201
huggingface_hub.utils._validators.HFValidationError: Cannot have -- or .. in repo_id: 'other..repo..id'.
202-
203-
>>> @validate_hf_hub_args
204-
... def my_cool_auth_method(token: str):
205-
... print(token)
206-
207-
>>> my_cool_auth_method(token="a token")
208-
"a token"
209-
210-
>>> my_cool_auth_method(use_auth_token="a use_auth_token")
211-
"a use_auth_token"
212-
213-
>>> my_cool_auth_method(token="a token", use_auth_token="a use_auth_token")
214-
UserWarning: Both `token` and `use_auth_token` are passed (...). `use_auth_token` value will be ignored.
215-
"a token"
216202
```
217203

218204
#### validate_hf_hub_args[[huggingface_hub.utils.validate_hf_hub_args]]
@@ -230,9 +216,3 @@ UserWarning: Both `token` and `use_auth_token` are passed (...). `use_auth_token
230216
#### repo_id[[huggingface_hub.utils.validate_repo_id]]
231217

232218
[[autodoc]] utils.validate_repo_id
233-
234-
#### smoothly_deprecate_use_auth_token[[huggingface_hub.utils.smoothly_deprecate_use_auth_token]]
235-
236-
정확히 검증기는 아니지만, 잘 실행됩니다.
237-
238-
[[autodoc]] utils.smoothly_deprecate_use_auth_token

src/huggingface_hub/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@
217217
"get_safetensors_metadata",
218218
"get_space_runtime",
219219
"get_space_variables",
220-
"get_token_permission",
221220
"get_user_overview",
222221
"get_webhook",
223222
"grant_access",
@@ -278,7 +277,6 @@
278277
"update_collection_metadata",
279278
"update_inference_endpoint",
280279
"update_repo_settings",
281-
"update_repo_visibility",
282280
"update_webhook",
283281
"upload_file",
284282
"upload_folder",
@@ -885,7 +883,6 @@
885883
"get_space_variables",
886884
"get_tf_storage_size",
887885
"get_token",
888-
"get_token_permission",
889886
"get_torch_storage_id",
890887
"get_torch_storage_size",
891888
"get_user_overview",
@@ -977,7 +974,6 @@
977974
"update_collection_metadata",
978975
"update_inference_endpoint",
979976
"update_repo_settings",
980-
"update_repo_visibility",
981977
"update_webhook",
982978
"upload_file",
983979
"upload_folder",
@@ -1247,7 +1243,6 @@ def __dir__():
12471243
get_safetensors_metadata, # noqa: F401
12481244
get_space_runtime, # noqa: F401
12491245
get_space_variables, # noqa: F401
1250-
get_token_permission, # noqa: F401
12511246
get_user_overview, # noqa: F401
12521247
get_webhook, # noqa: F401
12531248
grant_access, # noqa: F401
@@ -1308,7 +1303,6 @@ def __dir__():
13081303
update_collection_metadata, # noqa: F401
13091304
update_inference_endpoint, # noqa: F401
13101305
update_repo_settings, # noqa: F401
1311-
update_repo_visibility, # noqa: F401
13121306
update_webhook, # noqa: F401
13131307
upload_file, # noqa: F401
13141308
upload_folder, # noqa: F401

src/huggingface_hub/_login.py

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
_save_token,
4242
get_stored_tokens,
4343
)
44-
from .utils._deprecation import _deprecate_arguments, _deprecate_positional_args
44+
from .utils._deprecation import _deprecate_positional_args
4545

4646

4747
logger = logging.get_logger(__name__)
@@ -55,18 +55,12 @@
5555
"""
5656

5757

58-
@_deprecate_arguments(
59-
version="1.0",
60-
deprecated_args="write_permission",
61-
custom_message="Fine-grained tokens added complexity to the permissions, making it irrelevant to check if a token has 'write' access.",
62-
)
6358
@_deprecate_positional_args(version="1.0")
6459
def login(
6560
token: Optional[str] = None,
6661
*,
6762
add_to_git_credential: bool = False,
68-
new_session: bool = True,
69-
write_permission: bool = False,
63+
skip_if_logged_in: bool = False,
7064
) -> None:
7165
"""Login the machine to access the Hub.
7266
@@ -102,10 +96,8 @@ def login(
10296
is configured, a warning will be displayed to the user. If `token` is `None`,
10397
the value of `add_to_git_credential` is ignored and will be prompted again
10498
to the end user.
105-
new_session (`bool`, defaults to `True`):
106-
If `True`, will request a token even if one is already saved on the machine.
107-
write_permission (`bool`):
108-
Ignored and deprecated argument.
99+
skip_if_logged_in (`bool`, defaults to `False`):
100+
If `True`, do not prompt for token if user is already logged in.
109101
Raises:
110102
[`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
111103
If an organization token is passed. Only personal account tokens are valid
@@ -125,9 +117,9 @@ def login(
125117
)
126118
_login(token, add_to_git_credential=add_to_git_credential)
127119
elif is_notebook():
128-
notebook_login(new_session=new_session)
120+
notebook_login(skip_if_logged_in=skip_if_logged_in)
129121
else:
130-
interpreter_login(new_session=new_session)
122+
interpreter_login(skip_if_logged_in=skip_if_logged_in)
131123

132124

133125
def logout(token_name: Optional[str] = None) -> None:
@@ -242,13 +234,8 @@ def auth_list() -> None:
242234
###
243235

244236

245-
@_deprecate_arguments(
246-
version="1.0",
247-
deprecated_args="write_permission",
248-
custom_message="Fine-grained tokens added complexity to the permissions, making it irrelevant to check if a token has 'write' access.",
249-
)
250237
@_deprecate_positional_args(version="1.0")
251-
def interpreter_login(*, new_session: bool = True, write_permission: bool = False) -> None:
238+
def interpreter_login(*, skip_if_logged_in: bool = False) -> None:
252239
"""
253240
Displays a prompt to log in to the HF website and store the token.
254241
@@ -259,12 +246,10 @@ def interpreter_login(*, new_session: bool = True, write_permission: bool = Fals
259246
For more details, see [`login`].
260247
261248
Args:
262-
new_session (`bool`, defaults to `True`):
263-
If `True`, will request a token even if one is already saved on the machine.
264-
write_permission (`bool`):
265-
Ignored and deprecated argument.
249+
skip_if_logged_in (`bool`, defaults to `False`):
250+
If `True`, do not prompt for token if user is already logged in.
266251
"""
267-
if not new_session and get_token() is not None:
252+
if not skip_if_logged_in and get_token() is not None:
268253
logger.info("User is already logged in.")
269254
return
270255

@@ -314,13 +299,8 @@ def interpreter_login(*, new_session: bool = True, write_permission: bool = Fals
314299
notebooks. </center>"""
315300

316301

317-
@_deprecate_arguments(
318-
version="1.0",
319-
deprecated_args="write_permission",
320-
custom_message="Fine-grained tokens added complexity to the permissions, making it irrelevant to check if a token has 'write' access.",
321-
)
322302
@_deprecate_positional_args(version="1.0")
323-
def notebook_login(*, new_session: bool = True, write_permission: bool = False) -> None:
303+
def notebook_login(*, skip_if_logged_in: bool = False) -> None:
324304
"""
325305
Displays a widget to log in to the HF website and store the token.
326306
@@ -331,10 +311,8 @@ def notebook_login(*, new_session: bool = True, write_permission: bool = False)
331311
For more details, see [`login`].
332312
333313
Args:
334-
new_session (`bool`, defaults to `True`):
335-
If `True`, will request a token even if one is already saved on the machine.
336-
write_permission (`bool`):
337-
Ignored and deprecated argument.
314+
skip_if_logged_in (`bool`, defaults to `False`):
315+
If `True`, do not prompt for token if user is already logged in.
338316
"""
339317
try:
340318
import ipywidgets.widgets as widgets # type: ignore
@@ -344,7 +322,7 @@ def notebook_login(*, new_session: bool = True, write_permission: bool = False)
344322
"The `notebook_login` function can only be used in a notebook (Jupyter or"
345323
" Colab) and you need the `ipywidgets` module: `pip install ipywidgets`."
346324
)
347-
if not new_session and get_token() is not None:
325+
if not skip_if_logged_in and get_token() is not None:
348326
logger.info("User is already logged in.")
349327
return
350328

src/huggingface_hub/_snapshot_download.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
from pathlib import Path
3-
from typing import Iterable, Literal, Optional, Union
3+
from typing import Iterable, Optional, Union
44

55
import httpx
66
from tqdm.auto import tqdm as base_tqdm
@@ -46,9 +46,6 @@ def snapshot_download(
4646
tqdm_class: Optional[type[base_tqdm]] = None,
4747
headers: Optional[dict[str, str]] = None,
4848
endpoint: Optional[str] = None,
49-
# Deprecated args
50-
local_dir_use_symlinks: Union[bool, Literal["auto"]] = "auto",
51-
resume_download: Optional[bool] = None,
5249
) -> str:
5350
"""Download repo files.
5451
@@ -303,12 +300,10 @@ def _inner_hf_hub_download(repo_file: str):
303300
endpoint=endpoint,
304301
cache_dir=cache_dir,
305302
local_dir=local_dir,
306-
local_dir_use_symlinks=local_dir_use_symlinks,
307303
library_name=library_name,
308304
library_version=library_version,
309305
user_agent=user_agent,
310306
etag_timeout=etag_timeout,
311-
resume_download=resume_download,
312307
force_download=force_download,
313308
token=token,
314309
headers=headers,

0 commit comments

Comments
 (0)