MCPcopy Create free account
hub / github.com/NVIDIA/DALI / test_wds_sharding

Function test_wds_sharding

dali/test/python/reader/test_webdataset_requirements.py:172–210  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

170
171
172def test_wds_sharding():
173 num_samples = 3000
174 tar_file_paths = [
175 os.path.join(get_dali_extra_path(), "db/webdataset/MNIST/devel-0.tar"),
176 os.path.join(get_dali_extra_path(), "db/webdataset/MNIST/devel-1.tar"),
177 os.path.join(get_dali_extra_path(), "db/webdataset/MNIST/devel-2.tar"),
178 ]
179 index_files = [generate_temp_index_file(tar_file_path) for tar_file_path in tar_file_paths]
180
181 extract_dirs = [generate_temp_extract(tar_file_path) for tar_file_path in tar_file_paths]
182 equivalent_files = sum(
183 list(
184 sorted(
185 glob(extract_dir.name + "/*"), key=lambda s: int(s[s.rfind("/") + 1 : s.rfind(".")])
186 ) # noqa: 203
187 for extract_dir in extract_dirs
188 ),
189 [],
190 )
191
192 compare_pipelines(
193 webdataset_raw_pipeline(
194 tar_file_paths,
195 [index_file.name for index_file in index_files],
196 ["jpg", "cls"],
197 batch_size=test_batch_size,
198 device_id=0,
199 num_threads=1,
200 ),
201 file_reader_pipeline(
202 equivalent_files,
203 ["jpg", "cls"],
204 batch_size=test_batch_size,
205 device_id=0,
206 num_threads=1,
207 ),
208 test_batch_size,
209 math.ceil(num_samples / test_batch_size),
210 )
211
212
213def test_sharding():

Callers

nothing calls this directly

Calls 9

get_dali_extra_pathFunction · 0.90
generate_temp_index_fileFunction · 0.90
generate_temp_extractFunction · 0.90
compare_pipelinesFunction · 0.90
webdataset_raw_pipelineFunction · 0.90
file_reader_pipelineFunction · 0.90
sumClass · 0.85
globFunction · 0.85
ceilMethod · 0.80

Tested by

no test coverage detected