|
8 | 8 | from stopes.utils.sharding.hf_shards import HFInputConfig, HFShard |
9 | 9 |
|
10 | 10 | # 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 |
12 | 17 |
|
13 | 18 |
|
14 | 19 | def test_shard_iteration(): |
15 | 20 | shard = HFShard( |
16 | 21 | filter=None, |
17 | | - path_or_name="Fraser/mnist-text-small", |
18 | | - split="test", |
| 22 | + path_or_name="contemmcm/rotten_tomatoes", |
| 23 | + split="complete", |
19 | 24 | index=0, |
20 | 25 | num_shards=50, |
21 | | - trust_remote_code=True, |
22 | 26 | ) |
23 | 27 | with shard: |
24 | 28 | item = next(iter(shard)) |
25 | 29 | 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] |
28 | 32 |
|
29 | 33 | with shard as progress: |
30 | 34 | 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 |
33 | 39 |
|
34 | 40 |
|
35 | 41 | def test_input_config(): |
36 | 42 | input_config = HFInputConfig( |
37 | | - input_file="Fraser/mnist-text-small", |
38 | | - split="test", |
| 43 | + input_file="contemmcm/rotten_tomatoes", |
| 44 | + split="complete", |
39 | 45 | num_shards=50, |
40 | | - trust_remote_code=True, |
41 | 46 | ) |
42 | 47 | shards = input_config.make_shards() |
43 | 48 | first_shard = shards[0] |
44 | 49 | with first_shard: |
45 | 50 | item = next(iter(first_shard)) |
46 | | - assert item["label"] == first_item_id |
| 51 | + assert item["reviewState"] == expected_first_four[0] |
0 commit comments