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()