hfutils 0.4.1__tar.gz → 0.4.2__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 (75) hide show
  1. {hfutils-0.4.1/hfutils.egg-info → hfutils-0.4.2}/PKG-INFO +1 -1
  2. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/config/meta.py +1 -1
  3. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/fetch.py +12 -1
  4. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/local_fetch.py +12 -1
  5. {hfutils-0.4.1 → hfutils-0.4.2/hfutils.egg-info}/PKG-INFO +1 -1
  6. {hfutils-0.4.1 → hfutils-0.4.2}/LICENSE +0 -0
  7. {hfutils-0.4.1 → hfutils-0.4.2}/MANIFEST.in +0 -0
  8. {hfutils-0.4.1 → hfutils-0.4.2}/README.md +0 -0
  9. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/__init__.py +0 -0
  10. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/__main__.py +0 -0
  11. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/__init__.py +0 -0
  12. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/base.py +0 -0
  13. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/rar.py +0 -0
  14. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/sevenz.py +0 -0
  15. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/tar.py +0 -0
  16. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/zip.py +0 -0
  17. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/cache/__init__.py +0 -0
  18. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/cache/delete.py +0 -0
  19. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/config/__init__.py +0 -0
  20. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/__init__.py +0 -0
  21. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/base.py +0 -0
  22. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/cli.py +0 -0
  23. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/clone.py +0 -0
  24. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/dispatch.py +0 -0
  25. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/download.py +0 -0
  26. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/ils.py +0 -0
  27. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/index.py +0 -0
  28. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/ls.py +0 -0
  29. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/ls_repo.py +0 -0
  30. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/rollback.py +0 -0
  31. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/tree.py +0 -0
  32. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/upload.py +0 -0
  33. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/whoami.py +0 -0
  34. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/__init__.py +0 -0
  35. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/hash.py +0 -0
  36. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/make.py +0 -0
  37. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/validate.py +0 -0
  38. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/operate/__init__.py +0 -0
  39. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/operate/base.py +0 -0
  40. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/operate/download.py +0 -0
  41. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/operate/upload.py +0 -0
  42. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/operate/validate.py +0 -0
  43. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/repository/__init__.py +0 -0
  44. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/repository/base.py +0 -0
  45. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/repository/clone.py +0 -0
  46. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/repository/rollback.py +0 -0
  47. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/__init__.py +0 -0
  48. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/archive.py +0 -0
  49. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/binary.py +0 -0
  50. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/data.py +0 -0
  51. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/download.py +0 -0
  52. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/irregular_repo.json +0 -0
  53. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/logging.py +0 -0
  54. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/model.py +0 -0
  55. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/number.py +0 -0
  56. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/path.py +0 -0
  57. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/session.py +0 -0
  58. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/temp.py +0 -0
  59. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/tqdm_.py +0 -0
  60. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/type_.py +0 -0
  61. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/walk.py +0 -0
  62. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils.egg-info/SOURCES.txt +0 -0
  63. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils.egg-info/dependency_links.txt +0 -0
  64. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils.egg-info/entry_points.txt +0 -0
  65. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils.egg-info/requires.txt +0 -0
  66. {hfutils-0.4.1 → hfutils-0.4.2}/hfutils.egg-info/top_level.txt +0 -0
  67. {hfutils-0.4.1 → hfutils-0.4.2}/requirements-7z.txt +0 -0
  68. {hfutils-0.4.1 → hfutils-0.4.2}/requirements-build.txt +0 -0
  69. {hfutils-0.4.1 → hfutils-0.4.2}/requirements-doc.txt +0 -0
  70. {hfutils-0.4.1 → hfutils-0.4.2}/requirements-rar.txt +0 -0
  71. {hfutils-0.4.1 → hfutils-0.4.2}/requirements-test.txt +0 -0
  72. {hfutils-0.4.1 → hfutils-0.4.2}/requirements-transfer.txt +0 -0
  73. {hfutils-0.4.1 → hfutils-0.4.2}/requirements.txt +0 -0
  74. {hfutils-0.4.1 → hfutils-0.4.2}/setup.cfg +0 -0
  75. {hfutils-0.4.1 → hfutils-0.4.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hfutils
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: Useful utilities for huggingface
5
5
  Home-page: https://github.com/deepghs/hfutils
6
6
  Author: narugo1992
@@ -7,7 +7,7 @@ Overview:
7
7
  __TITLE__ = 'hfutils'
8
8
 
9
9
  #: Version of this project.
10
- __VERSION__ = '0.4.1'
10
+ __VERSION__ = '0.4.2'
11
11
 
12
12
  #: Short description of the project, will be included in ``setup.py``.
13
13
  __DESCRIPTION__ = 'Useful utilities for huggingface'
@@ -438,7 +438,7 @@ def hf_tar_file_download(repo_id: str, archive_in_repo: str, file_in_archive: st
438
438
  idx_repo_type: Optional[RepoTypeTyping] = None, idx_revision: Optional[str] = None,
439
439
  proxies: Optional[Dict] = None, user_agent: Union[Dict, str, None] = None,
440
440
  headers: Optional[Dict[str, str]] = None, endpoint: Optional[str] = None,
441
- hf_token: Optional[str] = None):
441
+ force_download: bool = False, hf_token: Optional[str] = None):
442
442
  """
443
443
  Download a file from a tar archive file in a Hugging Face repository.
444
444
 
@@ -470,6 +470,10 @@ def hf_tar_file_download(repo_id: str, archive_in_repo: str, file_in_archive: st
470
470
  :type headers: Dict[str, str], optional
471
471
  :param endpoint: The Hugging Face API endpoint.
472
472
  :type endpoint: str, optional
473
+ :param force_download: Force download the file to destination path.
474
+ Defualt to `False`, downloading will be skipped if the local file
475
+ is fully matched with expected file.
476
+ :type force_download: bool
473
477
  :param hf_token: The Hugging Face access token.
474
478
  :type hf_token: str, optional
475
479
  :raises FileNotFoundError: Raise this when file not exist in tar archive.
@@ -533,6 +537,13 @@ def hf_tar_file_download(repo_id: str, archive_in_repo: str, file_in_archive: st
533
537
  end_bytes = info['offset'] + info['size'] - 1
534
538
  headers['Range'] = f'bytes={start_bytes}-{end_bytes}'
535
539
 
540
+ if not force_download and os.path.exists(local_file) and \
541
+ os.path.isfile(local_file) and os.path.getsize(local_file) == info['size']:
542
+ _expected_sha256 = info.get('sha256')
543
+ if not _expected_sha256 or _f_sha256(local_file) == _expected_sha256:
544
+ # file already ready, no need to download it again
545
+ return
546
+
536
547
  if os.path.dirname(local_file):
537
548
  os.makedirs(os.path.dirname(local_file), exist_ok=True)
538
549
  try:
@@ -171,7 +171,7 @@ def tar_file_size(archive_file: str, file_in_archive: str, idx_file: Optional[st
171
171
 
172
172
 
173
173
  def tar_file_download(archive_file: str, file_in_archive: str, local_file: str,
174
- idx_file: Optional[str] = None, chunk_size: int = 1 << 20):
174
+ idx_file: Optional[str] = None, chunk_size: int = 1 << 20, force_download: bool = False):
175
175
  """
176
176
  Extract and download a specific file from the tar archive to a local file.
177
177
 
@@ -190,6 +190,10 @@ def tar_file_download(archive_file: str, file_in_archive: str, local_file: str,
190
190
  :type idx_file: Optional[str]
191
191
  :param chunk_size: The size of chunks to read and write, in bytes. Default is 1MB.
192
192
  :type chunk_size: int
193
+ :param force_download: Force download the file to destination path.
194
+ Defualt to `False`, downloading will be skipped if the local file
195
+ is fully matched with expected file.
196
+ :type force_download: bool
193
197
 
194
198
  :raises FileNotFoundError: If the specified file is not found in the archive.
195
199
  :raises ArchiveStandaloneFileIncompleteDownload: If the downloaded file size doesn't match the expected size.
@@ -212,6 +216,13 @@ def tar_file_download(archive_file: str, file_in_archive: str, local_file: str,
212
216
 
213
217
  info = files[_n_path(file_in_archive)]
214
218
 
219
+ if not force_download and os.path.exists(local_file) and \
220
+ os.path.isfile(local_file) and os.path.getsize(local_file) == info['size']:
221
+ _expected_sha256 = info.get('sha256')
222
+ if not _expected_sha256 or _f_sha256(local_file) == _expected_sha256:
223
+ # file already ready, no need to download it again
224
+ return
225
+
215
226
  if os.path.dirname(local_file):
216
227
  os.makedirs(os.path.dirname(local_file), exist_ok=True)
217
228
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hfutils
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: Useful utilities for huggingface
5
5
  Home-page: https://github.com/deepghs/hfutils
6
6
  Author: narugo1992
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