File size: 1,119 Bytes
de8bb50
 
 
65faa6e
a5ac9e2
de8bb50
65faa6e
de8bb50
 
 
a5ac9e2
de8bb50
 
 
 
 
 
 
 
 
 
a5ac9e2
52178ed
 
 
 
 
 
 
 
de8bb50
 
 
 
52178ed
de8bb50
 
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
import pytest
from datasets import load_dataset

from dynaword.dataset_structure import SampleSchema
from dynaword.paths import repo_path

from .conftest import DATASET_NAMES


@pytest.mark.parametrize("dataset_name", DATASET_NAMES)
def test_sample_schema(dataset_name: str):
    """Ensure that the dataset samples follow the correct schema"""

    ds = load_dataset(
        str(repo_path.resolve()), dataset_name, split="train", streaming=True
    )
    sample = next(iter(ds))
    SampleSchema(**sample)


@pytest.mark.parametrize("dataset_name", DATASET_NAMES)
def test_dataset_folder_structure(dataset_name: str):
    """tests that the dataset folder structure is as follows.

    dataset_name
    |- dataset_name.md
    |- dataset_name.parquet

    If there is a python file, there should at least be one called `create.py`, but there can be additional.
    """
    path = repo_path / "data" / dataset_name

    assert (path / f"{path.name}.parquet").exists()
    assert (path / f"{path.name}.md").exists()

    if any(p.name.endswith(".py") for p in path.glob("*")):
        assert (path / "create.py").exists()