danish-dynaword / src /tests /test_load.py
KennethEnevoldsen's picture
Added test to ensure that main readme contains all datasets
a3c400c unverified
raw
history blame
781 Bytes
from pathlib import Path
from datasets import load_dataset
from tests.readme_parsing import read_frontmatter_and_body
def test_dataset_loads(repo_path: Path):
"""Ensures that the dataset can load as intended"""
name = str(repo_path.resolve())
ds = load_dataset(name, split="train", streaming=True)
sample = next(iter(ds))
assert isinstance(sample, dict)
def test_all_datasets_in_yaml(repo_path: Path):
frontmatter, _ = read_frontmatter_and_body(repo_path / "README.md")
ds_names = {
cfg["config_name"]
for cfg in frontmatter["configs"]
if cfg["config_name"] != "default"
}
data_folder = repo_path / "data"
datasets = data_folder.glob("*")
for dataset in datasets:
assert dataset.name in ds_names