hfutils 0.2.4__tar.gz → 0.2.6__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.2.4/hfutils.egg-info → hfutils-0.2.6}/PKG-INFO +23 -22
- hfutils-0.2.6/hfutils/__main__.py +4 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/config/meta.py +1 -1
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/entry/cli.py +2 -0
- hfutils-0.2.6/hfutils/entry/ls_repo.py +74 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/operate/base.py +7 -2
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/utils/__init__.py +1 -1
- hfutils-0.2.6/hfutils/utils/irregular_repo.json +662 -0
- hfutils-0.2.6/hfutils/utils/path.py +144 -0
- {hfutils-0.2.4 → hfutils-0.2.6/hfutils.egg-info}/PKG-INFO +23 -22
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils.egg-info/SOURCES.txt +3 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils.egg-info/requires.txt +1 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/requirements.txt +1 -0
- hfutils-0.2.4/hfutils/utils/path.py +0 -5
- {hfutils-0.2.4 → hfutils-0.2.6}/LICENSE +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/MANIFEST.in +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/README.md +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/__init__.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/archive/__init__.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/archive/base.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/archive/rar.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/archive/sevenz.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/archive/tar.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/archive/zip.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/config/__init__.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/entry/__init__.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/entry/base.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/entry/dispatch.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/entry/download.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/entry/ls.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/entry/upload.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/entry/whoami.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/index/__init__.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/index/fetch.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/index/hash.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/index/make.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/index/validate.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/operate/__init__.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/operate/download.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/operate/upload.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/operate/validate.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/utils/binary.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/utils/download.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/utils/temp.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/utils/tqdm_.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils/utils/walk.py +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils.egg-info/dependency_links.txt +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils.egg-info/entry_points.txt +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/hfutils.egg-info/top_level.txt +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/requirements-7z.txt +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/requirements-build.txt +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/requirements-doc.txt +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/requirements-rar.txt +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/requirements-test.txt +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/requirements-transfer.txt +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/setup.cfg +0 -0
- {hfutils-0.2.4 → hfutils-0.2.6}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hfutils
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: Useful utilities for huggingface
|
|
5
5
|
Home-page: https://github.com/deepghs/hfutils
|
|
6
6
|
Author: narugo1992
|
|
@@ -26,25 +26,9 @@ Requires-Dist: tqdm
|
|
|
26
26
|
Requires-Dist: requests
|
|
27
27
|
Requires-Dist: click>=7
|
|
28
28
|
Requires-Dist: tzlocal
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Requires-Dist: coverage>=5; extra == "test"
|
|
33
|
-
Requires-Dist: mock>=4.0.3; extra == "test"
|
|
34
|
-
Requires-Dist: flake8~=3.5; extra == "test"
|
|
35
|
-
Requires-Dist: testfixtures>=6.18.5; extra == "test"
|
|
36
|
-
Requires-Dist: pytest~=6.2.5; extra == "test"
|
|
37
|
-
Requires-Dist: pytest-cov~=3.0.0; extra == "test"
|
|
38
|
-
Requires-Dist: pytest-mock~=3.6.1; extra == "test"
|
|
39
|
-
Requires-Dist: pytest-xdist>=1.34.0; extra == "test"
|
|
40
|
-
Requires-Dist: pytest-rerunfailures~=10.2; extra == "test"
|
|
41
|
-
Requires-Dist: pytest-timeout~=2.0.2; extra == "test"
|
|
42
|
-
Requires-Dist: pytest-benchmark~=3.4.0; extra == "test"
|
|
43
|
-
Requires-Dist: easydict<2,>=1.7; extra == "test"
|
|
44
|
-
Requires-Dist: testtools>=2; extra == "test"
|
|
45
|
-
Requires-Dist: where>=1.0.2; extra == "test"
|
|
46
|
-
Requires-Dist: responses>=0.20.0; extra == "test"
|
|
47
|
-
Requires-Dist: natsort; extra == "test"
|
|
29
|
+
Requires-Dist: natsort
|
|
30
|
+
Provides-Extra: build
|
|
31
|
+
Requires-Dist: pyinstaller<5,>=4.7; extra == "build"
|
|
48
32
|
Provides-Extra: doc
|
|
49
33
|
Requires-Dist: Jinja2>=3.0.0; extra == "doc"
|
|
50
34
|
Requires-Dist: sphinx>=3.2.0; extra == "doc"
|
|
@@ -65,12 +49,29 @@ Requires-Dist: ipykernel>=6.15; extra == "doc"
|
|
|
65
49
|
Requires-Dist: py-cpuinfo>=8.0.0; extra == "doc"
|
|
66
50
|
Requires-Dist: click>=7.0.0; extra == "doc"
|
|
67
51
|
Requires-Dist: pandas; extra == "doc"
|
|
68
|
-
Provides-Extra: build
|
|
69
|
-
Requires-Dist: pyinstaller<5,>=4.7; extra == "build"
|
|
70
52
|
Provides-Extra: 7z
|
|
71
53
|
Requires-Dist: py7zr; extra == "7z"
|
|
72
54
|
Provides-Extra: transfer
|
|
73
55
|
Requires-Dist: hf-transfer; extra == "transfer"
|
|
56
|
+
Provides-Extra: test
|
|
57
|
+
Requires-Dist: coverage>=5; extra == "test"
|
|
58
|
+
Requires-Dist: mock>=4.0.3; extra == "test"
|
|
59
|
+
Requires-Dist: flake8~=3.5; extra == "test"
|
|
60
|
+
Requires-Dist: testfixtures>=6.18.5; extra == "test"
|
|
61
|
+
Requires-Dist: pytest~=6.2.5; extra == "test"
|
|
62
|
+
Requires-Dist: pytest-cov~=3.0.0; extra == "test"
|
|
63
|
+
Requires-Dist: pytest-mock~=3.6.1; extra == "test"
|
|
64
|
+
Requires-Dist: pytest-xdist>=1.34.0; extra == "test"
|
|
65
|
+
Requires-Dist: pytest-rerunfailures~=10.2; extra == "test"
|
|
66
|
+
Requires-Dist: pytest-timeout~=2.0.2; extra == "test"
|
|
67
|
+
Requires-Dist: pytest-benchmark~=3.4.0; extra == "test"
|
|
68
|
+
Requires-Dist: easydict<2,>=1.7; extra == "test"
|
|
69
|
+
Requires-Dist: testtools>=2; extra == "test"
|
|
70
|
+
Requires-Dist: where>=1.0.2; extra == "test"
|
|
71
|
+
Requires-Dist: responses>=0.20.0; extra == "test"
|
|
72
|
+
Requires-Dist: natsort; extra == "test"
|
|
73
|
+
Provides-Extra: rar
|
|
74
|
+
Requires-Dist: rarfile; extra == "rar"
|
|
74
75
|
|
|
75
76
|
# hfutils
|
|
76
77
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from .dispatch import hfutilcli
|
|
2
2
|
from .download import _add_download_subcommand
|
|
3
3
|
from .ls import _add_ls_subcommand
|
|
4
|
+
from .ls_repo import _add_ls_repo_subcommand
|
|
4
5
|
from .upload import _add_upload_subcommand
|
|
5
6
|
from .whoami import _add_whoami_subcommand
|
|
6
7
|
|
|
@@ -9,6 +10,7 @@ _DECORATORS = [
|
|
|
9
10
|
_add_upload_subcommand,
|
|
10
11
|
_add_ls_subcommand,
|
|
11
12
|
_add_whoami_subcommand,
|
|
13
|
+
_add_ls_repo_subcommand,
|
|
12
14
|
]
|
|
13
15
|
|
|
14
16
|
cli = hfutilcli
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import fnmatch
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
import click
|
|
5
|
+
from huggingface_hub.utils import LocalTokenNotFoundError
|
|
6
|
+
|
|
7
|
+
from .base import CONTEXT_SETTINGS, ClickErrorException
|
|
8
|
+
from ..operate.base import REPO_TYPES, get_hf_client
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class NoLocalAuthentication(ClickErrorException):
|
|
12
|
+
"""
|
|
13
|
+
Exception raised when there is no local authentication token.
|
|
14
|
+
"""
|
|
15
|
+
exit_code = 0x31
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _add_ls_repo_subcommand(cli: click.Group) -> click.Group:
|
|
19
|
+
"""
|
|
20
|
+
Add the ls_repo subcommand to the CLI.
|
|
21
|
+
|
|
22
|
+
:param cli: The click Group object.
|
|
23
|
+
:type cli: click.Group
|
|
24
|
+
|
|
25
|
+
:return: The updated click Group object.
|
|
26
|
+
:rtype: click.Group
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
@cli.command('ls_repo', help='List repositories from HuggingFace.\n\n'
|
|
30
|
+
'Set environment $HF_TOKEN to use your own access token.',
|
|
31
|
+
context_settings=CONTEXT_SETTINGS)
|
|
32
|
+
@click.option('-a', '--author', 'author', type=str, default=None,
|
|
33
|
+
help='Author of the repositories. Search my repositories when not given.')
|
|
34
|
+
@click.option('-t', '--type', 'repo_type', type=click.Choice(REPO_TYPES), default='dataset',
|
|
35
|
+
help='Type of the HuggingFace repository.', show_default=True)
|
|
36
|
+
@click.option('-p', '--pattern', 'pattern', type=str, default='*',
|
|
37
|
+
help='Pattern of the repository names.', show_default=True)
|
|
38
|
+
def ls(author: Optional[str], repo_type: str, pattern: str):
|
|
39
|
+
"""
|
|
40
|
+
List repositories from HuggingFace.
|
|
41
|
+
|
|
42
|
+
:param author: Author of the repositories.
|
|
43
|
+
:type author: Optional[str]
|
|
44
|
+
:param repo_type: Type of the HuggingFace repository.
|
|
45
|
+
:type repo_type: str
|
|
46
|
+
:param pattern: Pattern of the repository names.
|
|
47
|
+
:type pattern: str
|
|
48
|
+
"""
|
|
49
|
+
hf_client = get_hf_client()
|
|
50
|
+
if not author:
|
|
51
|
+
try:
|
|
52
|
+
info = hf_client.whoami()
|
|
53
|
+
author = author or info['name']
|
|
54
|
+
except LocalTokenNotFoundError:
|
|
55
|
+
raise NoLocalAuthentication(
|
|
56
|
+
'Authentication failed.\n'
|
|
57
|
+
'Make sure you have set the correct Huggingface token.\n'
|
|
58
|
+
'Or if need to use this with guest mode, please explicitly set the `-a` option.'
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
if repo_type == 'model':
|
|
62
|
+
r = hf_client.list_models(author=author)
|
|
63
|
+
elif repo_type == 'dataset':
|
|
64
|
+
r = hf_client.list_datasets(author=author)
|
|
65
|
+
elif repo_type == 'space':
|
|
66
|
+
r = hf_client.list_spaces(author=author)
|
|
67
|
+
else:
|
|
68
|
+
raise ValueError(f'Unknown repository type - {repo_type!r}.') # pragma: no cover
|
|
69
|
+
|
|
70
|
+
for repo_item in r:
|
|
71
|
+
if fnmatch.fnmatch(repo_item.id, pattern):
|
|
72
|
+
print(repo_item.id)
|
|
73
|
+
|
|
74
|
+
return cli
|
|
@@ -5,6 +5,8 @@ from typing import Literal, List, Optional
|
|
|
5
5
|
|
|
6
6
|
from huggingface_hub import HfApi, HfFileSystem
|
|
7
7
|
|
|
8
|
+
from hfutils.utils import parse_hf_fs_path
|
|
9
|
+
|
|
8
10
|
RepoTypeTyping = Literal['dataset', 'model', 'space']
|
|
9
11
|
REPO_TYPES = ['dataset', 'model', 'space']
|
|
10
12
|
|
|
@@ -113,12 +115,15 @@ def list_files_in_repository(repo_id: str, repo_type: RepoTypeTyping = 'dataset'
|
|
|
113
115
|
|
|
114
116
|
try:
|
|
115
117
|
_exist_files = [
|
|
116
|
-
|
|
118
|
+
parse_hf_fs_path(file).filename
|
|
117
119
|
for file in hf_fs.glob(f'{repo_root_path}/**', revision=revision)
|
|
118
120
|
]
|
|
119
121
|
except FileNotFoundError:
|
|
120
122
|
return []
|
|
121
|
-
|
|
123
|
+
if subdir and subdir != '.':
|
|
124
|
+
_exist_files = [os.path.relpath(file, subdir) for file in _exist_files]
|
|
125
|
+
|
|
126
|
+
_exist_ps = sorted([(file, file.split('/')) for file in _exist_files], key=lambda x: x[1])
|
|
122
127
|
retval = []
|
|
123
128
|
for i, (file, segments) in enumerate(_exist_ps):
|
|
124
129
|
if i < len(_exist_ps) - 1 and segments == _exist_ps[i + 1][1][:len(segments)]:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from .binary import is_binary_file
|
|
2
2
|
from .download import download_file
|
|
3
|
-
from .path import hf_normpath
|
|
3
|
+
from .path import hf_normpath, hf_fs_path, parse_hf_fs_path, HfFileSystemPath
|
|
4
4
|
from .temp import TemporaryDirectory
|
|
5
5
|
from .tqdm_ import tqdm
|
|
6
6
|
from .walk import walk_files
|
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
{
|
|
2
|
+
"datasets": [
|
|
3
|
+
"acronym_identification",
|
|
4
|
+
"ade_corpus_v2",
|
|
5
|
+
"adv_glue",
|
|
6
|
+
"aeslc",
|
|
7
|
+
"afrikaans_ner_corpus",
|
|
8
|
+
"ag_news",
|
|
9
|
+
"air_dialogue",
|
|
10
|
+
"ajgt_twitter_ar",
|
|
11
|
+
"allegro_reviews",
|
|
12
|
+
"allocine",
|
|
13
|
+
"alt",
|
|
14
|
+
"amazon_polarity",
|
|
15
|
+
"amazon_reviews_multi",
|
|
16
|
+
"amazon_us_reviews",
|
|
17
|
+
"ambig_qa",
|
|
18
|
+
"ami",
|
|
19
|
+
"amttl",
|
|
20
|
+
"app_reviews",
|
|
21
|
+
"aqua_rat",
|
|
22
|
+
"aquamuse",
|
|
23
|
+
"ar_res_reviews",
|
|
24
|
+
"ar_sarcasm",
|
|
25
|
+
"arabic_billion_words",
|
|
26
|
+
"arabic_pos_dialect",
|
|
27
|
+
"arabic_speech_corpus",
|
|
28
|
+
"arcd",
|
|
29
|
+
"arsentd_lev",
|
|
30
|
+
"art",
|
|
31
|
+
"arxiv_dataset",
|
|
32
|
+
"ascent_kb",
|
|
33
|
+
"aslg_pc12",
|
|
34
|
+
"asnq",
|
|
35
|
+
"assin",
|
|
36
|
+
"assin2",
|
|
37
|
+
"atomic",
|
|
38
|
+
"autshumato",
|
|
39
|
+
"banking77",
|
|
40
|
+
"bbaw_egyptian",
|
|
41
|
+
"bbc_hindi_nli",
|
|
42
|
+
"bc2gm_corpus",
|
|
43
|
+
"best2009",
|
|
44
|
+
"bible_para",
|
|
45
|
+
"big_patent",
|
|
46
|
+
"bigbench",
|
|
47
|
+
"billsum",
|
|
48
|
+
"bing_coronavirus_query_set",
|
|
49
|
+
"biomrc",
|
|
50
|
+
"biosses",
|
|
51
|
+
"biwi_kinect_head_pose",
|
|
52
|
+
"blended_skill_talk",
|
|
53
|
+
"blog_authorship_corpus",
|
|
54
|
+
"bn_hate_speech",
|
|
55
|
+
"bnl_newspapers",
|
|
56
|
+
"bookcorpus",
|
|
57
|
+
"bookcorpusopen",
|
|
58
|
+
"bprec",
|
|
59
|
+
"break_data",
|
|
60
|
+
"brwac",
|
|
61
|
+
"bsd_ja_en",
|
|
62
|
+
"bswac",
|
|
63
|
+
"c3",
|
|
64
|
+
"c4",
|
|
65
|
+
"cail2018",
|
|
66
|
+
"caner",
|
|
67
|
+
"casino",
|
|
68
|
+
"catalonia_independence",
|
|
69
|
+
"cats_vs_dogs",
|
|
70
|
+
"cawac",
|
|
71
|
+
"cbt",
|
|
72
|
+
"cc100",
|
|
73
|
+
"ccaligned_multilingual",
|
|
74
|
+
"cdsc",
|
|
75
|
+
"cdt",
|
|
76
|
+
"cedr",
|
|
77
|
+
"cfq",
|
|
78
|
+
"chr_en",
|
|
79
|
+
"cifar10",
|
|
80
|
+
"cifar100",
|
|
81
|
+
"circa",
|
|
82
|
+
"clickbait_news_bg",
|
|
83
|
+
"climate_fever",
|
|
84
|
+
"clinc_oos",
|
|
85
|
+
"clue",
|
|
86
|
+
"cmrc2018",
|
|
87
|
+
"cmu_hinglish_dog",
|
|
88
|
+
"cnn_dailymail",
|
|
89
|
+
"coached_conv_pref",
|
|
90
|
+
"coarse_discourse",
|
|
91
|
+
"codah",
|
|
92
|
+
"code_search_net",
|
|
93
|
+
"code_x_glue_cc_clone_detection_big_clone_bench",
|
|
94
|
+
"code_x_glue_cc_clone_detection_poj104",
|
|
95
|
+
"code_x_glue_cc_cloze_testing_all",
|
|
96
|
+
"code_x_glue_cc_cloze_testing_maxmin",
|
|
97
|
+
"code_x_glue_cc_code_completion_line",
|
|
98
|
+
"code_x_glue_cc_code_completion_token",
|
|
99
|
+
"code_x_glue_cc_code_refinement",
|
|
100
|
+
"code_x_glue_cc_code_to_code_trans",
|
|
101
|
+
"code_x_glue_cc_defect_detection",
|
|
102
|
+
"code_x_glue_ct_code_to_text",
|
|
103
|
+
"code_x_glue_tc_nl_code_search_adv",
|
|
104
|
+
"code_x_glue_tc_text_to_code",
|
|
105
|
+
"code_x_glue_tt_text_to_text",
|
|
106
|
+
"com_qa",
|
|
107
|
+
"common_language",
|
|
108
|
+
"common_voice",
|
|
109
|
+
"compguesswhat",
|
|
110
|
+
"conceptnet5",
|
|
111
|
+
"conceptual_12m",
|
|
112
|
+
"conceptual_captions",
|
|
113
|
+
"conll2000",
|
|
114
|
+
"conll2002",
|
|
115
|
+
"conll2003",
|
|
116
|
+
"conll2012_ontonotesv5",
|
|
117
|
+
"conllpp",
|
|
118
|
+
"consumer-finance-complaints",
|
|
119
|
+
"conv_ai",
|
|
120
|
+
"conv_ai_2",
|
|
121
|
+
"conv_ai_3",
|
|
122
|
+
"conv_questions",
|
|
123
|
+
"cornell_movie_dialog",
|
|
124
|
+
"cos_e",
|
|
125
|
+
"cosmos_qa",
|
|
126
|
+
"counter",
|
|
127
|
+
"covid_qa_castorini",
|
|
128
|
+
"covid_qa_deepset",
|
|
129
|
+
"covid_qa_ucsd",
|
|
130
|
+
"covid_tweets_japanese",
|
|
131
|
+
"covost2",
|
|
132
|
+
"cppe-5",
|
|
133
|
+
"craigslist_bargains",
|
|
134
|
+
"crawl_domain",
|
|
135
|
+
"crd3",
|
|
136
|
+
"crime_and_punish",
|
|
137
|
+
"crows_pairs",
|
|
138
|
+
"cryptonite",
|
|
139
|
+
"cs_restaurants",
|
|
140
|
+
"cuad",
|
|
141
|
+
"curiosity_dialogs",
|
|
142
|
+
"daily_dialog",
|
|
143
|
+
"dane",
|
|
144
|
+
"danish_political_comments",
|
|
145
|
+
"dart",
|
|
146
|
+
"datacommons_factcheck",
|
|
147
|
+
"dbrd",
|
|
148
|
+
"deal_or_no_dialog",
|
|
149
|
+
"definite_pronoun_resolution",
|
|
150
|
+
"dengue_filipino",
|
|
151
|
+
"dialog_re",
|
|
152
|
+
"diplomacy_detection",
|
|
153
|
+
"disaster_response_messages",
|
|
154
|
+
"discofuse",
|
|
155
|
+
"discovery",
|
|
156
|
+
"disfl_qa",
|
|
157
|
+
"doc2dial",
|
|
158
|
+
"docred",
|
|
159
|
+
"doqa",
|
|
160
|
+
"dream",
|
|
161
|
+
"dutch_social",
|
|
162
|
+
"dyk",
|
|
163
|
+
"e2e_nlg",
|
|
164
|
+
"e2e_nlg_cleaned",
|
|
165
|
+
"ecb",
|
|
166
|
+
"ecthr_cases",
|
|
167
|
+
"eduge",
|
|
168
|
+
"ehealth_kd",
|
|
169
|
+
"electricity_load_diagrams",
|
|
170
|
+
"eli5",
|
|
171
|
+
"eli5_category",
|
|
172
|
+
"elkarhizketak",
|
|
173
|
+
"emea",
|
|
174
|
+
"emo",
|
|
175
|
+
"emotone_ar",
|
|
176
|
+
"empathetic_dialogues",
|
|
177
|
+
"enriched_web_nlg",
|
|
178
|
+
"enwik8",
|
|
179
|
+
"eraser_multi_rc",
|
|
180
|
+
"esnli",
|
|
181
|
+
"eth_py150_open",
|
|
182
|
+
"ethos",
|
|
183
|
+
"ett",
|
|
184
|
+
"eu_regulatory_ir",
|
|
185
|
+
"eurlex",
|
|
186
|
+
"euronews",
|
|
187
|
+
"europa_eac_tm",
|
|
188
|
+
"europa_ecdc_tm",
|
|
189
|
+
"event2Mind",
|
|
190
|
+
"evidence_infer_treatment",
|
|
191
|
+
"factckbr",
|
|
192
|
+
"fake_news_english",
|
|
193
|
+
"fake_news_filipino",
|
|
194
|
+
"farsi_news",
|
|
195
|
+
"fashion_mnist",
|
|
196
|
+
"fever",
|
|
197
|
+
"few_rel",
|
|
198
|
+
"financial_phrasebank",
|
|
199
|
+
"finer",
|
|
200
|
+
"flores",
|
|
201
|
+
"flue",
|
|
202
|
+
"food101",
|
|
203
|
+
"fquad",
|
|
204
|
+
"freebase_qa",
|
|
205
|
+
"gap",
|
|
206
|
+
"gem",
|
|
207
|
+
"generated_reviews_enth",
|
|
208
|
+
"generics_kb",
|
|
209
|
+
"german_legal_entity_recognition",
|
|
210
|
+
"germaner",
|
|
211
|
+
"germeval_14",
|
|
212
|
+
"giga_fren",
|
|
213
|
+
"gigaword",
|
|
214
|
+
"glucose",
|
|
215
|
+
"gnad10",
|
|
216
|
+
"go_emotions",
|
|
217
|
+
"gooaq",
|
|
218
|
+
"google_wellformed_query",
|
|
219
|
+
"grail_qa",
|
|
220
|
+
"great_code",
|
|
221
|
+
"gsm8k",
|
|
222
|
+
"guardian_authorship",
|
|
223
|
+
"gutenberg_time",
|
|
224
|
+
"hans",
|
|
225
|
+
"hansards",
|
|
226
|
+
"hard",
|
|
227
|
+
"harem",
|
|
228
|
+
"has_part",
|
|
229
|
+
"hate_offensive",
|
|
230
|
+
"hate_speech18",
|
|
231
|
+
"hate_speech_filipino",
|
|
232
|
+
"hate_speech_pl",
|
|
233
|
+
"hate_speech_portuguese",
|
|
234
|
+
"hatexplain",
|
|
235
|
+
"hausa_voa_ner",
|
|
236
|
+
"hausa_voa_topics",
|
|
237
|
+
"hda_nli_hindi",
|
|
238
|
+
"head_qa",
|
|
239
|
+
"health_fact",
|
|
240
|
+
"hebrew_projectbenyehuda",
|
|
241
|
+
"hebrew_sentiment",
|
|
242
|
+
"hebrew_this_world",
|
|
243
|
+
"hind_encorp",
|
|
244
|
+
"hindi_discourse",
|
|
245
|
+
"hippocorpus",
|
|
246
|
+
"hkcancor",
|
|
247
|
+
"hlgd",
|
|
248
|
+
"hope_edi",
|
|
249
|
+
"hotpot_qa",
|
|
250
|
+
"hover",
|
|
251
|
+
"hrenwac_para",
|
|
252
|
+
"hrwac",
|
|
253
|
+
"humicroedit",
|
|
254
|
+
"hybrid_qa",
|
|
255
|
+
"hyperpartisan_news_detection",
|
|
256
|
+
"iapp_wiki_qa_squad",
|
|
257
|
+
"id_clickbait",
|
|
258
|
+
"id_liputan6",
|
|
259
|
+
"id_nergrit_corpus",
|
|
260
|
+
"id_newspapers_2018",
|
|
261
|
+
"id_panl_bppt",
|
|
262
|
+
"id_puisi",
|
|
263
|
+
"igbo_english_machine_translation",
|
|
264
|
+
"igbo_monolingual",
|
|
265
|
+
"igbo_ner",
|
|
266
|
+
"ilist",
|
|
267
|
+
"imagenet-1k",
|
|
268
|
+
"imagenet_sketch",
|
|
269
|
+
"imdb_urdu_reviews",
|
|
270
|
+
"imppres",
|
|
271
|
+
"indic_glue",
|
|
272
|
+
"indonli",
|
|
273
|
+
"inquisitive_qg",
|
|
274
|
+
"interpress_news_category_tr",
|
|
275
|
+
"interpress_news_category_tr_lite",
|
|
276
|
+
"irc_disentangle",
|
|
277
|
+
"isixhosa_ner_corpus",
|
|
278
|
+
"isizulu_ner_corpus",
|
|
279
|
+
"iwslt2017",
|
|
280
|
+
"jeopardy",
|
|
281
|
+
"jnlpba",
|
|
282
|
+
"journalists_questions",
|
|
283
|
+
"kan_hope",
|
|
284
|
+
"kannada_news",
|
|
285
|
+
"kd_conv",
|
|
286
|
+
"kde4",
|
|
287
|
+
"kelm",
|
|
288
|
+
"kilt_tasks",
|
|
289
|
+
"kilt_wikipedia",
|
|
290
|
+
"kinnews_kirnews",
|
|
291
|
+
"klue",
|
|
292
|
+
"kor_3i4k",
|
|
293
|
+
"kor_hate",
|
|
294
|
+
"kor_ner",
|
|
295
|
+
"kor_nli",
|
|
296
|
+
"kor_nlu",
|
|
297
|
+
"kor_qpair",
|
|
298
|
+
"kor_sae",
|
|
299
|
+
"kor_sarcasm",
|
|
300
|
+
"labr",
|
|
301
|
+
"lama",
|
|
302
|
+
"large_spanish_corpus",
|
|
303
|
+
"laroseda",
|
|
304
|
+
"lc_quad",
|
|
305
|
+
"lccc",
|
|
306
|
+
"lener_br",
|
|
307
|
+
"liar",
|
|
308
|
+
"librispeech_asr",
|
|
309
|
+
"librispeech_lm",
|
|
310
|
+
"limit",
|
|
311
|
+
"lince",
|
|
312
|
+
"linnaeus",
|
|
313
|
+
"liveqa",
|
|
314
|
+
"lj_speech",
|
|
315
|
+
"lm1b",
|
|
316
|
+
"lst20",
|
|
317
|
+
"m_lama",
|
|
318
|
+
"mac_morpho",
|
|
319
|
+
"makhzan",
|
|
320
|
+
"masakhaner",
|
|
321
|
+
"math_dataset",
|
|
322
|
+
"math_qa",
|
|
323
|
+
"matinf",
|
|
324
|
+
"mbpp",
|
|
325
|
+
"mc4",
|
|
326
|
+
"mc_taco",
|
|
327
|
+
"md_gender_bias",
|
|
328
|
+
"mdd",
|
|
329
|
+
"med_hop",
|
|
330
|
+
"medal",
|
|
331
|
+
"medical_dialog",
|
|
332
|
+
"medical_questions_pairs",
|
|
333
|
+
"menyo20k_mt",
|
|
334
|
+
"meta_woz",
|
|
335
|
+
"metashift",
|
|
336
|
+
"metooma",
|
|
337
|
+
"metrec",
|
|
338
|
+
"miam",
|
|
339
|
+
"mkb",
|
|
340
|
+
"mkqa",
|
|
341
|
+
"mlqa",
|
|
342
|
+
"mlsum",
|
|
343
|
+
"mnist",
|
|
344
|
+
"mocha",
|
|
345
|
+
"monash_tsf",
|
|
346
|
+
"moroco",
|
|
347
|
+
"movie_rationales",
|
|
348
|
+
"mrqa",
|
|
349
|
+
"ms_marco",
|
|
350
|
+
"ms_terms",
|
|
351
|
+
"msr_genomics_kbcomp",
|
|
352
|
+
"msr_sqa",
|
|
353
|
+
"msr_text_compression",
|
|
354
|
+
"msr_zhen_translation_parity",
|
|
355
|
+
"msra_ner",
|
|
356
|
+
"mt_eng_vietnamese",
|
|
357
|
+
"muchocine",
|
|
358
|
+
"multi_booked",
|
|
359
|
+
"multi_news",
|
|
360
|
+
"multi_nli_mismatch",
|
|
361
|
+
"multi_para_crawl",
|
|
362
|
+
"multi_re_qa",
|
|
363
|
+
"multi_woz_v22",
|
|
364
|
+
"multi_x_science_sum",
|
|
365
|
+
"multidoc2dial",
|
|
366
|
+
"multilingual_librispeech",
|
|
367
|
+
"mutual_friends",
|
|
368
|
+
"mwsc",
|
|
369
|
+
"myanmar_news",
|
|
370
|
+
"narrativeqa",
|
|
371
|
+
"narrativeqa_manual",
|
|
372
|
+
"natural_questions",
|
|
373
|
+
"ncbi_disease",
|
|
374
|
+
"nchlt",
|
|
375
|
+
"ncslgr",
|
|
376
|
+
"nell",
|
|
377
|
+
"neural_code_search",
|
|
378
|
+
"newsgroup",
|
|
379
|
+
"newsph",
|
|
380
|
+
"newsph_nli",
|
|
381
|
+
"newspop",
|
|
382
|
+
"newsqa",
|
|
383
|
+
"newsroom",
|
|
384
|
+
"nkjp-ner",
|
|
385
|
+
"nli_tr",
|
|
386
|
+
"nlu_evaluation_data",
|
|
387
|
+
"norec",
|
|
388
|
+
"norne",
|
|
389
|
+
"norwegian_ner",
|
|
390
|
+
"nq_open",
|
|
391
|
+
"nsmc",
|
|
392
|
+
"numer_sense",
|
|
393
|
+
"numeric_fused_head",
|
|
394
|
+
"oclar",
|
|
395
|
+
"offcombr",
|
|
396
|
+
"offenseval2020_tr",
|
|
397
|
+
"offenseval_dravidian",
|
|
398
|
+
"ofis_publik",
|
|
399
|
+
"ohsumed",
|
|
400
|
+
"ollie",
|
|
401
|
+
"omp",
|
|
402
|
+
"onestop_english",
|
|
403
|
+
"onestop_qa",
|
|
404
|
+
"open_subtitles",
|
|
405
|
+
"openai_humaneval",
|
|
406
|
+
"openslr",
|
|
407
|
+
"opinosis",
|
|
408
|
+
"orange_sum",
|
|
409
|
+
"oscar",
|
|
410
|
+
"para_crawl",
|
|
411
|
+
"para_pat",
|
|
412
|
+
"parsinlu_reading_comprehension",
|
|
413
|
+
"pass",
|
|
414
|
+
"paws",
|
|
415
|
+
"paws-x",
|
|
416
|
+
"pec",
|
|
417
|
+
"peoples_daily_ner",
|
|
418
|
+
"per_sent",
|
|
419
|
+
"persian_ner",
|
|
420
|
+
"pg19",
|
|
421
|
+
"php",
|
|
422
|
+
"pib",
|
|
423
|
+
"piqa",
|
|
424
|
+
"pn_summary",
|
|
425
|
+
"poem_sentiment",
|
|
426
|
+
"polemo2",
|
|
427
|
+
"poleval2019_cyberbullying",
|
|
428
|
+
"poleval2019_mt",
|
|
429
|
+
"polsum",
|
|
430
|
+
"polyglot_ner",
|
|
431
|
+
"prachathai67k",
|
|
432
|
+
"pragmeval",
|
|
433
|
+
"proto_qa",
|
|
434
|
+
"psc",
|
|
435
|
+
"ptb_text_only",
|
|
436
|
+
"pubmed",
|
|
437
|
+
"py_ast",
|
|
438
|
+
"qa4mre",
|
|
439
|
+
"qa_srl",
|
|
440
|
+
"qa_zre",
|
|
441
|
+
"qangaroo",
|
|
442
|
+
"qanta",
|
|
443
|
+
"qed",
|
|
444
|
+
"qed_amara",
|
|
445
|
+
"quac",
|
|
446
|
+
"quail",
|
|
447
|
+
"quarel",
|
|
448
|
+
"quickdraw",
|
|
449
|
+
"quora",
|
|
450
|
+
"quoref",
|
|
451
|
+
"re_dial",
|
|
452
|
+
"reasoning_bg",
|
|
453
|
+
"recipe_nlg",
|
|
454
|
+
"reclor",
|
|
455
|
+
"red_caps",
|
|
456
|
+
"reddit_tifu",
|
|
457
|
+
"refresd",
|
|
458
|
+
"reuters21578",
|
|
459
|
+
"riddle_sense",
|
|
460
|
+
"ro_sent",
|
|
461
|
+
"ro_sts",
|
|
462
|
+
"ro_sts_parallel",
|
|
463
|
+
"roman_urdu",
|
|
464
|
+
"roman_urdu_hate_speech",
|
|
465
|
+
"ronec",
|
|
466
|
+
"rotten_tomatoes",
|
|
467
|
+
"samsum",
|
|
468
|
+
"sanskrit_classic",
|
|
469
|
+
"saudinewsnet",
|
|
470
|
+
"sberquad",
|
|
471
|
+
"sbu_captions",
|
|
472
|
+
"scan",
|
|
473
|
+
"scb_mt_enth_2020",
|
|
474
|
+
"scene_parse_150",
|
|
475
|
+
"schema_guided_dstc8",
|
|
476
|
+
"scielo",
|
|
477
|
+
"scientific_papers",
|
|
478
|
+
"search_qa",
|
|
479
|
+
"sede",
|
|
480
|
+
"selqa",
|
|
481
|
+
"sem_eval_2010_task_8",
|
|
482
|
+
"sem_eval_2014_task_1",
|
|
483
|
+
"sem_eval_2018_task_1",
|
|
484
|
+
"sem_eval_2020_task_11",
|
|
485
|
+
"sent_comp",
|
|
486
|
+
"senti_lex",
|
|
487
|
+
"senti_ws",
|
|
488
|
+
"sentiment140",
|
|
489
|
+
"sepedi_ner",
|
|
490
|
+
"sesotho_ner_corpus",
|
|
491
|
+
"setimes",
|
|
492
|
+
"setswana_ner_corpus",
|
|
493
|
+
"sharc_modified",
|
|
494
|
+
"sick",
|
|
495
|
+
"silicone",
|
|
496
|
+
"simple_questions_v2",
|
|
497
|
+
"siswati_ner_corpus",
|
|
498
|
+
"smartdata",
|
|
499
|
+
"sms_spam",
|
|
500
|
+
"snips_built_in_intents",
|
|
501
|
+
"snow_simplified_japanese_corpus",
|
|
502
|
+
"so_stacksample",
|
|
503
|
+
"social_bias_frames",
|
|
504
|
+
"social_i_qa",
|
|
505
|
+
"sofc_materials_articles",
|
|
506
|
+
"sogou_news",
|
|
507
|
+
"spanish_billion_words",
|
|
508
|
+
"spc",
|
|
509
|
+
"species_800",
|
|
510
|
+
"speech_commands",
|
|
511
|
+
"squad_adversarial",
|
|
512
|
+
"squad_es",
|
|
513
|
+
"squad_it",
|
|
514
|
+
"squad_kor_v1",
|
|
515
|
+
"squad_kor_v2",
|
|
516
|
+
"squad_v1_pt",
|
|
517
|
+
"squadshifts",
|
|
518
|
+
"srwac",
|
|
519
|
+
"sst",
|
|
520
|
+
"story_cloze",
|
|
521
|
+
"stsb_mt_sv",
|
|
522
|
+
"style_change_detection",
|
|
523
|
+
"subjqa",
|
|
524
|
+
"super_glue",
|
|
525
|
+
"superb",
|
|
526
|
+
"svhn",
|
|
527
|
+
"swag",
|
|
528
|
+
"swahili",
|
|
529
|
+
"swahili_news",
|
|
530
|
+
"swda",
|
|
531
|
+
"swedish_medical_ner",
|
|
532
|
+
"swedish_ner_corpus",
|
|
533
|
+
"swedish_reviews",
|
|
534
|
+
"tab_fact",
|
|
535
|
+
"tamilmixsentiment",
|
|
536
|
+
"tanzil",
|
|
537
|
+
"tapaco",
|
|
538
|
+
"tashkeela",
|
|
539
|
+
"taskmaster1",
|
|
540
|
+
"taskmaster2",
|
|
541
|
+
"taskmaster3",
|
|
542
|
+
"tatoeba",
|
|
543
|
+
"ted_hrlr",
|
|
544
|
+
"ted_iwlst2013",
|
|
545
|
+
"ted_multi",
|
|
546
|
+
"ted_talks_iwslt",
|
|
547
|
+
"telugu_books",
|
|
548
|
+
"telugu_news",
|
|
549
|
+
"tep_en_fa_para",
|
|
550
|
+
"text2log",
|
|
551
|
+
"textvqa",
|
|
552
|
+
"thai_toxicity_tweet",
|
|
553
|
+
"thainer",
|
|
554
|
+
"thaiqa_squad",
|
|
555
|
+
"thaisum",
|
|
556
|
+
"the_pile_books3",
|
|
557
|
+
"the_pile_openwebtext2",
|
|
558
|
+
"the_pile_stack_exchange",
|
|
559
|
+
"tilde_model",
|
|
560
|
+
"time_dial",
|
|
561
|
+
"times_of_india_news_headlines",
|
|
562
|
+
"timit_asr",
|
|
563
|
+
"tlc",
|
|
564
|
+
"tmu_gfm_dataset",
|
|
565
|
+
"tne",
|
|
566
|
+
"told-br",
|
|
567
|
+
"totto",
|
|
568
|
+
"trec",
|
|
569
|
+
"truthful_qa",
|
|
570
|
+
"tsac",
|
|
571
|
+
"ttc4900",
|
|
572
|
+
"tunizi",
|
|
573
|
+
"tuple_ie",
|
|
574
|
+
"turk",
|
|
575
|
+
"turkic_xwmt",
|
|
576
|
+
"turkish_movie_sentiment",
|
|
577
|
+
"turkish_ner",
|
|
578
|
+
"turkish_product_reviews",
|
|
579
|
+
"turkish_shrinked_ner",
|
|
580
|
+
"turku_ner_corpus",
|
|
581
|
+
"tweet_eval",
|
|
582
|
+
"tweet_qa",
|
|
583
|
+
"tweets_ar_en_parallel",
|
|
584
|
+
"tweets_hate_speech_detection",
|
|
585
|
+
"twi_text_c3",
|
|
586
|
+
"twi_wordsim353",
|
|
587
|
+
"tydiqa",
|
|
588
|
+
"ubuntu_dialogs_corpus",
|
|
589
|
+
"udhr",
|
|
590
|
+
"um005",
|
|
591
|
+
"universal_dependencies",
|
|
592
|
+
"universal_morphologies",
|
|
593
|
+
"urdu_fake_news",
|
|
594
|
+
"urdu_sentiment_corpus",
|
|
595
|
+
"vctk",
|
|
596
|
+
"visual_genome",
|
|
597
|
+
"vivos",
|
|
598
|
+
"web_nlg",
|
|
599
|
+
"web_of_science",
|
|
600
|
+
"web_questions",
|
|
601
|
+
"weibo_ner",
|
|
602
|
+
"wi_locness",
|
|
603
|
+
"wider_face",
|
|
604
|
+
"wiki40b",
|
|
605
|
+
"wiki_asp",
|
|
606
|
+
"wiki_atomic_edits",
|
|
607
|
+
"wiki_auto",
|
|
608
|
+
"wiki_bio",
|
|
609
|
+
"wiki_dpr",
|
|
610
|
+
"wiki_hop",
|
|
611
|
+
"wiki_lingua",
|
|
612
|
+
"wiki_movies",
|
|
613
|
+
"wiki_qa",
|
|
614
|
+
"wiki_qa_ar",
|
|
615
|
+
"wiki_snippets",
|
|
616
|
+
"wiki_source",
|
|
617
|
+
"wiki_split",
|
|
618
|
+
"wiki_summary",
|
|
619
|
+
"wikiann",
|
|
620
|
+
"wikicorpus",
|
|
621
|
+
"wikihow",
|
|
622
|
+
"wikipedia",
|
|
623
|
+
"wikisql",
|
|
624
|
+
"wikitablequestions",
|
|
625
|
+
"wikitext",
|
|
626
|
+
"wikitext_tl39",
|
|
627
|
+
"wili_2018",
|
|
628
|
+
"wino_bias",
|
|
629
|
+
"winograd_wsc",
|
|
630
|
+
"winogrande",
|
|
631
|
+
"wiqa",
|
|
632
|
+
"wisesight1000",
|
|
633
|
+
"wisesight_sentiment",
|
|
634
|
+
"wnut_17",
|
|
635
|
+
"wongnai_reviews",
|
|
636
|
+
"woz_dialogue",
|
|
637
|
+
"wrbsc",
|
|
638
|
+
"x_stance",
|
|
639
|
+
"xcopa",
|
|
640
|
+
"xcsr",
|
|
641
|
+
"xed_en_fi",
|
|
642
|
+
"xglue",
|
|
643
|
+
"xnli",
|
|
644
|
+
"xor_tydi_qa",
|
|
645
|
+
"xquad",
|
|
646
|
+
"xquad_r",
|
|
647
|
+
"xsum_factuality",
|
|
648
|
+
"xtreme",
|
|
649
|
+
"yahoo_answers_qa",
|
|
650
|
+
"yahoo_answers_topics",
|
|
651
|
+
"yelp_polarity",
|
|
652
|
+
"yelp_review_full",
|
|
653
|
+
"yoruba_bbc_topics",
|
|
654
|
+
"yoruba_gv_ner",
|
|
655
|
+
"yoruba_text_c3",
|
|
656
|
+
"yoruba_wordsim353",
|
|
657
|
+
"youtube_caption_corrections",
|
|
658
|
+
"zest"
|
|
659
|
+
],
|
|
660
|
+
"models": [],
|
|
661
|
+
"spaces": []
|
|
662
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import re
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from functools import lru_cache
|
|
6
|
+
from typing import Optional, Dict, Set, Literal
|
|
7
|
+
|
|
8
|
+
RepoTypeTyping = Literal['dataset', 'model', 'space']
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def hf_normpath(path) -> str:
|
|
12
|
+
"""
|
|
13
|
+
Normalize a given path.
|
|
14
|
+
|
|
15
|
+
:param path: The path to normalize.
|
|
16
|
+
:type path: Any
|
|
17
|
+
|
|
18
|
+
:return: The normalized path.
|
|
19
|
+
:rtype: str
|
|
20
|
+
"""
|
|
21
|
+
return re.sub(
|
|
22
|
+
r'[\\/]+', '/',
|
|
23
|
+
os.path.relpath(os.path.normpath(os.path.join(os.sep, path)), os.sep)
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def hf_fs_path(repo_id: str, filename: str,
|
|
28
|
+
repo_type: RepoTypeTyping = 'dataset', revision: Optional[str] = None):
|
|
29
|
+
"""
|
|
30
|
+
Get the huggingface filesystem path.
|
|
31
|
+
|
|
32
|
+
:param repo_id: The repository ID.
|
|
33
|
+
:type repo_id: str
|
|
34
|
+
|
|
35
|
+
:param filename: The filename.
|
|
36
|
+
:type filename: str
|
|
37
|
+
|
|
38
|
+
:param repo_type: The type of repository. (default: 'dataset')
|
|
39
|
+
:type repo_type: RepoTypeTyping
|
|
40
|
+
|
|
41
|
+
:param revision: The revision of the repository. (default: None)
|
|
42
|
+
:type revision: Optional[str]
|
|
43
|
+
|
|
44
|
+
:return: The huggingface filesystem path.
|
|
45
|
+
:rtype: str
|
|
46
|
+
"""
|
|
47
|
+
filename = hf_normpath(filename)
|
|
48
|
+
if repo_type == 'dataset':
|
|
49
|
+
prefix = 'datasets/'
|
|
50
|
+
elif repo_type == 'space':
|
|
51
|
+
prefix = 'spaces/'
|
|
52
|
+
else:
|
|
53
|
+
prefix = ''
|
|
54
|
+
|
|
55
|
+
if revision is not None:
|
|
56
|
+
revision_text = f'@{revision}'
|
|
57
|
+
else:
|
|
58
|
+
revision_text = ''
|
|
59
|
+
|
|
60
|
+
return f'{prefix}{repo_id}{revision_text}/{filename}'
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@lru_cache()
|
|
64
|
+
def _irregular_repos() -> Dict[RepoTypeTyping, Set[str]]:
|
|
65
|
+
"""
|
|
66
|
+
Get irregular repositories.
|
|
67
|
+
|
|
68
|
+
:return: A dictionary containing irregular repositories.
|
|
69
|
+
:rtype: Dict[RepoTypeTyping, Set[str]]
|
|
70
|
+
"""
|
|
71
|
+
with open(os.path.join(os.path.dirname(__file__), 'irregular_repo.json'), 'r') as f:
|
|
72
|
+
data = json.load(f)
|
|
73
|
+
return {
|
|
74
|
+
'model': set(data['models']),
|
|
75
|
+
'dataset': set(data['datasets']),
|
|
76
|
+
'space': set(data['spaces']),
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
_RE_IR_PATH = re.compile(
|
|
81
|
+
r'^(?P<repo_id>[^@/]+)(@(?P<revision>[^@/]+))?(/(?P<filename>[\s\S]+))?$')
|
|
82
|
+
_RE_PATH = re.compile(
|
|
83
|
+
r'^(?P<repo_id>[^@/]+/[^@/]+)(@(?P<revision>[^@/]+))?(/(?P<filename>[\s\S]+))?$')
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@dataclass
|
|
87
|
+
class HfFileSystemPath:
|
|
88
|
+
"""
|
|
89
|
+
Huggingface FileSystem Path.
|
|
90
|
+
|
|
91
|
+
:param repo_id: The repository ID.
|
|
92
|
+
:type repo_id: str
|
|
93
|
+
|
|
94
|
+
:param filename: The filename.
|
|
95
|
+
:type filename: str
|
|
96
|
+
|
|
97
|
+
:param repo_type: The type of repository.
|
|
98
|
+
:type repo_type: RepoTypeTyping
|
|
99
|
+
|
|
100
|
+
:param revision: The revision of the repository.
|
|
101
|
+
:type revision: Optional[str]
|
|
102
|
+
"""
|
|
103
|
+
repo_id: str
|
|
104
|
+
filename: str
|
|
105
|
+
repo_type: RepoTypeTyping
|
|
106
|
+
revision: Optional[str]
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def parse_hf_fs_path(path: str) -> HfFileSystemPath:
|
|
110
|
+
"""
|
|
111
|
+
Parse the huggingface filesystem path.
|
|
112
|
+
|
|
113
|
+
:param path: The path to parse.
|
|
114
|
+
:type path: str
|
|
115
|
+
|
|
116
|
+
:return: The parsed huggingface filesystem path.
|
|
117
|
+
:rtype: HfFileSystemPath
|
|
118
|
+
:raises ValueError: If this path is invalid.
|
|
119
|
+
"""
|
|
120
|
+
origin_path = path
|
|
121
|
+
repo_type: RepoTypeTyping
|
|
122
|
+
if path.startswith('datasets/'):
|
|
123
|
+
repo_type = 'dataset'
|
|
124
|
+
path = path[len('datasets/'):]
|
|
125
|
+
elif path.startswith('spaces/'):
|
|
126
|
+
repo_type = 'space'
|
|
127
|
+
path = path[len('spaces/'):]
|
|
128
|
+
else:
|
|
129
|
+
repo_type = 'model'
|
|
130
|
+
|
|
131
|
+
matching = _RE_IR_PATH.fullmatch(path)
|
|
132
|
+
if matching:
|
|
133
|
+
if matching.group('repo_id') not in _irregular_repos()[repo_type]:
|
|
134
|
+
matching = None
|
|
135
|
+
if not matching:
|
|
136
|
+
matching = _RE_PATH.fullmatch(path)
|
|
137
|
+
|
|
138
|
+
if matching:
|
|
139
|
+
repo_id = matching.group('repo_id')
|
|
140
|
+
revision = matching.group('revision') or None
|
|
141
|
+
filename = hf_normpath(matching.group('filename') or '.')
|
|
142
|
+
return HfFileSystemPath(repo_id, filename, repo_type, revision)
|
|
143
|
+
else:
|
|
144
|
+
raise ValueError(f'Invalid huggingface filesystem path - {origin_path!r}.')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hfutils
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: Useful utilities for huggingface
|
|
5
5
|
Home-page: https://github.com/deepghs/hfutils
|
|
6
6
|
Author: narugo1992
|
|
@@ -26,25 +26,9 @@ Requires-Dist: tqdm
|
|
|
26
26
|
Requires-Dist: requests
|
|
27
27
|
Requires-Dist: click>=7
|
|
28
28
|
Requires-Dist: tzlocal
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Requires-Dist: coverage>=5; extra == "test"
|
|
33
|
-
Requires-Dist: mock>=4.0.3; extra == "test"
|
|
34
|
-
Requires-Dist: flake8~=3.5; extra == "test"
|
|
35
|
-
Requires-Dist: testfixtures>=6.18.5; extra == "test"
|
|
36
|
-
Requires-Dist: pytest~=6.2.5; extra == "test"
|
|
37
|
-
Requires-Dist: pytest-cov~=3.0.0; extra == "test"
|
|
38
|
-
Requires-Dist: pytest-mock~=3.6.1; extra == "test"
|
|
39
|
-
Requires-Dist: pytest-xdist>=1.34.0; extra == "test"
|
|
40
|
-
Requires-Dist: pytest-rerunfailures~=10.2; extra == "test"
|
|
41
|
-
Requires-Dist: pytest-timeout~=2.0.2; extra == "test"
|
|
42
|
-
Requires-Dist: pytest-benchmark~=3.4.0; extra == "test"
|
|
43
|
-
Requires-Dist: easydict<2,>=1.7; extra == "test"
|
|
44
|
-
Requires-Dist: testtools>=2; extra == "test"
|
|
45
|
-
Requires-Dist: where>=1.0.2; extra == "test"
|
|
46
|
-
Requires-Dist: responses>=0.20.0; extra == "test"
|
|
47
|
-
Requires-Dist: natsort; extra == "test"
|
|
29
|
+
Requires-Dist: natsort
|
|
30
|
+
Provides-Extra: build
|
|
31
|
+
Requires-Dist: pyinstaller<5,>=4.7; extra == "build"
|
|
48
32
|
Provides-Extra: doc
|
|
49
33
|
Requires-Dist: Jinja2>=3.0.0; extra == "doc"
|
|
50
34
|
Requires-Dist: sphinx>=3.2.0; extra == "doc"
|
|
@@ -65,12 +49,29 @@ Requires-Dist: ipykernel>=6.15; extra == "doc"
|
|
|
65
49
|
Requires-Dist: py-cpuinfo>=8.0.0; extra == "doc"
|
|
66
50
|
Requires-Dist: click>=7.0.0; extra == "doc"
|
|
67
51
|
Requires-Dist: pandas; extra == "doc"
|
|
68
|
-
Provides-Extra: build
|
|
69
|
-
Requires-Dist: pyinstaller<5,>=4.7; extra == "build"
|
|
70
52
|
Provides-Extra: 7z
|
|
71
53
|
Requires-Dist: py7zr; extra == "7z"
|
|
72
54
|
Provides-Extra: transfer
|
|
73
55
|
Requires-Dist: hf-transfer; extra == "transfer"
|
|
56
|
+
Provides-Extra: test
|
|
57
|
+
Requires-Dist: coverage>=5; extra == "test"
|
|
58
|
+
Requires-Dist: mock>=4.0.3; extra == "test"
|
|
59
|
+
Requires-Dist: flake8~=3.5; extra == "test"
|
|
60
|
+
Requires-Dist: testfixtures>=6.18.5; extra == "test"
|
|
61
|
+
Requires-Dist: pytest~=6.2.5; extra == "test"
|
|
62
|
+
Requires-Dist: pytest-cov~=3.0.0; extra == "test"
|
|
63
|
+
Requires-Dist: pytest-mock~=3.6.1; extra == "test"
|
|
64
|
+
Requires-Dist: pytest-xdist>=1.34.0; extra == "test"
|
|
65
|
+
Requires-Dist: pytest-rerunfailures~=10.2; extra == "test"
|
|
66
|
+
Requires-Dist: pytest-timeout~=2.0.2; extra == "test"
|
|
67
|
+
Requires-Dist: pytest-benchmark~=3.4.0; extra == "test"
|
|
68
|
+
Requires-Dist: easydict<2,>=1.7; extra == "test"
|
|
69
|
+
Requires-Dist: testtools>=2; extra == "test"
|
|
70
|
+
Requires-Dist: where>=1.0.2; extra == "test"
|
|
71
|
+
Requires-Dist: responses>=0.20.0; extra == "test"
|
|
72
|
+
Requires-Dist: natsort; extra == "test"
|
|
73
|
+
Provides-Extra: rar
|
|
74
|
+
Requires-Dist: rarfile; extra == "rar"
|
|
74
75
|
|
|
75
76
|
# hfutils
|
|
76
77
|
|
|
@@ -10,6 +10,7 @@ requirements-transfer.txt
|
|
|
10
10
|
requirements.txt
|
|
11
11
|
setup.py
|
|
12
12
|
hfutils/__init__.py
|
|
13
|
+
hfutils/__main__.py
|
|
13
14
|
hfutils.egg-info/PKG-INFO
|
|
14
15
|
hfutils.egg-info/SOURCES.txt
|
|
15
16
|
hfutils.egg-info/dependency_links.txt
|
|
@@ -30,6 +31,7 @@ hfutils/entry/cli.py
|
|
|
30
31
|
hfutils/entry/dispatch.py
|
|
31
32
|
hfutils/entry/download.py
|
|
32
33
|
hfutils/entry/ls.py
|
|
34
|
+
hfutils/entry/ls_repo.py
|
|
33
35
|
hfutils/entry/upload.py
|
|
34
36
|
hfutils/entry/whoami.py
|
|
35
37
|
hfutils/index/__init__.py
|
|
@@ -45,6 +47,7 @@ hfutils/operate/validate.py
|
|
|
45
47
|
hfutils/utils/__init__.py
|
|
46
48
|
hfutils/utils/binary.py
|
|
47
49
|
hfutils/utils/download.py
|
|
50
|
+
hfutils/utils/irregular_repo.json
|
|
48
51
|
hfutils/utils/path.py
|
|
49
52
|
hfutils/utils/temp.py
|
|
50
53
|
hfutils/utils/tqdm_.py
|
|
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
|