hfutils 0.12.2__tar.gz → 0.13.0__tar.gz
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.
- {hfutils-0.12.2/hfutils.egg-info → hfutils-0.13.0}/PKG-INFO +1 -1
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/config/meta.py +1 -1
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/download.py +8 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/duplicate.py +9 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/ils.py +8 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/index.py +8 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/ls.py +8 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/ls_repo.py +11 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/rollback.py +9 -1
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/squash.py +9 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/tree.py +8 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/upload.py +8 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/warmup.py +8 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/whoami.py +11 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/index/fetch.py +2 -2
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/operate/base.py +3 -3
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/repository/clone.py +3 -1
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/__init__.py +1 -0
- hfutils-0.13.0/hfutils/utils/version.py +4 -0
- {hfutils-0.12.2 → hfutils-0.13.0/hfutils.egg-info}/PKG-INFO +1 -1
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils.egg-info/SOURCES.txt +1 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/LICENSE +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/MANIFEST.in +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/README.md +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/__init__.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/__main__.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/archive/__init__.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/archive/base.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/archive/rar.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/archive/sevenz.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/archive/tar.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/archive/zip.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/cache/__init__.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/cache/delete.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/config/__init__.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/__init__.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/base.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/cli.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/clone.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/entry/dispatch.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/index/__init__.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/index/hash.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/index/local_fetch.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/index/make.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/index/validate.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/meta/__init__.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/meta/version.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/operate/__init__.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/operate/download.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/operate/duplicate.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/operate/upload.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/operate/validate.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/operate/warmup.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/repository/__init__.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/repository/base.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/repository/rollback.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/repository/size.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/repository/url.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/archive.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/arrange.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/binary.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/binary_proxy.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/data.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/download.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/ext.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/heap.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/irregular_repo.json +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/logging.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/model.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/number.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/path.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/session.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/temp.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/tqdm_.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/type_.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils/utils/walk.py +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils.egg-info/dependency_links.txt +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils.egg-info/entry_points.txt +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils.egg-info/requires.txt +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/hfutils.egg-info/top_level.txt +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/requirements-7z.txt +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/requirements-build.txt +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/requirements-doc.txt +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/requirements-rar.txt +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/requirements-test.txt +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/requirements-transfer.txt +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/requirements.txt +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/setup.cfg +0 -0
- {hfutils-0.12.2 → hfutils-0.13.0}/setup.py +0 -0
|
@@ -15,12 +15,16 @@ import warnings
|
|
|
15
15
|
from typing import Optional
|
|
16
16
|
|
|
17
17
|
import click
|
|
18
|
-
from huggingface_hub import configure_http_backend
|
|
19
18
|
|
|
20
19
|
from .base import CONTEXT_SETTINGS, command_wrap, ClickErrorException
|
|
21
20
|
from ..operate import download_file_to_file, download_archive_as_directory, download_directory_as_directory
|
|
22
21
|
from ..operate.base import REPO_TYPES, RepoTypeTyping
|
|
23
|
-
from ..utils import get_requests_session
|
|
22
|
+
from ..utils import get_requests_session, HF_IS_VERSION_0_X_X
|
|
23
|
+
|
|
24
|
+
if HF_IS_VERSION_0_X_X:
|
|
25
|
+
from huggingface_hub import configure_http_backend
|
|
26
|
+
else:
|
|
27
|
+
configure_http_backend = None
|
|
24
28
|
|
|
25
29
|
|
|
26
30
|
class NoRemotePathAssignedWithDownload(ClickErrorException):
|
|
@@ -122,7 +126,8 @@ def _add_download_subcommand(cli: click.Group) -> click.Group:
|
|
|
122
126
|
|
|
123
127
|
:raises NoRemotePathAssignedWithDownload: If no remote path in repository is assigned.
|
|
124
128
|
"""
|
|
125
|
-
|
|
129
|
+
if HF_IS_VERSION_0_X_X:
|
|
130
|
+
configure_http_backend(get_requests_session)
|
|
126
131
|
|
|
127
132
|
if tmpdir:
|
|
128
133
|
os.environ['TMPDIR'] = tmpdir
|
|
@@ -6,12 +6,16 @@ It includes commands and utilities to copy repositories while preserving their c
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import click
|
|
9
|
-
from huggingface_hub import configure_http_backend
|
|
10
9
|
|
|
11
10
|
from .base import CONTEXT_SETTINGS, command_wrap
|
|
12
11
|
from ..operate import hf_repo_duplicate
|
|
13
12
|
from ..operate.base import REPO_TYPES, RepoTypeTyping
|
|
14
|
-
from ..utils import get_requests_session
|
|
13
|
+
from ..utils import get_requests_session, HF_IS_VERSION_0_X_X
|
|
14
|
+
|
|
15
|
+
if HF_IS_VERSION_0_X_X:
|
|
16
|
+
from huggingface_hub import configure_http_backend
|
|
17
|
+
else:
|
|
18
|
+
configure_http_backend = None
|
|
15
19
|
|
|
16
20
|
|
|
17
21
|
def _add_duplicate_subcommand(cli: click.Group) -> click.Group:
|
|
@@ -59,7 +63,9 @@ def _add_duplicate_subcommand(cli: click.Group) -> click.Group:
|
|
|
59
63
|
|
|
60
64
|
:raises: Various exceptions from huggingface_hub based on operation status
|
|
61
65
|
"""
|
|
62
|
-
|
|
66
|
+
if HF_IS_VERSION_0_X_X:
|
|
67
|
+
configure_http_backend(get_requests_session)
|
|
68
|
+
|
|
63
69
|
hf_repo_duplicate(
|
|
64
70
|
src_repo_id=src_repo_id,
|
|
65
71
|
dst_repo_id=dst_repo_id,
|
|
@@ -26,14 +26,18 @@ from typing import Optional, Literal
|
|
|
26
26
|
import click
|
|
27
27
|
from hbutils.scale import size_to_bytes_str
|
|
28
28
|
from hbutils.string import plural_word, titleize
|
|
29
|
-
from huggingface_hub import configure_http_backend
|
|
30
29
|
|
|
31
30
|
from .base import CONTEXT_SETTINGS
|
|
32
31
|
from ..index import hf_tar_get_index, hf_tar_validate
|
|
33
32
|
from ..operate.base import REPO_TYPES
|
|
34
|
-
from ..utils import get_requests_session, get_file_type, FileItemType
|
|
33
|
+
from ..utils import get_requests_session, get_file_type, FileItemType, HF_IS_VERSION_0_X_X
|
|
35
34
|
from ..utils.path import RepoTypeTyping, hf_normpath
|
|
36
35
|
|
|
36
|
+
if HF_IS_VERSION_0_X_X:
|
|
37
|
+
from huggingface_hub import configure_http_backend
|
|
38
|
+
else:
|
|
39
|
+
configure_http_backend = None
|
|
40
|
+
|
|
37
41
|
_FT_NAME_MAP = {
|
|
38
42
|
FileItemType.IMAGE: 'image',
|
|
39
43
|
FileItemType.ARCHIVE: 'archive/compressed',
|
|
@@ -133,7 +137,8 @@ def _add_ils_subcommand(cli: click.Group) -> click.Group:
|
|
|
133
137
|
|
|
134
138
|
The function uses click styles to format the output for better readability in the terminal.
|
|
135
139
|
"""
|
|
136
|
-
|
|
140
|
+
if HF_IS_VERSION_0_X_X:
|
|
141
|
+
configure_http_backend(get_requests_session)
|
|
137
142
|
|
|
138
143
|
idx_info = hf_tar_get_index(
|
|
139
144
|
repo_id=repo_id,
|
|
@@ -18,7 +18,6 @@ from typing import Optional
|
|
|
18
18
|
|
|
19
19
|
import click
|
|
20
20
|
from hbutils.string import plural_word
|
|
21
|
-
from huggingface_hub import configure_http_backend
|
|
22
21
|
|
|
23
22
|
from .base import CONTEXT_SETTINGS
|
|
24
23
|
from ..cache import delete_detached_cache
|
|
@@ -26,7 +25,12 @@ from ..index import hf_tar_validate, tar_create_index
|
|
|
26
25
|
from ..operate import get_hf_fs, download_file_to_file, upload_directory_as_directory
|
|
27
26
|
from ..operate.base import REPO_TYPES, RepoTypeTyping, get_hf_client
|
|
28
27
|
from ..utils import tqdm, hf_fs_path, parse_hf_fs_path, TemporaryDirectory, hf_normpath, ColoredFormatter, \
|
|
29
|
-
get_requests_session
|
|
28
|
+
get_requests_session, HF_IS_VERSION_0_X_X
|
|
29
|
+
|
|
30
|
+
if HF_IS_VERSION_0_X_X:
|
|
31
|
+
from huggingface_hub import configure_http_backend
|
|
32
|
+
else:
|
|
33
|
+
configure_http_backend = None
|
|
30
34
|
|
|
31
35
|
|
|
32
36
|
def _add_index_subcommand(cli: click.Group) -> click.Group:
|
|
@@ -90,7 +94,8 @@ def _add_index_subcommand(cli: click.Group) -> click.Group:
|
|
|
90
94
|
This function is typically invoked through the CLI interface, like:
|
|
91
95
|
$ python script.py index -r my_repo -x my_index_repo -t dataset -R main --min_upload_interval 120
|
|
92
96
|
"""
|
|
93
|
-
|
|
97
|
+
if HF_IS_VERSION_0_X_X:
|
|
98
|
+
configure_http_backend(get_requests_session)
|
|
94
99
|
|
|
95
100
|
logger = logging.getLogger()
|
|
96
101
|
logger.setLevel(logging.INFO)
|
|
@@ -4,12 +4,16 @@ from typing import Union, List
|
|
|
4
4
|
|
|
5
5
|
import click
|
|
6
6
|
import tzlocal
|
|
7
|
-
from huggingface_hub import configure_http_backend
|
|
8
7
|
from huggingface_hub.hf_api import RepoFolder, RepoFile
|
|
9
8
|
|
|
10
9
|
from .base import CONTEXT_SETTINGS
|
|
11
10
|
from ..operate.base import REPO_TYPES, get_hf_client
|
|
12
|
-
from ..utils import get_requests_session, FileItemType, get_file_type
|
|
11
|
+
from ..utils import get_requests_session, FileItemType, get_file_type, HF_IS_VERSION_0_X_X
|
|
12
|
+
|
|
13
|
+
if HF_IS_VERSION_0_X_X:
|
|
14
|
+
from huggingface_hub import configure_http_backend
|
|
15
|
+
else:
|
|
16
|
+
configure_http_backend = None
|
|
13
17
|
|
|
14
18
|
|
|
15
19
|
class ListItem:
|
|
@@ -73,7 +77,8 @@ def _add_ls_subcommand(cli: click.Group) -> click.Group:
|
|
|
73
77
|
:param show_detailed: Flag to indicate whether to show detailed file information.
|
|
74
78
|
:type show_detailed: bool
|
|
75
79
|
"""
|
|
76
|
-
|
|
80
|
+
if HF_IS_VERSION_0_X_X:
|
|
81
|
+
configure_http_backend(get_requests_session)
|
|
77
82
|
|
|
78
83
|
hf_client = get_hf_client()
|
|
79
84
|
items: List[ListItem] = []
|
|
@@ -2,12 +2,16 @@ import fnmatch
|
|
|
2
2
|
from typing import Optional
|
|
3
3
|
|
|
4
4
|
import click
|
|
5
|
-
from huggingface_hub import configure_http_backend
|
|
6
5
|
from huggingface_hub.utils import LocalTokenNotFoundError
|
|
7
6
|
|
|
8
7
|
from .base import CONTEXT_SETTINGS, ClickErrorException
|
|
9
8
|
from ..operate.base import REPO_TYPES, get_hf_client
|
|
10
|
-
from ..utils import get_requests_session
|
|
9
|
+
from ..utils import get_requests_session, HF_IS_VERSION_0_X_X
|
|
10
|
+
|
|
11
|
+
if HF_IS_VERSION_0_X_X:
|
|
12
|
+
from huggingface_hub import configure_http_backend
|
|
13
|
+
else:
|
|
14
|
+
configure_http_backend = None
|
|
11
15
|
|
|
12
16
|
|
|
13
17
|
class NoLocalAuthentication(ClickErrorException):
|
|
@@ -48,11 +52,15 @@ def _add_ls_repo_subcommand(cli: click.Group) -> click.Group:
|
|
|
48
52
|
:param pattern: Pattern of the repository names.
|
|
49
53
|
:type pattern: str
|
|
50
54
|
"""
|
|
51
|
-
|
|
55
|
+
if HF_IS_VERSION_0_X_X:
|
|
56
|
+
configure_http_backend(get_requests_session)
|
|
52
57
|
|
|
53
58
|
hf_client = get_hf_client()
|
|
54
59
|
if not author:
|
|
55
60
|
try:
|
|
61
|
+
if not hf_client.token:
|
|
62
|
+
raise LocalTokenNotFoundError
|
|
63
|
+
|
|
56
64
|
info = hf_client.whoami()
|
|
57
65
|
author = author or info['name']
|
|
58
66
|
except LocalTokenNotFoundError:
|
|
@@ -5,7 +5,12 @@ import click
|
|
|
5
5
|
from .base import CONTEXT_SETTINGS
|
|
6
6
|
from ..operate.base import REPO_TYPES, RepoTypeTyping
|
|
7
7
|
from ..repository import hf_hub_rollback
|
|
8
|
-
from ..utils import ColoredFormatter
|
|
8
|
+
from ..utils import ColoredFormatter, HF_IS_VERSION_0_X_X, get_requests_session
|
|
9
|
+
|
|
10
|
+
if HF_IS_VERSION_0_X_X:
|
|
11
|
+
from huggingface_hub import configure_http_backend
|
|
12
|
+
else:
|
|
13
|
+
configure_http_backend = None
|
|
9
14
|
|
|
10
15
|
|
|
11
16
|
def _add_rollback_subcommand(cli: click.Group) -> click.Group:
|
|
@@ -43,6 +48,9 @@ def _add_rollback_subcommand(cli: click.Group) -> click.Group:
|
|
|
43
48
|
:param revision: The revision of the repository to rollback.
|
|
44
49
|
:param rollback_to_commit_id: The commit ID to rollback to.
|
|
45
50
|
"""
|
|
51
|
+
if HF_IS_VERSION_0_X_X:
|
|
52
|
+
configure_http_backend(get_requests_session)
|
|
53
|
+
|
|
46
54
|
# Set up logging
|
|
47
55
|
logger = logging.getLogger()
|
|
48
56
|
logger.setLevel(logging.INFO)
|
|
@@ -8,11 +8,15 @@ The module utilizes the Click library for creating the CLI and integrates with t
|
|
|
8
8
|
from typing import Optional
|
|
9
9
|
|
|
10
10
|
import click
|
|
11
|
-
from huggingface_hub import configure_http_backend
|
|
12
11
|
|
|
13
12
|
from .base import CONTEXT_SETTINGS, command_wrap
|
|
14
13
|
from ..operate.base import REPO_TYPES, RepoTypeTyping, get_hf_client
|
|
15
|
-
from ..utils import get_requests_session, hf_fs_path
|
|
14
|
+
from ..utils import get_requests_session, hf_fs_path, HF_IS_VERSION_0_X_X
|
|
15
|
+
|
|
16
|
+
if HF_IS_VERSION_0_X_X:
|
|
17
|
+
from huggingface_hub import configure_http_backend
|
|
18
|
+
else:
|
|
19
|
+
configure_http_backend = None
|
|
16
20
|
|
|
17
21
|
|
|
18
22
|
def _add_squash_subcommand(cli: click.Group) -> click.Group:
|
|
@@ -59,7 +63,9 @@ def _add_squash_subcommand(cli: click.Group) -> click.Group:
|
|
|
59
63
|
:param message: Optional commit message for the squash operation.
|
|
60
64
|
:type message: Optional[str]
|
|
61
65
|
"""
|
|
62
|
-
|
|
66
|
+
if HF_IS_VERSION_0_X_X:
|
|
67
|
+
configure_http_backend(get_requests_session)
|
|
68
|
+
|
|
63
69
|
hf_client = get_hf_client()
|
|
64
70
|
hf_client.super_squash_history(
|
|
65
71
|
repo_id=repo_id,
|
|
@@ -22,13 +22,17 @@ from typing import Optional, List, Union
|
|
|
22
22
|
|
|
23
23
|
import click
|
|
24
24
|
from hbutils.string import format_tree
|
|
25
|
-
from huggingface_hub import configure_http_backend
|
|
26
25
|
from huggingface_hub.hf_api import RepoFile
|
|
27
26
|
from natsort import natsorted
|
|
28
27
|
|
|
29
28
|
from .base import CONTEXT_SETTINGS
|
|
30
29
|
from ..operate.base import REPO_TYPES, list_files_in_repository, RepoTypeTyping, get_hf_client
|
|
31
|
-
from ..utils import get_requests_session, hf_normpath, get_file_type, hf_fs_path, FileItemType
|
|
30
|
+
from ..utils import get_requests_session, hf_normpath, get_file_type, hf_fs_path, FileItemType, HF_IS_VERSION_0_X_X
|
|
31
|
+
|
|
32
|
+
if HF_IS_VERSION_0_X_X:
|
|
33
|
+
from huggingface_hub import configure_http_backend
|
|
34
|
+
else:
|
|
35
|
+
configure_http_backend = None
|
|
32
36
|
|
|
33
37
|
|
|
34
38
|
@dataclasses.dataclass
|
|
@@ -221,7 +225,8 @@ def _add_tree_subcommand(cli: click.Group) -> click.Group:
|
|
|
221
225
|
:param show_all: Whether to show hidden files.
|
|
222
226
|
:type show_all: bool
|
|
223
227
|
"""
|
|
224
|
-
|
|
228
|
+
if HF_IS_VERSION_0_X_X:
|
|
229
|
+
configure_http_backend(get_requests_session)
|
|
225
230
|
|
|
226
231
|
_tree = _get_tree(
|
|
227
232
|
repo_id=repo_id,
|
|
@@ -15,12 +15,16 @@ import warnings
|
|
|
15
15
|
from typing import Optional
|
|
16
16
|
|
|
17
17
|
import click
|
|
18
|
-
from huggingface_hub import configure_http_backend
|
|
19
18
|
|
|
20
19
|
from .base import CONTEXT_SETTINGS, command_wrap, ClickErrorException
|
|
21
20
|
from ..operate import upload_file_to_file, upload_directory_as_archive, upload_directory_as_directory
|
|
22
21
|
from ..operate.base import REPO_TYPES, RepoTypeTyping, get_hf_client
|
|
23
|
-
from ..utils import get_requests_session
|
|
22
|
+
from ..utils import get_requests_session, HF_IS_VERSION_0_X_X
|
|
23
|
+
|
|
24
|
+
if HF_IS_VERSION_0_X_X:
|
|
25
|
+
from huggingface_hub import configure_http_backend
|
|
26
|
+
else:
|
|
27
|
+
configure_http_backend = None
|
|
24
28
|
|
|
25
29
|
|
|
26
30
|
class NoRemotePathAssignedWithUpload(ClickErrorException):
|
|
@@ -123,7 +127,8 @@ def _add_upload_subcommand(cli: click.Group) -> click.Group:
|
|
|
123
127
|
:raises NoRemotePathAssignedWithUpload: If no upload mode is specified.
|
|
124
128
|
:raises ValueError: If conflicting visibility settings are provided.
|
|
125
129
|
"""
|
|
126
|
-
|
|
130
|
+
if HF_IS_VERSION_0_X_X:
|
|
131
|
+
configure_http_backend(get_requests_session)
|
|
127
132
|
|
|
128
133
|
if not file_in_repo and not archive_in_repo and not dir_in_repo:
|
|
129
134
|
raise NoRemotePathAssignedWithUpload('No remote path in repository assigned.\n'
|
|
@@ -14,12 +14,16 @@ import warnings
|
|
|
14
14
|
from typing import Optional
|
|
15
15
|
|
|
16
16
|
import click
|
|
17
|
-
from huggingface_hub import configure_http_backend
|
|
18
17
|
|
|
19
18
|
from .base import CONTEXT_SETTINGS, command_wrap, ClickErrorException
|
|
20
19
|
from ..operate import hf_warmup_file, hf_warmup_directory
|
|
21
20
|
from ..operate.base import REPO_TYPES, RepoTypeTyping
|
|
22
|
-
from ..utils import get_requests_session
|
|
21
|
+
from ..utils import get_requests_session, HF_IS_VERSION_0_X_X
|
|
22
|
+
|
|
23
|
+
if HF_IS_VERSION_0_X_X:
|
|
24
|
+
from huggingface_hub import configure_http_backend
|
|
25
|
+
else:
|
|
26
|
+
configure_http_backend = None
|
|
23
27
|
|
|
24
28
|
|
|
25
29
|
class NoRemotePathAssignedWithWarmup(ClickErrorException):
|
|
@@ -100,7 +104,8 @@ def _add_warmup_subcommand(cli: click.Group) -> click.Group:
|
|
|
100
104
|
|
|
101
105
|
:raises NoRemotePathAssignedWithWarmup: If no remote path in repository is assigned.
|
|
102
106
|
"""
|
|
103
|
-
|
|
107
|
+
if HF_IS_VERSION_0_X_X:
|
|
108
|
+
configure_http_backend(get_requests_session)
|
|
104
109
|
|
|
105
110
|
if not file_in_repo and not dir_in_repo:
|
|
106
111
|
raise NoRemotePathAssignedWithWarmup('No remote path in repository assigned.\n'
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import click
|
|
2
2
|
from hbutils.string import plural_word
|
|
3
|
-
from huggingface_hub import configure_http_backend
|
|
4
3
|
from huggingface_hub.utils import LocalTokenNotFoundError
|
|
5
4
|
|
|
6
5
|
from .base import CONTEXT_SETTINGS
|
|
7
6
|
from ..meta import hf_site_info
|
|
8
7
|
from ..operate.base import get_hf_client
|
|
9
|
-
from ..utils import get_requests_session
|
|
8
|
+
from ..utils import get_requests_session, HF_IS_VERSION_0_X_X
|
|
9
|
+
|
|
10
|
+
if HF_IS_VERSION_0_X_X:
|
|
11
|
+
from huggingface_hub import configure_http_backend
|
|
12
|
+
else:
|
|
13
|
+
configure_http_backend = None
|
|
10
14
|
|
|
11
15
|
|
|
12
16
|
def _add_whoami_subcommand(cli: click.Group) -> click.Group:
|
|
@@ -31,10 +35,14 @@ def _add_whoami_subcommand(cli: click.Group) -> click.Group:
|
|
|
31
35
|
This function retrieves the current user's identification from the Hugging Face Hub API and displays it.
|
|
32
36
|
|
|
33
37
|
"""
|
|
34
|
-
|
|
38
|
+
if HF_IS_VERSION_0_X_X:
|
|
39
|
+
configure_http_backend(get_requests_session)
|
|
35
40
|
|
|
36
41
|
hf_client = get_hf_client()
|
|
37
42
|
try:
|
|
43
|
+
if not hf_client.token:
|
|
44
|
+
raise LocalTokenNotFoundError
|
|
45
|
+
|
|
38
46
|
info = hf_client.whoami()
|
|
39
47
|
username = info['name']
|
|
40
48
|
click.echo(f'Hi, {click.style(f"@{username}", fg="green", bold=True)} '
|
|
@@ -17,7 +17,7 @@ from tqdm import tqdm
|
|
|
17
17
|
|
|
18
18
|
from .hash import _f_sha256
|
|
19
19
|
from ..operate.base import RepoTypeTyping, get_hf_client
|
|
20
|
-
from ..utils import hf_normpath, BinaryProxyIO
|
|
20
|
+
from ..utils import hf_normpath, BinaryProxyIO, HF_IS_VERSION_0_X_X
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class ArchiveStandaloneFileIncompleteDownload(Exception):
|
|
@@ -699,7 +699,7 @@ def _hf_tar_file_info_write(repo_id: str, archive_in_repo: str, file_in_archive:
|
|
|
699
699
|
|
|
700
700
|
|
|
701
701
|
def _check_hf_transfer_conflict():
|
|
702
|
-
if constants.HF_HUB_ENABLE_HF_TRANSFER and vpip('huggingface_hub') < '0.31':
|
|
702
|
+
if HF_IS_VERSION_0_X_X and constants.HF_HUB_ENABLE_HF_TRANSFER and vpip('huggingface_hub') < '0.31':
|
|
703
703
|
warnings.warn(f"You are trying to use huggingface_hub=={huggingface_hub.__version__} "
|
|
704
704
|
f"with hf_transfer enabled at the same time, this may cause unexpected error "
|
|
705
705
|
f"(see: https://github.com/huggingface/huggingface_hub/issues/2978 for more details). "
|
|
@@ -70,7 +70,7 @@ def get_hf_client(hf_token: Optional[str] = None) -> HfApi:
|
|
|
70
70
|
>>> # Use client to interact with Hugging Face API
|
|
71
71
|
>>> models = client.list_models(limit=5)
|
|
72
72
|
"""
|
|
73
|
-
return HfApi(token=hf_token or _get_hf_token())
|
|
73
|
+
return HfApi(token=hf_token or _get_hf_token() or None)
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
@lru_cache()
|
|
@@ -96,7 +96,7 @@ def get_hf_fs(hf_token: Optional[str] = None) -> HfFileSystem:
|
|
|
96
96
|
"""
|
|
97
97
|
# use_listings_cache=False is necessary
|
|
98
98
|
# or the result of glob and ls will be cached, the unittest will down
|
|
99
|
-
return HfFileSystem(token=hf_token or _get_hf_token(), use_listings_cache=False)
|
|
99
|
+
return HfFileSystem(token=hf_token or _get_hf_token() or None, use_listings_cache=False)
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
def _fn_path_pattern_norm(pattern: Union[List[str], str]) -> Union[List[str], str]:
|
|
@@ -436,4 +436,4 @@ def list_files_in_repository(
|
|
|
436
436
|
raise_when_base_not_exist=raise_when_base_not_exist,
|
|
437
437
|
hf_token=hf_token,
|
|
438
438
|
)
|
|
439
|
-
]
|
|
439
|
+
]
|
|
@@ -54,6 +54,8 @@ def hf_hub_clone(repo_id: str, dst_dir: str,
|
|
|
54
54
|
_git = _check_git(requires_lfs=not no_lfs)
|
|
55
55
|
hf_client = get_hf_client(hf_token)
|
|
56
56
|
try:
|
|
57
|
+
if not hf_client.token:
|
|
58
|
+
raise LocalTokenNotFoundError
|
|
57
59
|
username = hf_client.whoami()['name']
|
|
58
60
|
except LocalTokenNotFoundError:
|
|
59
61
|
username = None # anonymous mode
|
|
@@ -63,7 +65,7 @@ def hf_hub_clone(repo_id: str, dst_dir: str,
|
|
|
63
65
|
repo_type=repo_type,
|
|
64
66
|
endpoint=endpoint,
|
|
65
67
|
))
|
|
66
|
-
if username:
|
|
68
|
+
if username and hf_client.token:
|
|
67
69
|
clone_url = clone_url.with_username(username).with_password(hf_client.token)
|
|
68
70
|
clone_url = str(clone_url)
|
|
69
71
|
|
|
@@ -13,4 +13,5 @@ from .session import TimeoutHTTPAdapter, get_requests_session, get_random_ua
|
|
|
13
13
|
from .temp import TemporaryDirectory
|
|
14
14
|
from .tqdm_ import tqdm
|
|
15
15
|
from .type_ import FileItemType, get_file_type
|
|
16
|
+
from .version import HF_IS_VERSION_0_X_X, HF_IS_VERSION_1_X_X
|
|
16
17
|
from .walk import walk_files
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|