huggingface-hub 0.22.0__tar.gz → 0.22.0rc0__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.
Potentially problematic release.
This version of huggingface-hub might be problematic. Click here for more details.
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/PKG-INFO +1 -1
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/__init__.py +1 -1
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/file_download.py +71 -78
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/hf_file_system.py +3 -77
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/hub_mixin.py +1 -6
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub.egg-info/PKG-INFO +1 -1
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/LICENSE +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/MANIFEST.in +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/README.md +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/pyproject.toml +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/setup.cfg +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/setup.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_commit_api.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_commit_scheduler.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_inference_endpoints.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_login.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_multi_commits.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_snapshot_download.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_space_api.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_tensorboard_logger.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_webhooks_payload.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_webhooks_server.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/__init__.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/_cli_utils.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/delete_cache.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/download.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/env.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/huggingface_cli.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/lfs.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/scan_cache.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/upload.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/user.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/community.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/constants.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/errors.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/fastai_utils.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/hf_api.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/__init__.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_client.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_common.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/__init__.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/_async_client.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/__init__.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/audio_classification.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/audio_to_audio.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/base.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/chat_completion.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/depth_estimation.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/document_question_answering.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/feature_extraction.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/fill_mask.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/image_classification.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/image_segmentation.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/image_to_image.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/image_to_text.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/object_detection.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/question_answering.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/sentence_similarity.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/summarization.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/table_question_answering.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/text2text_generation.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/text_classification.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/text_generation.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/text_to_audio.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/text_to_image.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/token_classification.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/translation.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/video_classification.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/visual_question_answering.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/zero_shot_classification.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_templating.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_types.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference_api.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/keras_mixin.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/lfs.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/repocard.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/repocard_data.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/repository.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/serialization/__init__.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/serialization/_base.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/serialization/_numpy.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/serialization/_tensorflow.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/serialization/_torch.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/templates/datasetcard_template.md +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/templates/modelcard_template.md +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/__init__.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_cache_assets.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_cache_manager.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_chunk_utils.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_datetime.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_deprecation.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_errors.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_experimental.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_fixes.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_git_credential.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_headers.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_hf_folder.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_http.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_pagination.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_paths.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_runtime.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_safetensors.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_subprocess.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_telemetry.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_token.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_typing.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_validators.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/endpoint_helpers.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/insecure_hashlib.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/logging.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/sha.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/tqdm.py +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub.egg-info/SOURCES.txt +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub.egg-info/dependency_links.txt +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub.egg-info/entry_points.txt +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub.egg-info/requires.txt +0 -0
- {huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: huggingface_hub
|
|
3
|
-
Version: 0.22.
|
|
3
|
+
Version: 0.22.0rc0
|
|
4
4
|
Summary: Client library to download and publish models, datasets and other repos on the huggingface.co hub
|
|
5
5
|
Home-page: https://github.com/huggingface/huggingface_hub
|
|
6
6
|
Author: Hugging Face, Inc.
|
|
@@ -404,7 +404,6 @@ def http_get(
|
|
|
404
404
|
expected_size: Optional[int] = None,
|
|
405
405
|
displayed_filename: Optional[str] = None,
|
|
406
406
|
_nb_retries: int = 5,
|
|
407
|
-
_tqdm_bar: Optional[tqdm] = None,
|
|
408
407
|
) -> None:
|
|
409
408
|
"""
|
|
410
409
|
Download a remote file. Do not gobble up errors, and will return errors tailored to the Hugging Face Hub.
|
|
@@ -484,90 +483,84 @@ def http_get(
|
|
|
484
483
|
)
|
|
485
484
|
|
|
486
485
|
# Stream file to buffer
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
486
|
+
with tqdm(
|
|
487
|
+
unit="B",
|
|
488
|
+
unit_scale=True,
|
|
489
|
+
total=total,
|
|
490
|
+
initial=resume_size,
|
|
491
|
+
desc=displayed_filename,
|
|
492
|
+
disable=True if (logger.getEffectiveLevel() == logging.NOTSET) else None,
|
|
493
|
+
# ^ set `disable=None` rather than `disable=False` by default to disable progress bar when no TTY attached
|
|
494
|
+
# see https://github.com/huggingface/huggingface_hub/pull/2000
|
|
495
|
+
) as progress:
|
|
496
|
+
if hf_transfer and total is not None and total > 5 * DOWNLOAD_CHUNK_SIZE:
|
|
497
|
+
supports_callback = "callback" in inspect.signature(hf_transfer.download).parameters
|
|
498
|
+
if not supports_callback:
|
|
499
|
+
warnings.warn(
|
|
500
|
+
"You are using an outdated version of `hf_transfer`. "
|
|
501
|
+
"Consider upgrading to latest version to enable progress bars "
|
|
502
|
+
"using `pip install -U hf_transfer`."
|
|
503
|
+
)
|
|
504
|
+
try:
|
|
505
|
+
hf_transfer.download(
|
|
506
|
+
url=url,
|
|
507
|
+
filename=temp_file.name,
|
|
508
|
+
max_files=HF_TRANSFER_CONCURRENCY,
|
|
509
|
+
chunk_size=DOWNLOAD_CHUNK_SIZE,
|
|
510
|
+
headers=headers,
|
|
511
|
+
parallel_failures=3,
|
|
512
|
+
max_retries=5,
|
|
513
|
+
**({"callback": progress.update} if supports_callback else {}),
|
|
514
|
+
)
|
|
515
|
+
except Exception as e:
|
|
516
|
+
raise RuntimeError(
|
|
517
|
+
"An error occurred while downloading using `hf_transfer`. Consider"
|
|
518
|
+
" disabling HF_HUB_ENABLE_HF_TRANSFER for better error handling."
|
|
519
|
+
) from e
|
|
520
|
+
if not supports_callback:
|
|
521
|
+
progress.update(total)
|
|
522
|
+
if expected_size is not None and expected_size != os.path.getsize(temp_file.name):
|
|
523
|
+
raise EnvironmentError(
|
|
524
|
+
consistency_error_message.format(
|
|
525
|
+
actual_size=os.path.getsize(temp_file.name),
|
|
526
|
+
)
|
|
527
|
+
)
|
|
528
|
+
return
|
|
529
|
+
new_resume_size = resume_size
|
|
508
530
|
try:
|
|
509
|
-
|
|
531
|
+
for chunk in r.iter_content(chunk_size=DOWNLOAD_CHUNK_SIZE):
|
|
532
|
+
if chunk: # filter out keep-alive new chunks
|
|
533
|
+
progress.update(len(chunk))
|
|
534
|
+
temp_file.write(chunk)
|
|
535
|
+
new_resume_size += len(chunk)
|
|
536
|
+
# Some data has been downloaded from the server so we reset the number of retries.
|
|
537
|
+
_nb_retries = 5
|
|
538
|
+
except (requests.ConnectionError, requests.ReadTimeout) as e:
|
|
539
|
+
# If ConnectionError (SSLError) or ReadTimeout happen while streaming data from the server, it is most likely
|
|
540
|
+
# a transient error (network outage?). We log a warning message and try to resume the download a few times
|
|
541
|
+
# before giving up. Tre retry mechanism is basic but should be enough in most cases.
|
|
542
|
+
if _nb_retries <= 0:
|
|
543
|
+
logger.warning("Error while downloading from %s: %s\nMax retries exceeded.", url, str(e))
|
|
544
|
+
raise
|
|
545
|
+
logger.warning("Error while downloading from %s: %s\nTrying to resume download...", url, str(e))
|
|
546
|
+
time.sleep(1)
|
|
547
|
+
reset_sessions() # In case of SSLError it's best to reset the shared requests.Session objects
|
|
548
|
+
return http_get(
|
|
510
549
|
url=url,
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
headers=
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
**({"callback": progress.update} if supports_callback else {}),
|
|
550
|
+
temp_file=temp_file,
|
|
551
|
+
proxies=proxies,
|
|
552
|
+
resume_size=new_resume_size,
|
|
553
|
+
headers=initial_headers,
|
|
554
|
+
expected_size=expected_size,
|
|
555
|
+
_nb_retries=_nb_retries - 1,
|
|
518
556
|
)
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
"An error occurred while downloading using `hf_transfer`. Consider"
|
|
522
|
-
" disabling HF_HUB_ENABLE_HF_TRANSFER for better error handling."
|
|
523
|
-
) from e
|
|
524
|
-
if not supports_callback:
|
|
525
|
-
progress.update(total)
|
|
526
|
-
if expected_size is not None and expected_size != os.path.getsize(temp_file.name):
|
|
557
|
+
|
|
558
|
+
if expected_size is not None and expected_size != temp_file.tell():
|
|
527
559
|
raise EnvironmentError(
|
|
528
560
|
consistency_error_message.format(
|
|
529
|
-
actual_size=
|
|
561
|
+
actual_size=temp_file.tell(),
|
|
530
562
|
)
|
|
531
563
|
)
|
|
532
|
-
return
|
|
533
|
-
new_resume_size = resume_size
|
|
534
|
-
try:
|
|
535
|
-
for chunk in r.iter_content(chunk_size=DOWNLOAD_CHUNK_SIZE):
|
|
536
|
-
if chunk: # filter out keep-alive new chunks
|
|
537
|
-
progress.update(len(chunk))
|
|
538
|
-
temp_file.write(chunk)
|
|
539
|
-
new_resume_size += len(chunk)
|
|
540
|
-
# Some data has been downloaded from the server so we reset the number of retries.
|
|
541
|
-
_nb_retries = 5
|
|
542
|
-
except (requests.ConnectionError, requests.ReadTimeout) as e:
|
|
543
|
-
# If ConnectionError (SSLError) or ReadTimeout happen while streaming data from the server, it is most likely
|
|
544
|
-
# a transient error (network outage?). We log a warning message and try to resume the download a few times
|
|
545
|
-
# before giving up. Tre retry mechanism is basic but should be enough in most cases.
|
|
546
|
-
if _nb_retries <= 0:
|
|
547
|
-
logger.warning("Error while downloading from %s: %s\nMax retries exceeded.", url, str(e))
|
|
548
|
-
raise
|
|
549
|
-
logger.warning("Error while downloading from %s: %s\nTrying to resume download...", url, str(e))
|
|
550
|
-
time.sleep(1)
|
|
551
|
-
reset_sessions() # In case of SSLError it's best to reset the shared requests.Session objects
|
|
552
|
-
return http_get(
|
|
553
|
-
url=url,
|
|
554
|
-
temp_file=temp_file,
|
|
555
|
-
proxies=proxies,
|
|
556
|
-
resume_size=new_resume_size,
|
|
557
|
-
headers=initial_headers,
|
|
558
|
-
expected_size=expected_size,
|
|
559
|
-
_nb_retries=_nb_retries - 1,
|
|
560
|
-
_tqdm_bar=_tqdm_bar,
|
|
561
|
-
)
|
|
562
|
-
|
|
563
|
-
progress.close()
|
|
564
|
-
|
|
565
|
-
if expected_size is not None and expected_size != temp_file.tell():
|
|
566
|
-
raise EnvironmentError(
|
|
567
|
-
consistency_error_message.format(
|
|
568
|
-
actual_size=temp_file.tell(),
|
|
569
|
-
)
|
|
570
|
-
)
|
|
571
564
|
|
|
572
565
|
|
|
573
566
|
@validate_hf_hub_args
|
|
@@ -6,24 +6,15 @@ from collections import deque
|
|
|
6
6
|
from dataclasses import dataclass, field
|
|
7
7
|
from datetime import datetime
|
|
8
8
|
from itertools import chain
|
|
9
|
-
from pathlib import Path
|
|
10
9
|
from typing import Any, Dict, List, NoReturn, Optional, Tuple, Union
|
|
11
10
|
from urllib.parse import quote, unquote
|
|
12
11
|
|
|
13
12
|
import fsspec
|
|
14
|
-
from fsspec.callbacks import _DEFAULT_CALLBACK, NoOpCallback, TqdmCallback
|
|
15
|
-
from fsspec.utils import isfilelike
|
|
16
13
|
from requests import Response
|
|
17
14
|
|
|
18
15
|
from ._commit_api import CommitOperationCopy, CommitOperationDelete
|
|
19
|
-
from .constants import
|
|
20
|
-
|
|
21
|
-
ENDPOINT,
|
|
22
|
-
REPO_TYPE_MODEL,
|
|
23
|
-
REPO_TYPES_MAPPING,
|
|
24
|
-
REPO_TYPES_URL_PREFIXES,
|
|
25
|
-
)
|
|
26
|
-
from .file_download import hf_hub_url, http_get
|
|
16
|
+
from .constants import DEFAULT_REVISION, ENDPOINT, REPO_TYPE_MODEL, REPO_TYPES_MAPPING, REPO_TYPES_URL_PREFIXES
|
|
17
|
+
from .file_download import hf_hub_url
|
|
27
18
|
from .hf_api import HfApi, LastCommitInfo, RepoFile
|
|
28
19
|
from .utils import (
|
|
29
20
|
EntryNotFoundError,
|
|
@@ -600,58 +591,6 @@ class HfFileSystem(fsspec.AbstractFileSystem):
|
|
|
600
591
|
url = url.replace("/resolve/", "/tree/", 1)
|
|
601
592
|
return url
|
|
602
593
|
|
|
603
|
-
def get_file(self, rpath, lpath, callback=_DEFAULT_CALLBACK, outfile=None, **kwargs) -> None:
|
|
604
|
-
"""Copy single remote file to local."""
|
|
605
|
-
revision = kwargs.get("revision")
|
|
606
|
-
unhandled_kwargs = set(kwargs.keys()) - {"revision"}
|
|
607
|
-
if not isinstance(callback, (NoOpCallback, TqdmCallback)) or len(unhandled_kwargs) > 0:
|
|
608
|
-
# for now, let's not handle custom callbacks
|
|
609
|
-
# and let's not handle custom kwargs
|
|
610
|
-
return super().get_file(rpath, lpath, callback=callback, outfile=outfile, **kwargs)
|
|
611
|
-
|
|
612
|
-
# Taken from https://github.com/fsspec/filesystem_spec/blob/47b445ae4c284a82dd15e0287b1ffc410e8fc470/fsspec/spec.py#L883
|
|
613
|
-
if isfilelike(lpath):
|
|
614
|
-
outfile = lpath
|
|
615
|
-
elif self.isdir(rpath):
|
|
616
|
-
os.makedirs(lpath, exist_ok=True)
|
|
617
|
-
return None
|
|
618
|
-
|
|
619
|
-
if isinstance(lpath, (str, Path)): # otherwise, let's assume it's a file-like object
|
|
620
|
-
os.makedirs(os.path.dirname(lpath), exist_ok=True)
|
|
621
|
-
|
|
622
|
-
# Open file if not already open
|
|
623
|
-
close_file = False
|
|
624
|
-
if outfile is None:
|
|
625
|
-
outfile = open(lpath, "wb")
|
|
626
|
-
close_file = True
|
|
627
|
-
initial_pos = outfile.tell()
|
|
628
|
-
|
|
629
|
-
# Custom implementation of `get_file` to use `http_get`.
|
|
630
|
-
resolve_remote_path = self.resolve_path(rpath, revision=revision)
|
|
631
|
-
expected_size = self.info(rpath, revision=revision)["size"]
|
|
632
|
-
callback.set_size(expected_size)
|
|
633
|
-
try:
|
|
634
|
-
http_get(
|
|
635
|
-
url=hf_hub_url(
|
|
636
|
-
repo_id=resolve_remote_path.repo_id,
|
|
637
|
-
revision=resolve_remote_path.revision,
|
|
638
|
-
filename=resolve_remote_path.path_in_repo,
|
|
639
|
-
repo_type=resolve_remote_path.repo_type,
|
|
640
|
-
endpoint=self.endpoint,
|
|
641
|
-
),
|
|
642
|
-
temp_file=outfile,
|
|
643
|
-
displayed_filename=rpath,
|
|
644
|
-
expected_size=expected_size,
|
|
645
|
-
resume_size=0,
|
|
646
|
-
headers=self._api._build_hf_headers(),
|
|
647
|
-
_tqdm_bar=callback.tqdm if isinstance(callback, TqdmCallback) else None,
|
|
648
|
-
)
|
|
649
|
-
outfile.seek(initial_pos)
|
|
650
|
-
finally:
|
|
651
|
-
# Close file only if we opened it ourselves
|
|
652
|
-
if close_file:
|
|
653
|
-
outfile.close()
|
|
654
|
-
|
|
655
594
|
@property
|
|
656
595
|
def transaction(self):
|
|
657
596
|
"""A context within which files are committed together upon exit
|
|
@@ -679,7 +618,6 @@ class HfFileSystemFile(fsspec.spec.AbstractBufferedFile):
|
|
|
679
618
|
raise FileNotFoundError(
|
|
680
619
|
f"{e}.\nMake sure the repository and revision exist before writing data."
|
|
681
620
|
) from e
|
|
682
|
-
raise
|
|
683
621
|
super().__init__(fs, self.resolved_path.unresolve(), **kwargs)
|
|
684
622
|
self.fs: HfFileSystem
|
|
685
623
|
|
|
@@ -729,18 +667,6 @@ class HfFileSystemFile(fsspec.spec.AbstractBufferedFile):
|
|
|
729
667
|
path=self.resolved_path.unresolve(),
|
|
730
668
|
)
|
|
731
669
|
|
|
732
|
-
def read(self, length=-1):
|
|
733
|
-
"""Read remote file.
|
|
734
|
-
|
|
735
|
-
If `length` is not provided or is -1, the entire file is downloaded and read. On POSIX systems and if
|
|
736
|
-
`hf_transfer` is not enabled, the file is loaded in memory directly. Otherwise, the file is downloaded to a
|
|
737
|
-
temporary file and read from there.
|
|
738
|
-
"""
|
|
739
|
-
if self.mode == "rb" and (length is None or length == -1) and self.loc == 0:
|
|
740
|
-
with self.fs.open(self.path, "rb", block_size=0) as f: # block_size=0 enables fast streaming
|
|
741
|
-
return f.read()
|
|
742
|
-
return super().read(length)
|
|
743
|
-
|
|
744
670
|
def url(self) -> str:
|
|
745
671
|
return self.fs.url(self.path)
|
|
746
672
|
|
|
@@ -769,7 +695,7 @@ class HfFileSystemStreamFile(fsspec.spec.AbstractBufferedFile):
|
|
|
769
695
|
raise FileNotFoundError(
|
|
770
696
|
f"{e}.\nMake sure the repository and revision exist before writing data."
|
|
771
697
|
) from e
|
|
772
|
-
# avoid an
|
|
698
|
+
# avoid an unecessary .info() call to instantiate .details
|
|
773
699
|
self.details = {"name": self.resolved_path.unresolve(), "size": None}
|
|
774
700
|
super().__init__(
|
|
775
701
|
fs, self.resolved_path.unresolve(), mode=mode, block_size=block_size, cache_type=cache_type, **kwargs
|
|
@@ -262,12 +262,6 @@ class ModelHubMixin:
|
|
|
262
262
|
save_directory = Path(save_directory)
|
|
263
263
|
save_directory.mkdir(parents=True, exist_ok=True)
|
|
264
264
|
|
|
265
|
-
# Remove config.json if already exists. After `_save_pretrained` we don't want to overwrite config.json
|
|
266
|
-
# as it might have been saved by the custom `_save_pretrained` already. However we do want to overwrite
|
|
267
|
-
# an existing config.json if it was not saved by `_save_pretrained`.
|
|
268
|
-
config_path = save_directory / CONFIG_NAME
|
|
269
|
-
config_path.unlink(missing_ok=True)
|
|
270
|
-
|
|
271
265
|
# save model weights/files (framework-specific)
|
|
272
266
|
self._save_pretrained(save_directory)
|
|
273
267
|
|
|
@@ -277,6 +271,7 @@ class ModelHubMixin:
|
|
|
277
271
|
if config is not None:
|
|
278
272
|
if is_dataclass(config):
|
|
279
273
|
config = asdict(config) # type: ignore[arg-type]
|
|
274
|
+
config_path = save_directory / CONFIG_NAME
|
|
280
275
|
if not config_path.exists():
|
|
281
276
|
config_str = json.dumps(config, sort_keys=True, indent=2)
|
|
282
277
|
config_path.write_text(config_str)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: huggingface-hub
|
|
3
|
-
Version: 0.22.
|
|
3
|
+
Version: 0.22.0rc0
|
|
4
4
|
Summary: Client library to download and publish models, datasets and other repos on the huggingface.co hub
|
|
5
5
|
Home-page: https://github.com/huggingface/huggingface_hub
|
|
6
6
|
Author: Hugging Face, Inc.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_commit_scheduler.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_inference_endpoints.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_snapshot_download.py
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_tensorboard_logger.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_webhooks_payload.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/_webhooks_server.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/__init__.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/_cli_utils.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/delete_cache.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/download.py
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/huggingface_cli.py
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/commands/scan_cache.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/__init__.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_client.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_common.py
RENAMED
|
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
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_templating.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/inference/_types.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/serialization/__init__.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/serialization/_base.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/serialization/_numpy.py
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/serialization/_torch.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_cache_assets.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_cache_manager.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_chunk_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_deprecation.py
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_experimental.py
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_git_credential.py
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_hf_folder.py
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_pagination.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_safetensors.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_subprocess.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_telemetry.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/_validators.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/endpoint_helpers.py
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub/utils/insecure_hashlib.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub.egg-info/requires.txt
RENAMED
|
File without changes
|
{huggingface_hub-0.22.0 → huggingface_hub-0.22.0rc0}/src/huggingface_hub.egg-info/top_level.txt
RENAMED
|
File without changes
|