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

Function data_dir_with_metadata

tests/test_load.py:113–134  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

111
112@pytest.fixture
113def data_dir_with_metadata(tmp_path):
114 data_dir = tmp_path / "data_dir_with_metadata"
115 data_dir.mkdir()
116 (data_dir / "train").mkdir()
117 (data_dir / "test").mkdir()
118 with open(data_dir / "train" / "cat.jpg", "wb") as f:
119 f.write(b"train_image_bytes")
120 with open(data_dir / "test" / "dog.jpg", "wb") as f:
121 f.write(b"test_image_bytes")
122 with open(data_dir / "train" / "metadata.jsonl", "w") as f:
123 f.write(
124 """\
125 {"file_name": "cat.jpg", "caption": "Cool train cat image"}
126 """
127 )
128 with open(data_dir / "test" / "metadata.jsonl", "w") as f:
129 f.write(
130 """\
131 {"file_name": "dog.jpg", "caption": "Cool test dog image"}
132 """
133 )
134 return str(data_dir)
135
136
137@pytest.fixture

Callers

nothing calls this directly

Calls 2

mkdirMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected