MCPcopy
hub / github.com/huggingface/datasets / test_test_command

Function test_test_command

tests/commands/test_test.py:34–83  ·  view source on GitHub ↗
(dataset_dir)

Source from the content-addressed store, hash-verified

32
33@pytest.mark.integration
34def test_test_command(dataset_dir):
35 args = _TestCommandArgs(dataset=dataset_dir, all_configs=True, save_infos=True)
36 test_command = TestCommand(*args)
37 test_command.run()
38 dataset_readme_path = os.path.join(dataset_dir, "README.md")
39 assert os.path.exists(dataset_readme_path)
40 dataset_infos = DatasetInfosDict.from_directory(dataset_dir)
41 expected_dataset_infos = DatasetInfosDict(
42 {
43 "default": DatasetInfo(
44 features=Features(
45 {
46 "tokens": List(Value("string")),
47 "ner_tags": List(
48 ClassLabel(names=["O", "B-PER", "I-PER", "B-ORG", "I-ORG", "B-LOC", "I-LOC"])
49 ),
50 "langs": List(Value("string")),
51 "spans": List(Value("string")),
52 }
53 ),
54 splits=[
55 {
56 "name": "train",
57 "num_bytes": 2351563,
58 "num_examples": 10000,
59 },
60 {
61 "name": "validation",
62 "num_bytes": 238418,
63 "num_examples": 1000,
64 },
65 ],
66 download_size=3940680,
67 dataset_size=2589981,
68 )
69 }
70 )
71 assert dataset_infos.keys() == expected_dataset_infos.keys()
72 for key in DatasetInfo._INCLUDED_INFO_IN_YAML:
73 result, expected = getattr(dataset_infos["default"], key), getattr(expected_dataset_infos["default"], key)
74 if key == "num_bytes":
75 assert is_1percent_close(result, expected)
76 elif key == "splits":
77 assert list(result) == list(expected)
78 for split in result:
79 assert result[split].name == expected[split].name
80 assert result[split].num_examples == expected[split].num_examples
81 assert is_1percent_close(result[split].num_bytes, expected[split].num_bytes)
82 else:
83 result == expected

Callers

nothing calls this directly

Calls 11

runMethod · 0.95
TestCommandClass · 0.90
DatasetInfosDictClass · 0.90
DatasetInfoClass · 0.90
FeaturesClass · 0.90
ListClass · 0.90
ValueClass · 0.90
ClassLabelClass · 0.90
is_1percent_closeFunction · 0.85
existsMethod · 0.80
from_directoryMethod · 0.45

Tested by

no test coverage detected