huggingface-hub 0.20.2__py3-none-any.whl → 0.20.3__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.
@@ -46,7 +46,7 @@ import sys
46
46
  from typing import TYPE_CHECKING
47
47
 
48
48
 
49
- __version__ = "0.20.2"
49
+ __version__ = "0.20.3"
50
50
 
51
51
  # Alphabetical order of definitions is ensured in tests
52
52
  # WARNING: any comment added in this dictionary definition will be lost when
@@ -13,12 +13,12 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  """Contain helper class to retrieve/store token from/to local cache."""
16
- import os
17
16
  import warnings
18
17
  from pathlib import Path
19
18
  from typing import Optional
20
19
 
21
20
  from .. import constants
21
+ from ._token import get_token
22
22
 
23
23
 
24
24
  class HfFolder:
@@ -50,12 +50,8 @@ class HfFolder:
50
50
  """
51
51
  Get token or None if not existent.
52
52
 
53
- Note that a token can be also provided using the `HF_TOKEN` environment variable.
54
-
55
- Token is saved in the huggingface home folder. You can configure it by setting
56
- the `HF_HOME` environment variable. Previous location was `~/.huggingface/token`.
57
- If token is found in old location but not in new location, it is copied there first.
58
- For more details, see https://github.com/huggingface/huggingface_hub/issues/1232.
53
+ This method is deprecated in favor of [`huggingface_hub.get_token`] but is kept for backward compatibility.
54
+ Its behavior is the same as [`huggingface_hub.get_token`].
59
55
 
60
56
  Returns:
61
57
  `str` or `None`: The token, `None` if it doesn't exist.
@@ -66,22 +62,7 @@ class HfFolder:
66
62
  except Exception: # if not possible (e.g. PermissionError), do not raise
67
63
  pass
68
64
 
69
- # 1. Is it set by environment variable ?
70
- token: Optional[str] = os.environ.get("HF_TOKEN")
71
- if token is None: # Ensure backward compatibility but doesn't have priority
72
- token = os.environ.get("HUGGING_FACE_HUB_TOKEN")
73
- if token is not None:
74
- token = token.replace("\r", "").replace("\n", "").strip()
75
- if token != "":
76
- return token
77
-
78
- # 2. Is it set in token path ?
79
- try:
80
- token = cls.path_token.read_text()
81
- token = token.replace("\r", "").replace("\n", "").strip()
82
- return token
83
- except FileNotFoundError:
84
- return None
65
+ return get_token()
85
66
 
86
67
  # TODO: deprecate when adapted in transformers/datasets/gradio
87
68
  # @_deprecate_method(version="1.0", message="Use `huggingface_hub.logout` instead.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: huggingface-hub
3
- Version: 0.20.2
3
+ Version: 0.20.3
4
4
  Summary: Client library to download and publish models, datasets and other repos on the huggingface.co hub
5
5
  Home-page: https://github.com/huggingface/huggingface_hub
6
6
  Author: Hugging Face, Inc.
@@ -1,4 +1,4 @@
1
- huggingface_hub/__init__.py,sha256=ixK6-0G7PFdH1mCZ9c5g8ZuYHsxSpVo8TTuA7O0mun8,20809
1
+ huggingface_hub/__init__.py,sha256=uaa0OgkPFs3mbcVaOYGzb-CCIm_56yQY90UKWTGwGiM,20809
2
2
  huggingface_hub/_commit_api.py,sha256=LWwx0PmTHzh-gwO6-cl0GWTrSnzCy8tfZ8DDCxnfb7Y,27795
3
3
  huggingface_hub/_commit_scheduler.py,sha256=FgfjYv3E0oK3iBxDdy45Y7t78FWkmjnBR4dRd5aZviU,13653
4
4
  huggingface_hub/_inference_endpoints.py,sha256=FW36nfm9UNNnc6L6hyL2KLiItglPGcQuYJ6DA2w4Gp4,14929
@@ -52,7 +52,7 @@ huggingface_hub/utils/_experimental.py,sha256=rBx4gV2NU1dT_OfeRzsCmCWyIF4Wxcf0Pd
52
52
  huggingface_hub/utils/_fixes.py,sha256=wFvfTYj62Il2OwkQB_Qp0xONG6SARQ5oEkT3_FhB4rc,2437
53
53
  huggingface_hub/utils/_git_credential.py,sha256=NMfMmuqdub_QX3T2d32Jhpf3RBnf2eh4VnDhHoqyZRA,4595
54
54
  huggingface_hub/utils/_headers.py,sha256=wz0kPrpu9PHpeCIJAq8MBiHuR2HbNWGukd0QgWS6lWo,9344
55
- huggingface_hub/utils/_hf_folder.py,sha256=9FlyCbiMP-PuyR4MP8sh5wiYbphkCjP18sCma0P7XDw,4488
55
+ huggingface_hub/utils/_hf_folder.py,sha256=5fxKNZ8y12szgmLhxZWJsjK_zx-wopMtVoFPCuwI1VI,3612
56
56
  huggingface_hub/utils/_http.py,sha256=qJ9wlsv-SU9L4Epr8FLHznY3COIcOrUUmGMjJXfrQvI,12889
57
57
  huggingface_hub/utils/_pagination.py,sha256=VfpmMLyNCRo24fw0o_yWysMK69d9M6sSg2-nWtuypO4,1840
58
58
  huggingface_hub/utils/_paths.py,sha256=nUaxXN-R2EcWfHE8ivFWfHqEKMIvXEdUeCGDC_QHMqc,4397
@@ -68,9 +68,9 @@ huggingface_hub/utils/insecure_hashlib.py,sha256=OjxlvtSQHpbLp9PWSrXBDJ0wHjxCBU-
68
68
  huggingface_hub/utils/logging.py,sha256=mARNwc5gY6apMQ9IM5zymn-RsYnFbYW3b0HDMYXmBS0,4729
69
69
  huggingface_hub/utils/sha.py,sha256=IVi7CfBthfu-ExLduY_CQltTy-tVGTbrvURCTOWKcLA,901
70
70
  huggingface_hub/utils/tqdm.py,sha256=zBWgoxxwHooOceABVREVqSNpJGcMpaByKFVDU8VbuUQ,6334
71
- huggingface_hub-0.20.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
72
- huggingface_hub-0.20.2.dist-info/METADATA,sha256=D1vK91f8NEHzMiWLSl7_TQs6rZ6cr0E4ecRkkFB0lMM,12930
73
- huggingface_hub-0.20.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
74
- huggingface_hub-0.20.2.dist-info/entry_points.txt,sha256=Y3Z2L02rBG7va_iE6RPXolIgwOdwUFONyRN3kXMxZ0g,131
75
- huggingface_hub-0.20.2.dist-info/top_level.txt,sha256=8KzlQJAY4miUvjAssOAJodqKOw3harNzuiwGQ9qLSSk,16
76
- huggingface_hub-0.20.2.dist-info/RECORD,,
71
+ huggingface_hub-0.20.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
72
+ huggingface_hub-0.20.3.dist-info/METADATA,sha256=QwoMs3u0SUk5JBYWVZXnvNFKSSiIOF34zHM9_QYkUiQ,12930
73
+ huggingface_hub-0.20.3.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
74
+ huggingface_hub-0.20.3.dist-info/entry_points.txt,sha256=Y3Z2L02rBG7va_iE6RPXolIgwOdwUFONyRN3kXMxZ0g,131
75
+ huggingface_hub-0.20.3.dist-info/top_level.txt,sha256=8KzlQJAY4miUvjAssOAJodqKOw3harNzuiwGQ9qLSSk,16
76
+ huggingface_hub-0.20.3.dist-info/RECORD,,