File size: 1,818 Bytes
db6eb0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import logging
import os

import datasets as ds
import pytest

logging.basicConfig(
    format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", level=logging.INFO
)


@pytest.fixture
def dataset_path() -> str:
    return "cocostuff.py"


@pytest.mark.skipif(
    bool(os.environ.get("CI", False)),
    reason="Because this test downloads a large data set, we will skip running it on CI.",
)
def test_load_stuff_thing_dataset(dataset_path: str):
    dataset = ds.load_dataset(path=dataset_path, name="stuff-thing")

    expected_features = [
        "image",
        "image_id",
        "image_filename",
        "width",
        "height",
        "stuff_map",
        "objects",
    ]
    for expected_feature in expected_features:
        assert expected_feature in dataset["train"].features.keys()  # type: ignore
        assert expected_feature in dataset["validation"].features.keys()  # type: ignore

    assert dataset["train"].num_rows == 118280  # type: ignore
    assert dataset["validation"].num_rows == 5000  # type: ignore


@pytest.mark.skipif(
    bool(os.environ.get("CI", False)),
    reason="Because this test downloads a large data set, we will skip running it on CI.",
)
def test_load_stuff_only_dataset(dataset_path: str):
    dataset = ds.load_dataset(path=dataset_path, name="stuff-only")

    expected_features = [
        "image",
        "image_id",
        "image_filename",
        "width",
        "height",
        "objects",
    ]
    for expected_feature in expected_features:
        assert expected_feature in dataset["train"].features.keys()  # type: ignore
        assert expected_feature in dataset["validation"].features.keys()  # type: ignore

    assert dataset["train"].num_rows == 118280  # type: ignore
    assert dataset["validation"].num_rows == 5000  # type: ignore