|
14 | 14 |
|
15 | 15 | import logging
|
16 | 16 | import os
|
| 17 | +import warnings |
17 | 18 | from pathlib import Path
|
18 | 19 | from tempfile import TemporaryDirectory, gettempdir
|
19 | 20 | from typing import Dict, Optional, Union
|
@@ -171,7 +172,7 @@ def _from_pretrained(
|
171 | 172 | config: PretrainedConfig,
|
172 | 173 | use_auth_token: Optional[Union[bool, str]] = None,
|
173 | 174 | token: Optional[Union[bool, str]] = None,
|
174 |
| - revision: Optional[Union[str, None]] = None, |
| 175 | + revision: Optional[str] = None, |
175 | 176 | force_download: bool = False,
|
176 | 177 | cache_dir: str = HUGGINGFACE_HUB_CACHE,
|
177 | 178 | file_name: Optional[str] = None,
|
@@ -213,15 +214,13 @@ def _from_pretrained(
|
213 | 214 | Whether or not to apply 8-bit weight quantization.
|
214 | 215 | """
|
215 | 216 | if use_auth_token is not None:
|
216 |
| - logger.warning( |
217 |
| - "The `use_auth_token` argument is deprecated and will be removed soon. " |
218 |
| - "Please use the `token` argument instead." |
| 217 | + warnings.warn( |
| 218 | + "The `use_auth_token` argument is deprecated and will be removed soon. Please use the `token` argument instead.", |
| 219 | + FutureWarning, |
219 | 220 | )
|
220 | 221 | if token is not None:
|
221 | 222 | raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
|
222 |
| - |
223 | 223 | token = use_auth_token
|
224 |
| - use_auth_token = None |
225 | 224 |
|
226 | 225 | model_path = Path(model_id)
|
227 | 226 | default_file_name = ONNX_WEIGHTS_NAME if from_onnx else OV_XML_FILE_NAME
|
@@ -284,15 +283,13 @@ def _cached_file(
|
284 | 283 | local_files_only: bool = False,
|
285 | 284 | ):
|
286 | 285 | if use_auth_token is not None:
|
287 |
| - logger.warning( |
288 |
| - "The `use_auth_token` argument is deprecated and will be removed soon. " |
289 |
| - "Please use the `token` argument instead." |
| 286 | + warnings.warn( |
| 287 | + "The `use_auth_token` argument is deprecated and will be removed soon. Please use the `token` argument instead.", |
| 288 | + FutureWarning, |
290 | 289 | )
|
291 | 290 | if token is not None:
|
292 | 291 | raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
|
293 |
| - |
294 | 292 | token = use_auth_token
|
295 |
| - use_auth_token = None |
296 | 293 |
|
297 | 294 | # locates a file in a local folder and repo, downloads and cache it if necessary.
|
298 | 295 | model_path = Path(model_path)
|
@@ -359,15 +356,13 @@ def _from_transformers(
|
359 | 356 | kwargs will be passed to the model during initialization
|
360 | 357 | """
|
361 | 358 | if use_auth_token is not None:
|
362 |
| - logger.warning( |
363 |
| - "The `use_auth_token` argument is deprecated and will be removed soon. " |
364 |
| - "Please use the `token` argument instead." |
| 359 | + warnings.warn( |
| 360 | + "The `use_auth_token` argument is deprecated and will be removed soon. Please use the `token` argument instead.", |
| 361 | + FutureWarning, |
365 | 362 | )
|
366 | 363 | if token is not None:
|
367 | 364 | raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
|
368 |
| - |
369 | 365 | token = use_auth_token
|
370 |
| - use_auth_token = None |
371 | 366 |
|
372 | 367 | save_dir = TemporaryDirectory()
|
373 | 368 | save_dir_path = Path(save_dir.name)
|
@@ -417,15 +412,13 @@ def _to_load(
|
417 | 412 | **kwargs,
|
418 | 413 | ):
|
419 | 414 | if use_auth_token is not None:
|
420 |
| - logger.warning( |
421 |
| - "The `use_auth_token` argument is deprecated and will be removed soon. " |
422 |
| - "Please use the `token` argument instead." |
| 415 | + warnings.warn( |
| 416 | + "The `use_auth_token` argument is deprecated and will be removed soon. Please use the `token` argument instead.", |
| 417 | + FutureWarning, |
423 | 418 | )
|
424 | 419 | if token is not None:
|
425 | 420 | raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
|
426 |
| - |
427 | 421 | token = use_auth_token
|
428 |
| - use_auth_token = None |
429 | 422 |
|
430 | 423 | save_dir = TemporaryDirectory()
|
431 | 424 | save_dir_path = Path(save_dir.name)
|
|
0 commit comments