Skip to content

Commit 4d5b835

Browse files
committed
replacing mnist-text for rotten-tomatoes in test-case due to hf scripts deprecation
1 parent 50a9d85 commit 4d5b835

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

stopes/pipelines/tests/test_global_mining.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ def encode_to_np(
129129
(False, True, True, "speech"),
130130
],
131131
)
132-
@pytest.mark.asyncio(scope="session")
133132
def test_global_mining_pipeline(
134133
tmp_path: Path, split_langs: bool, use_meta: bool, fp16: bool, modality: str
135134
) -> None:

stopes/utils/sharding/hf_shards.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def __enter__(self):
103103
cache_dir=_cache_dir,
104104
download_mode=_download_mode,
105105
split=self.split,
106-
trust_remote_code=self.trust_remote_code,
107106
)
108107
if self.split is None: # _data is a DatasetDict, convert to Dataset
109108
_data = concatenate_datasets(

stopes/utils/test_hf_shards.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,44 @@
88
from stopes.utils.sharding.hf_shards import HFInputConfig, HFShard
99

1010
# TODO: Hard code this to test if there are changes in HF datasets API
11-
first_item_id = 7
11+
expected_first_four = [
12+
1,
13+
0,
14+
1,
15+
0,
16+
] # contemmcm/rotten_tomatoes first 4 reviewState values
1217

1318

1419
def test_shard_iteration():
1520
shard = HFShard(
1621
filter=None,
17-
path_or_name="Fraser/mnist-text-small",
18-
split="test",
22+
path_or_name="contemmcm/rotten_tomatoes",
23+
split="complete",
1924
index=0,
2025
num_shards=50,
21-
trust_remote_code=True,
2226
)
2327
with shard:
2428
item = next(iter(shard))
2529
assert isinstance(item, dict)
26-
assert "label" in item
27-
assert item["label"] == first_item_id
30+
assert "reviewState" in item
31+
assert item["reviewState"] == expected_first_four[0]
2832

2933
with shard as progress:
3034
batch_iter = progress.to_batches(batch_size=4)
31-
item = next(batch_iter)
32-
assert item["label"][0].as_py() == first_item_id # type: ignore
35+
batch = next(batch_iter)
36+
# Verify first 4 items match expected pattern [1,0,1,0]
37+
for i in range(4):
38+
assert batch["reviewState"][i].as_py() == expected_first_four[i] # type: ignore
3339

3440

3541
def test_input_config():
3642
input_config = HFInputConfig(
37-
input_file="Fraser/mnist-text-small",
38-
split="test",
43+
input_file="contemmcm/rotten_tomatoes",
44+
split="complete",
3945
num_shards=50,
40-
trust_remote_code=True,
4146
)
4247
shards = input_config.make_shards()
4348
first_shard = shards[0]
4449
with first_shard:
4550
item = next(iter(first_shard))
46-
assert item["label"] == first_item_id
51+
assert item["reviewState"] == expected_first_four[0]

0 commit comments

Comments
 (0)