Skip to content

Commit ff38e6e

Browse files
Wauplinclaude
andcommitted
Fix CI: huggingface_hub 1.20.0 commit op equality + pytest parametrize
Two unrelated CI failures: 1. tests/test_hub.py::test_delete_from_hub Since huggingface_hub 1.20.0 (huggingface/huggingface_hub#4331), `UploadInfo` is no longer a dataclass and `CommitOperationAdd`/`CommitOperationDelete` no longer implement value equality. Two operations with identical content are therefore not equal anymore, breaking the `operations == expected_operations` assertion. Compare operations attribute by attribute instead. This is a breaking change in huggingface_hub that will not be reverted upstream. 2. tests/test_load.py collection error A trailing comma in `@pytest.mark.parametrize("stream_from_cache, ", ...)` made recent pytest parse it as two argnames, raising `TypeError: object of type 'bool' has no len()` at collection time. Drop the trailing comma. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 06fcc08 commit ff38e6e

2 files changed

Lines changed: 25 additions & 19 deletions

File tree

tests/test_hub.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,27 @@ def test_delete_from_hub(temporary_repo, hf_api, hf_token, csv_path, ci_hub_conf
6666
assert mock_method.called
6767
assert mock_method.call_args.kwargs.get("commit_message") == "Delete 'dogs' config"
6868
assert mock_method.call_args.kwargs.get("create_pr")
69-
expected_operations = [
70-
CommitOperationDelete(path_in_repo="dogs/train/0000.csv", is_folder=False),
71-
CommitOperationAdd(
72-
path_in_repo="README.md",
73-
path_or_fileobj=dedent(
74-
f"""\
75-
---
76-
{METADATA_CONFIGS_FIELD}:
77-
- config_name: cats
78-
data_files:
79-
- split: train
80-
path: cats/train/*
81-
---
82-
"""
83-
).encode(),
84-
),
85-
]
86-
assert mock_method.call_args.kwargs.get("operations") == expected_operations
69+
expected_readme = dedent(
70+
f"""\
71+
---
72+
{METADATA_CONFIGS_FIELD}:
73+
- config_name: cats
74+
data_files:
75+
- split: train
76+
path: cats/train/*
77+
---
78+
"""
79+
).encode()
80+
# Note: we compare operations attribute by attribute rather than relying on `==`. Since
81+
# huggingface_hub 1.20.0 (https://github.com/huggingface/huggingface_hub/pull/4331),
82+
# `CommitOperationAdd`/`CommitOperationDelete` no longer implement value equality, so two
83+
# operations with identical content are not considered equal.
84+
operations = mock_method.call_args.kwargs.get("operations")
85+
assert len(operations) == 2
86+
delete_operation, add_operation = operations
87+
assert isinstance(delete_operation, CommitOperationDelete)
88+
assert delete_operation.path_in_repo == "dogs/train/0000.csv"
89+
assert delete_operation.is_folder is False
90+
assert isinstance(add_operation, CommitOperationAdd)
91+
assert add_operation.path_in_repo == "README.md"
92+
assert add_operation.path_or_fileobj == expected_readme

tests/test_load.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ def test_load_dataset_from_hub(kwargs, expected_train_num_rows, expected_test_nu
921921

922922

923923
@pytest.mark.integration
924-
@pytest.mark.parametrize("stream_from_cache, ", [False, True])
924+
@pytest.mark.parametrize("stream_from_cache", [False, True])
925925
def test_load_dataset_cached_from_hub(stream_from_cache, caplog):
926926
dataset = load_dataset(SAMPLE_DATASET_IDENTIFIER3)
927927
assert isinstance(dataset, DatasetDict)

0 commit comments

Comments
 (0)