hfutils 0.3.5__tar.gz → 0.3.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.
Files changed (68) hide show
  1. {hfutils-0.3.5/hfutils.egg-info → hfutils-0.3.6}/PKG-INFO +23 -23
  2. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/config/meta.py +1 -1
  3. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/index/fetch.py +17 -7
  4. {hfutils-0.3.5 → hfutils-0.3.6/hfutils.egg-info}/PKG-INFO +23 -23
  5. {hfutils-0.3.5 → hfutils-0.3.6}/LICENSE +0 -0
  6. {hfutils-0.3.5 → hfutils-0.3.6}/MANIFEST.in +0 -0
  7. {hfutils-0.3.5 → hfutils-0.3.6}/README.md +0 -0
  8. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/__init__.py +0 -0
  9. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/__main__.py +0 -0
  10. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/archive/__init__.py +0 -0
  11. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/archive/base.py +0 -0
  12. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/archive/rar.py +0 -0
  13. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/archive/sevenz.py +0 -0
  14. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/archive/tar.py +0 -0
  15. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/archive/zip.py +0 -0
  16. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/cache/__init__.py +0 -0
  17. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/cache/delete.py +0 -0
  18. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/config/__init__.py +0 -0
  19. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/__init__.py +0 -0
  20. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/base.py +0 -0
  21. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/cli.py +0 -0
  22. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/clone.py +0 -0
  23. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/dispatch.py +0 -0
  24. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/download.py +0 -0
  25. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/index.py +0 -0
  26. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/ls.py +0 -0
  27. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/ls_repo.py +0 -0
  28. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/rollback.py +0 -0
  29. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/upload.py +0 -0
  30. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/entry/whoami.py +0 -0
  31. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/index/__init__.py +0 -0
  32. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/index/hash.py +0 -0
  33. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/index/local_fetch.py +0 -0
  34. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/index/make.py +0 -0
  35. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/index/validate.py +0 -0
  36. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/operate/__init__.py +0 -0
  37. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/operate/base.py +0 -0
  38. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/operate/download.py +0 -0
  39. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/operate/upload.py +0 -0
  40. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/operate/validate.py +0 -0
  41. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/repository/__init__.py +0 -0
  42. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/repository/base.py +0 -0
  43. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/repository/clone.py +0 -0
  44. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/repository/rollback.py +0 -0
  45. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/utils/__init__.py +0 -0
  46. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/utils/binary.py +0 -0
  47. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/utils/download.py +0 -0
  48. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/utils/irregular_repo.json +0 -0
  49. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/utils/logging.py +0 -0
  50. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/utils/number.py +0 -0
  51. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/utils/path.py +0 -0
  52. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/utils/temp.py +0 -0
  53. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/utils/tqdm_.py +0 -0
  54. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils/utils/walk.py +0 -0
  55. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils.egg-info/SOURCES.txt +0 -0
  56. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils.egg-info/dependency_links.txt +0 -0
  57. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils.egg-info/entry_points.txt +0 -0
  58. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils.egg-info/requires.txt +0 -0
  59. {hfutils-0.3.5 → hfutils-0.3.6}/hfutils.egg-info/top_level.txt +0 -0
  60. {hfutils-0.3.5 → hfutils-0.3.6}/requirements-7z.txt +0 -0
  61. {hfutils-0.3.5 → hfutils-0.3.6}/requirements-build.txt +0 -0
  62. {hfutils-0.3.5 → hfutils-0.3.6}/requirements-doc.txt +0 -0
  63. {hfutils-0.3.5 → hfutils-0.3.6}/requirements-rar.txt +0 -0
  64. {hfutils-0.3.5 → hfutils-0.3.6}/requirements-test.txt +0 -0
  65. {hfutils-0.3.5 → hfutils-0.3.6}/requirements-transfer.txt +0 -0
  66. {hfutils-0.3.5 → hfutils-0.3.6}/requirements.txt +0 -0
  67. {hfutils-0.3.5 → hfutils-0.3.6}/setup.cfg +0 -0
  68. {hfutils-0.3.5 → hfutils-0.3.6}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hfutils
3
- Version: 0.3.5
3
+ Version: 0.3.6
4
4
  Summary: Useful utilities for huggingface
5
5
  Home-page: https://github.com/deepghs/hfutils
6
6
  Author: narugo1992
@@ -29,28 +29,6 @@ Requires-Dist: tzlocal
29
29
  Requires-Dist: natsort
30
30
  Requires-Dist: urlobject
31
31
  Requires-Dist: fsspec>=2024
32
- Provides-Extra: test
33
- Requires-Dist: coverage>=5; extra == "test"
34
- Requires-Dist: mock>=4.0.3; extra == "test"
35
- Requires-Dist: flake8~=3.5; extra == "test"
36
- Requires-Dist: testfixtures>=6.18.5; extra == "test"
37
- Requires-Dist: pytest~=6.2.5; extra == "test"
38
- Requires-Dist: pytest-cov~=3.0.0; extra == "test"
39
- Requires-Dist: pytest-mock~=3.6.1; extra == "test"
40
- Requires-Dist: pytest-xdist>=1.34.0; extra == "test"
41
- Requires-Dist: pytest-rerunfailures~=10.2; extra == "test"
42
- Requires-Dist: pytest-timeout~=2.0.2; extra == "test"
43
- Requires-Dist: pytest-benchmark~=3.4.0; extra == "test"
44
- Requires-Dist: easydict<2,>=1.7; extra == "test"
45
- Requires-Dist: testtools>=2; extra == "test"
46
- Requires-Dist: where>=1.0.2; extra == "test"
47
- Requires-Dist: responses>=0.20.0; extra == "test"
48
- Requires-Dist: natsort; extra == "test"
49
- Provides-Extra: 7z
50
- Requires-Dist: py7zr; extra == "7z"
51
- Provides-Extra: build
52
- Requires-Dist: pyinstaller<5,>=4.7; extra == "build"
53
- Requires-Dist: setuptools<70; extra == "build"
54
32
  Provides-Extra: doc
55
33
  Requires-Dist: Jinja2>=3.0.0; extra == "doc"
56
34
  Requires-Dist: sphinx>=3.2.0; extra == "doc"
@@ -71,8 +49,30 @@ Requires-Dist: ipykernel>=6.15; extra == "doc"
71
49
  Requires-Dist: py-cpuinfo>=8.0.0; extra == "doc"
72
50
  Requires-Dist: click>=7.0.0; extra == "doc"
73
51
  Requires-Dist: pandas; extra == "doc"
52
+ Provides-Extra: test
53
+ Requires-Dist: coverage>=5; extra == "test"
54
+ Requires-Dist: mock>=4.0.3; extra == "test"
55
+ Requires-Dist: flake8~=3.5; extra == "test"
56
+ Requires-Dist: testfixtures>=6.18.5; extra == "test"
57
+ Requires-Dist: pytest~=6.2.5; extra == "test"
58
+ Requires-Dist: pytest-cov~=3.0.0; extra == "test"
59
+ Requires-Dist: pytest-mock~=3.6.1; extra == "test"
60
+ Requires-Dist: pytest-xdist>=1.34.0; extra == "test"
61
+ Requires-Dist: pytest-rerunfailures~=10.2; extra == "test"
62
+ Requires-Dist: pytest-timeout~=2.0.2; extra == "test"
63
+ Requires-Dist: pytest-benchmark~=3.4.0; extra == "test"
64
+ Requires-Dist: easydict<2,>=1.7; extra == "test"
65
+ Requires-Dist: testtools>=2; extra == "test"
66
+ Requires-Dist: where>=1.0.2; extra == "test"
67
+ Requires-Dist: responses>=0.20.0; extra == "test"
68
+ Requires-Dist: natsort; extra == "test"
74
69
  Provides-Extra: transfer
75
70
  Requires-Dist: hf-transfer; extra == "transfer"
71
+ Provides-Extra: 7z
72
+ Requires-Dist: py7zr; extra == "7z"
73
+ Provides-Extra: build
74
+ Requires-Dist: pyinstaller<5,>=4.7; extra == "build"
75
+ Requires-Dist: setuptools<70; extra == "build"
76
76
  Provides-Extra: rar
77
77
  Requires-Dist: rarfile; extra == "rar"
78
78
 
@@ -7,7 +7,7 @@ Overview:
7
7
  __TITLE__ = 'hfutils'
8
8
 
9
9
  #: Version of this project.
10
- __VERSION__ = '0.3.5'
10
+ __VERSION__ = '0.3.6'
11
11
 
12
12
  #: Short description of the project, will be included in ``setup.py``.
13
13
  __DESCRIPTION__ = 'Useful utilities for huggingface'
@@ -1,5 +1,7 @@
1
1
  import json
2
2
  import os.path
3
+ import threading
4
+ from collections import defaultdict
3
5
  from typing import Optional, Dict, Union, List
4
6
 
5
7
  from huggingface_hub.file_download import http_get, hf_hub_url
@@ -21,6 +23,9 @@ class ArchiveStandaloneFileHashNotMatch(Exception):
21
23
  """
22
24
 
23
25
 
26
+ _HF_TAR_IDX_LOCKS = defaultdict(threading.Lock)
27
+
28
+
24
29
  def hf_tar_get_index(repo_id: str, archive_in_repo: str,
25
30
  repo_type: RepoTypeTyping = 'dataset', revision: str = 'main',
26
31
  idx_repo_id: Optional[str] = None, idx_file_in_repo: Optional[str] = None,
@@ -83,13 +88,18 @@ def hf_tar_get_index(repo_id: str, archive_in_repo: str,
83
88
  hf_client = get_hf_client(hf_token)
84
89
  body, _ = os.path.splitext(archive_in_repo)
85
90
  default_index_file = f'{body}.json'
86
- with open(hf_client.hf_hub_download(
87
- repo_id=idx_repo_id or repo_id,
88
- repo_type=idx_repo_type or repo_type,
89
- filename=idx_file_in_repo or default_index_file,
90
- revision=idx_revision or revision,
91
- ), 'r') as f:
92
- return json.load(f)
91
+ f_repo_id = idx_repo_id or repo_id
92
+ f_repo_type = idx_repo_type or repo_type
93
+ f_filename = idx_file_in_repo or default_index_file
94
+ f_revision = idx_revision or revision
95
+ with _HF_TAR_IDX_LOCKS[(f_repo_id, f_repo_type, f_filename, f_revision)]:
96
+ with open(hf_client.hf_hub_download(
97
+ repo_id=f_repo_id,
98
+ repo_type=f_repo_type,
99
+ filename=f_filename,
100
+ revision=f_revision,
101
+ ), 'r') as f:
102
+ return json.load(f)
93
103
 
94
104
 
95
105
  def hf_tar_list_files(repo_id: str, archive_in_repo: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hfutils
3
- Version: 0.3.5
3
+ Version: 0.3.6
4
4
  Summary: Useful utilities for huggingface
5
5
  Home-page: https://github.com/deepghs/hfutils
6
6
  Author: narugo1992
@@ -29,28 +29,6 @@ Requires-Dist: tzlocal
29
29
  Requires-Dist: natsort
30
30
  Requires-Dist: urlobject
31
31
  Requires-Dist: fsspec>=2024
32
- Provides-Extra: test
33
- Requires-Dist: coverage>=5; extra == "test"
34
- Requires-Dist: mock>=4.0.3; extra == "test"
35
- Requires-Dist: flake8~=3.5; extra == "test"
36
- Requires-Dist: testfixtures>=6.18.5; extra == "test"
37
- Requires-Dist: pytest~=6.2.5; extra == "test"
38
- Requires-Dist: pytest-cov~=3.0.0; extra == "test"
39
- Requires-Dist: pytest-mock~=3.6.1; extra == "test"
40
- Requires-Dist: pytest-xdist>=1.34.0; extra == "test"
41
- Requires-Dist: pytest-rerunfailures~=10.2; extra == "test"
42
- Requires-Dist: pytest-timeout~=2.0.2; extra == "test"
43
- Requires-Dist: pytest-benchmark~=3.4.0; extra == "test"
44
- Requires-Dist: easydict<2,>=1.7; extra == "test"
45
- Requires-Dist: testtools>=2; extra == "test"
46
- Requires-Dist: where>=1.0.2; extra == "test"
47
- Requires-Dist: responses>=0.20.0; extra == "test"
48
- Requires-Dist: natsort; extra == "test"
49
- Provides-Extra: 7z
50
- Requires-Dist: py7zr; extra == "7z"
51
- Provides-Extra: build
52
- Requires-Dist: pyinstaller<5,>=4.7; extra == "build"
53
- Requires-Dist: setuptools<70; extra == "build"
54
32
  Provides-Extra: doc
55
33
  Requires-Dist: Jinja2>=3.0.0; extra == "doc"
56
34
  Requires-Dist: sphinx>=3.2.0; extra == "doc"
@@ -71,8 +49,30 @@ Requires-Dist: ipykernel>=6.15; extra == "doc"
71
49
  Requires-Dist: py-cpuinfo>=8.0.0; extra == "doc"
72
50
  Requires-Dist: click>=7.0.0; extra == "doc"
73
51
  Requires-Dist: pandas; extra == "doc"
52
+ Provides-Extra: test
53
+ Requires-Dist: coverage>=5; extra == "test"
54
+ Requires-Dist: mock>=4.0.3; extra == "test"
55
+ Requires-Dist: flake8~=3.5; extra == "test"
56
+ Requires-Dist: testfixtures>=6.18.5; extra == "test"
57
+ Requires-Dist: pytest~=6.2.5; extra == "test"
58
+ Requires-Dist: pytest-cov~=3.0.0; extra == "test"
59
+ Requires-Dist: pytest-mock~=3.6.1; extra == "test"
60
+ Requires-Dist: pytest-xdist>=1.34.0; extra == "test"
61
+ Requires-Dist: pytest-rerunfailures~=10.2; extra == "test"
62
+ Requires-Dist: pytest-timeout~=2.0.2; extra == "test"
63
+ Requires-Dist: pytest-benchmark~=3.4.0; extra == "test"
64
+ Requires-Dist: easydict<2,>=1.7; extra == "test"
65
+ Requires-Dist: testtools>=2; extra == "test"
66
+ Requires-Dist: where>=1.0.2; extra == "test"
67
+ Requires-Dist: responses>=0.20.0; extra == "test"
68
+ Requires-Dist: natsort; extra == "test"
74
69
  Provides-Extra: transfer
75
70
  Requires-Dist: hf-transfer; extra == "transfer"
71
+ Provides-Extra: 7z
72
+ Requires-Dist: py7zr; extra == "7z"
73
+ Provides-Extra: build
74
+ Requires-Dist: pyinstaller<5,>=4.7; extra == "build"
75
+ Requires-Dist: setuptools<70; extra == "build"
76
76
  Provides-Extra: rar
77
77
  Requires-Dist: rarfile; extra == "rar"
78
78
 
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