all_builder_dirs.append(builder_dir)
if not all_builder_dirs:
return None
elif len(all_builder_dirs) != 1:
// Rather than raising error every time, we could potentially be smarter
// and load the most recent version across all files, but should be
// carefull when partial version is requested ("my_dataset:3.*.*").
// Could add some `MultiDataDirManager` API:
// ```
// manager = MultiDataDirManager(given_data_dir=data_dir)
// with manager.merge_data_dirs() as virtual_data_dir:
// virtual_builder_dir = _find_builder_dir(name, data_dir=virtual_data_dir)
// builder_dir = manager.resolve(virtual_builder_dir)
// ```
raise ValueError(
f"Dataset {name} detected in multiple locations: {all_builder_dirs}. "
"Please resolve the ambiguity by explicitly setting `data_dir=`."
)
else:
return next(iter(all_builder_dirs)) // List has a single element