Skip to content

Commit

Permalink
Fix dprs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gokulavasan committed Mar 26, 2024
1 parent 2b831b3 commit 4178f61
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions test/dataloader2/test_mprs.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,10 @@ class TestMultiProcessingReadingService(TestCase):
`pause`, `resume`, `snapshot`.
"""

@mp_ctx_parametrize
@parametrize("dp_fn", [subtest(_non_dispatching_dp, "non_dispatch"), subtest(_dispatching_dp, "dispatch")])
@parametrize("main_prefetch", [0, 10])
@parametrize("worker_prefetch", [0, 10])
def test_early_exit(self, ctx, dp_fn, main_prefetch, worker_prefetch) -> None:
def test_early_exit(self, ctx="forkserver", dp_fn, main_prefetch, worker_prefetch) -> None:
dp = dp_fn(1000)
rs = MultiProcessingReadingService(
num_workers=2,
Expand All @@ -244,11 +243,10 @@ def test_early_exit(self, ctx, dp_fn, main_prefetch, worker_prefetch) -> None:
_ = next(it)
dl.shutdown()

@mp_ctx_parametrize
@parametrize("dp_fn", [subtest(_non_dispatching_dp, "non_dispatch"), subtest(_dispatching_dp, "dispatch")])
@parametrize("main_prefetch", [0, 10])
@parametrize("worker_prefetch", [0, 10])
def test_exit(self, ctx, dp_fn, main_prefetch, worker_prefetch) -> None:
def test_exit(self, ctx="forkserver", dp_fn, main_prefetch, worker_prefetch) -> None:
dp = dp_fn(1000)
rs = MultiProcessingReadingService(
num_workers=2,
Expand All @@ -260,13 +258,12 @@ def test_exit(self, ctx, dp_fn, main_prefetch, worker_prefetch) -> None:
_ = list(dl)
dl.shutdown()

@mp_ctx_parametrize
@dp_parametrize
@parametrize(
"n_workers,worker_prefetch_cnt,main_prefetch_cnt",
[(1, 0, 0), (1, 0, 2), (2, 0, 0), (2, 2, 0), (2, 0, 2), (2, 2, 2)],
)
def test_reading_service_pause_resume(self, ctx, dp, n_workers, worker_prefetch_cnt, main_prefetch_cnt) -> None:
def test_reading_service_pause_resume(self, ctx="forkserver", dp, n_workers, worker_prefetch_cnt, main_prefetch_cnt) -> None:

# Functional Test: Testing various configuration of DataPipe/ReadingService to ensure the pipeline
# properly pauses and resumes
Expand All @@ -293,10 +290,9 @@ def test_reading_service_pause_resume(self, ctx, dp, n_workers, worker_prefetch_
)
dl.shutdown()

@mp_ctx_parametrize
@dp_parametrize
@parametrize("n_workers,worker_prefetch_cnt,main_prefetch_cnt", [(2, 0, 1), (2, 1, 0), (2, 0, 0)])
def test_reading_service_pause_stop_yield(self, ctx, dp, n_workers, worker_prefetch_cnt, main_prefetch_cnt) -> None:
def test_reading_service_pause_stop_yield(self, ctx="forkserver", dp, n_workers, worker_prefetch_cnt, main_prefetch_cnt) -> None:

# Functional Test: Confirms that `dl` will stop yielding elements after `_pause` is called
rs = MultiProcessingReadingService(
Expand Down

0 comments on commit 4178f61

Please sign in to comment.