Skip to content

Commit

Permalink
run DataLoader test only on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeier committed Aug 22, 2023
1 parent 5358620 commit af66bd0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/datasets_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import itertools
import os
import pathlib
import platform
import random
import shutil
import string
Expand Down Expand Up @@ -198,11 +199,16 @@ def check_wrapped_samples(dataset):

check_wrapped_samples(wrapped_dataset)

with dataset_test_case.create_dataset(config) as (dataset, _):
wrapped_dataset = wrap_dataset_for_transforms_v2(dataset)
dataloader = DataLoader(wrapped_dataset, num_workers=2, multiprocessing_context="spawn", collate_fn=_no_collate)
# On macOS, forking for multiprocessing is not available and thus spawning is used by default. For this to work,
# the whole pipeline including the dataset needs to be pickleable, which is what we are enforcing here.
if platform.system() == "Darwin":
with dataset_test_case.create_dataset(config) as (dataset, _):
wrapped_dataset = wrap_dataset_for_transforms_v2(dataset)
dataloader = DataLoader(
wrapped_dataset, num_workers=2, multiprocessing_context="spawn", collate_fn=_no_collate
)

check_wrapped_samples(dataloader)
check_wrapped_samples(dataloader)


class DatasetTestCase(unittest.TestCase):
Expand Down

0 comments on commit af66bd0

Please sign in to comment.