File size: 781 Bytes
7ed5f43
 
78108d3
 
a3c400c
 
78108d3
936cd0c
78108d3
936cd0c
7ed5f43
 
 
78108d3
3e28a50
a3c400c
 
 
 
 
 
 
 
78108d3
a3c400c
 
78108d3
a3c400c
 
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
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