diff --git a/setup.py b/setup.py index 7e1d263c13..35a321c336 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def get_version() -> str: # hf-xet version used in both install_requires and extras["hf_xet"] -HF_XET_VERSION = "hf-xet>=1.3.2,<2.0.0" +HF_XET_VERSION = "hf-xet>=1.4.2,<2.0.0" install_requires = [ "filelock>=3.10.0", diff --git a/src/huggingface_hub/_commit_api.py b/src/huggingface_hub/_commit_api.py index 793a7b8c54..c1607470e1 100644 --- a/src/huggingface_hub/_commit_api.py +++ b/src/huggingface_hub/_commit_api.py @@ -641,6 +641,7 @@ def token_refresher() -> tuple[str, int]: if len(all_paths_ops) > 0: all_paths = [str(op.path_or_fileobj) for op in all_paths_ops] + all_sha256s = [op.upload_info.sha256.hex() for op in all_paths_ops] upload_files( all_paths, xet_endpoint, @@ -649,10 +650,12 @@ def token_refresher() -> tuple[str, int]: progress_callback, repo_type, request_headers=xet_headers, + sha256s=all_sha256s, ) if len(all_bytes_ops) > 0: all_bytes = [op.path_or_fileobj for op in all_bytes_ops] + all_sha256s = [op.upload_info.sha256.hex() for op in all_bytes_ops] upload_bytes( all_bytes, xet_endpoint, @@ -661,6 +664,7 @@ def token_refresher() -> tuple[str, int]: progress_callback, repo_type, request_headers=xet_headers, + sha256s=all_sha256s, ) finally: diff --git a/tests/test_xet_upload.py b/tests/test_xet_upload.py index 5fa681f40d..015a4e023b 100644 --- a/tests/test_xet_upload.py +++ b/tests/test_xet_upload.py @@ -258,6 +258,7 @@ def test_request_headers_passed_to_upload_files(self, tmp_path): assert request_headers.get("x-custom-header") == "custom_value" assert request_headers.get("user-agent") == "test-agent" assert "authorization" not in request_headers + assert mock_upload_files.call_args.kwargs["sha256s"] == [addition.upload_info.sha256.hex()] def test_request_headers_passed_to_upload_bytes(self): """Test that headers (minus authorization) are passed as request_headers to hf_xet.upload_bytes.""" @@ -289,6 +290,7 @@ def test_request_headers_passed_to_upload_bytes(self): assert request_headers.get("x-custom-header") == "custom_value" assert request_headers.get("user-agent") == "test-agent" assert "authorization" not in request_headers + assert mock_upload_bytes.call_args.kwargs["sha256s"] == [addition.upload_info.sha256.hex()] def test_upload_folder(self, api, repo_url): repo_id = repo_url.repo_id