Skip to content

fix test_data_loader on Windows and macOS #5912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion test/test_prototype_builtin_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ def test_serializable(self, test_home, dataset_mock, config):

pickle.dumps(dataset)

# This has to be a proper function, since lambda's or local functions
# cannot be pickled, but this is a requirement for the DataLoader with
# multiprocessing, i.e. num_workers > 0
def _collate_fn(self, batch):
return batch

@pytest.mark.parametrize("num_workers", [0, 1])
@parametrize_dataset_mocks(DATASET_MOCKS)
def test_data_loader(self, test_home, dataset_mock, config, num_workers):
Expand All @@ -135,7 +141,7 @@ def test_data_loader(self, test_home, dataset_mock, config, num_workers):
dataset,
batch_size=2,
num_workers=num_workers,
collate_fn=lambda batch: batch,
collate_fn=self._collate_fn,
)

next(iter(dl))
Expand Down