From ff38e6edfa8c6da4deeb7bb96b990301216d36c2 Mon Sep 17 00:00:00 2001 From: Wauplin Date: Thu, 25 Jun 2026 15:14:01 +0200 Subject: [PATCH] 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 (https://github.com/huggingface/huggingface_hub/pull/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 --- tests/test_hub.py | 42 ++++++++++++++++++++++++------------------ tests/test_load.py | 2 +- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/tests/test_hub.py b/tests/test_hub.py index d0394c34441..1b76c8ed068 100644 --- a/tests/test_hub.py +++ b/tests/test_hub.py @@ -66,21 +66,27 @@ def test_delete_from_hub(temporary_repo, hf_api, hf_token, csv_path, ci_hub_conf assert mock_method.called assert mock_method.call_args.kwargs.get("commit_message") == "Delete 'dogs' config" assert mock_method.call_args.kwargs.get("create_pr") - expected_operations = [ - CommitOperationDelete(path_in_repo="dogs/train/0000.csv", is_folder=False), - CommitOperationAdd( - path_in_repo="README.md", - path_or_fileobj=dedent( - f"""\ - --- - {METADATA_CONFIGS_FIELD}: - - config_name: cats - data_files: - - split: train - path: cats/train/* - --- - """ - ).encode(), - ), - ] - assert mock_method.call_args.kwargs.get("operations") == expected_operations + expected_readme = dedent( + f"""\ + --- + {METADATA_CONFIGS_FIELD}: + - config_name: cats + data_files: + - split: train + path: cats/train/* + --- + """ + ).encode() + # Note: we compare operations attribute by attribute rather than relying on `==`. Since + # huggingface_hub 1.20.0 (https://github.com/huggingface/huggingface_hub/pull/4331), + # `CommitOperationAdd`/`CommitOperationDelete` no longer implement value equality, so two + # operations with identical content are not considered equal. + operations = mock_method.call_args.kwargs.get("operations") + assert len(operations) == 2 + delete_operation, add_operation = operations + assert isinstance(delete_operation, CommitOperationDelete) + assert delete_operation.path_in_repo == "dogs/train/0000.csv" + assert delete_operation.is_folder is False + assert isinstance(add_operation, CommitOperationAdd) + assert add_operation.path_in_repo == "README.md" + assert add_operation.path_or_fileobj == expected_readme diff --git a/tests/test_load.py b/tests/test_load.py index dba83bfc52c..eb5e631d7e2 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -921,7 +921,7 @@ def test_load_dataset_from_hub(kwargs, expected_train_num_rows, expected_test_nu @pytest.mark.integration -@pytest.mark.parametrize("stream_from_cache, ", [False, True]) +@pytest.mark.parametrize("stream_from_cache", [False, True]) def test_load_dataset_cached_from_hub(stream_from_cache, caplog): dataset = load_dataset(SAMPLE_DATASET_IDENTIFIER3) assert isinstance(dataset, DatasetDict)