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.
- {hfutils-0.4.1/hfutils.egg-info → hfutils-0.4.2}/PKG-INFO +1 -1
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/config/meta.py +1 -1
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/fetch.py +12 -1
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/local_fetch.py +12 -1
- {hfutils-0.4.1 → hfutils-0.4.2/hfutils.egg-info}/PKG-INFO +1 -1
- {hfutils-0.4.1 → hfutils-0.4.2}/LICENSE +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/MANIFEST.in +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/README.md +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/__init__.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/__main__.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/__init__.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/base.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/rar.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/sevenz.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/tar.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/archive/zip.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/cache/__init__.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/cache/delete.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/config/__init__.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/__init__.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/base.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/cli.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/clone.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/dispatch.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/download.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/ils.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/index.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/ls.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/ls_repo.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/rollback.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/tree.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/upload.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/entry/whoami.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/__init__.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/hash.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/make.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/index/validate.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/operate/__init__.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/operate/base.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/operate/download.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/operate/upload.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/operate/validate.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/repository/__init__.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/repository/base.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/repository/clone.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/repository/rollback.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/__init__.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/archive.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/binary.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/data.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/download.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/irregular_repo.json +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/logging.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/model.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/number.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/path.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/session.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/temp.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/tqdm_.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/type_.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils/utils/walk.py +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils.egg-info/SOURCES.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils.egg-info/dependency_links.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils.egg-info/entry_points.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils.egg-info/requires.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/hfutils.egg-info/top_level.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/requirements-7z.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/requirements-build.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/requirements-doc.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/requirements-rar.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/requirements-test.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/requirements-transfer.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/requirements.txt +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/setup.cfg +0 -0
- {hfutils-0.4.1 → hfutils-0.4.2}/setup.py +0 -0
|
@@ -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:
|
|
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
|
|
File without changes
|
|
File without changes
|