Skip to content

Commit af66bd0

Browse files
committed
run DataLoader test only on macOS
1 parent 5358620 commit af66bd0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/datasets_utils.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import itertools
66
import os
77
import pathlib
8+
import platform
89
import random
910
import shutil
1011
import string
@@ -198,11 +199,16 @@ def check_wrapped_samples(dataset):
198199

199200
check_wrapped_samples(wrapped_dataset)
200201

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

205-
check_wrapped_samples(dataloader)
211+
check_wrapped_samples(dataloader)
206212

207213

208214
class DatasetTestCase(unittest.TestCase):

0 commit comments

Comments
 (0)