-
Notifications
You must be signed in to change notification settings - Fork 817
Use git xet transfer to check if xet is enabled #3381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0c2026a
use git xet transfer to check if xet is enabled
hanouticelina f4b873b
nit
hanouticelina e3fa593
fix syntax
hanouticelina 76025ab
fix
hanouticelina 63176d2
Apply suggestions from code review
hanouticelina bf8db9d
fix docstring
hanouticelina 39636db
Merge branch 'use-xet-transfer-in-lfs-calls' of github.com:huggingfac…
hanouticelina da3ddf9
add transfers to docstring
hanouticelina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
from __future__ import annotations | ||
|
||
import inspect | ||
import io | ||
import json | ||
import re | ||
import struct | ||
|
@@ -46,7 +45,7 @@ | |
Union, | ||
overload, | ||
) | ||
from urllib.parse import quote, unquote | ||
from urllib.parse import quote | ||
|
||
import requests | ||
from requests.exceptions import HTTPError | ||
|
@@ -62,8 +61,7 @@ | |
_fetch_files_to_copy, | ||
_fetch_upload_modes, | ||
_prepare_commit_payload, | ||
_upload_lfs_files, | ||
_upload_xet_files, | ||
_upload_files, | ||
_warn_on_overwriting_operations, | ||
) | ||
from ._inference_endpoints import InferenceEndpoint, InferenceEndpointType | ||
|
@@ -132,13 +130,8 @@ | |
validate_hf_hub_args, | ||
) | ||
from .utils import tqdm as hf_tqdm | ||
from .utils._auth import ( | ||
_get_token_from_environment, | ||
_get_token_from_file, | ||
_get_token_from_google_colab, | ||
) | ||
from .utils._auth import _get_token_from_environment, _get_token_from_file, _get_token_from_google_colab | ||
from .utils._deprecation import _deprecate_arguments, _deprecate_method | ||
from .utils._runtime import is_xet_available | ||
from .utils._typing import CallableT | ||
from .utils.endpoint_helpers import _is_emission_within_threshold | ||
|
||
|
@@ -4502,6 +4495,10 @@ def preupload_lfs_files( | |
f"Skipped upload for {len(new_lfs_additions) - len(new_lfs_additions_to_upload)} LFS file(s) " | ||
"(ignored by gitignore file)." | ||
) | ||
# If no LFS files remain to upload, keep previous behavior and log explicitly | ||
if len(new_lfs_additions_to_upload) == 0: | ||
logger.debug("No LFS files to upload.") | ||
return | ||
# Prepare upload parameters | ||
upload_kwargs = { | ||
"additions": new_lfs_additions_to_upload, | ||
|
@@ -4514,32 +4511,7 @@ def preupload_lfs_files( | |
# PR (i.e. `revision`). | ||
"revision": revision if not create_pr else None, | ||
} | ||
# Upload files using Xet protocol if all of the following are true: | ||
# - xet is enabled for the repo, | ||
# - the files are provided as str or paths objects, | ||
# - the library is installed. | ||
# Otherwise, default back to LFS. | ||
xet_enabled = self.repo_info( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all of this to remove this call 😄 |
||
repo_id=repo_id, | ||
repo_type=repo_type, | ||
revision=unquote(revision) if revision is not None else revision, | ||
expand="xetEnabled", | ||
token=token, | ||
).xet_enabled | ||
has_buffered_io_data = any( | ||
isinstance(addition.path_or_fileobj, io.BufferedIOBase) for addition in new_lfs_additions_to_upload | ||
) | ||
if xet_enabled and not has_buffered_io_data and is_xet_available(): | ||
logger.debug("Uploading files using Xet Storage..") | ||
_upload_xet_files(**upload_kwargs, create_pr=create_pr) # type: ignore [arg-type] | ||
else: | ||
if xet_enabled and is_xet_available(): | ||
if has_buffered_io_data: | ||
logger.warning( | ||
"Uploading files as a binary IO buffer is not supported by Xet Storage. " | ||
"Falling back to HTTP upload." | ||
) | ||
_upload_lfs_files(**upload_kwargs, num_threads=num_threads) # type: ignore [arg-type] | ||
_upload_files(**upload_kwargs, num_threads=num_threads, create_pr=create_pr) # type: ignore [arg-type] | ||
for addition in new_lfs_additions_to_upload: | ||
addition._is_uploaded = True | ||
if free_memory: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.