Skip to content

Commit

Permalink
Fix max_concurrent instance check and error message (#1420)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Ho <[email protected]>
  • Loading branch information
mirceamironenco and andrewkho authored Jan 28, 2025
1 parent e25df94 commit 5238ca3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions torchdata/nodes/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ def __init__(
self._mp_context = mp.get_context(self.multiprocessing_context)

if max_concurrent is not None and num_workers > 0:
if not isinstance(max_concurrent, int) and max_concurrent > num_workers:
raise ValueError(f"{max_concurrent=} should be >= {num_workers=}!")
if isinstance(max_concurrent, int) and max_concurrent > num_workers:
raise ValueError(f"{max_concurrent=} should be <= {num_workers=}!")
self.max_concurrent = max_concurrent
self.snapshot_frequency = snapshot_frequency
self._it: Optional[Union[_InlineMapperIter[T], _ParallelMapperIter[T]]] = None
Expand Down Expand Up @@ -404,8 +404,8 @@ def __init__(
self.method = method
self.multiprocessing_context = multiprocessing_context
if max_concurrent is not None and num_workers > 0:
if not isinstance(max_concurrent, int) and max_concurrent > num_workers:
raise ValueError(f"{max_concurrent=} should be >= {num_workers=}!")
if isinstance(max_concurrent, int) and max_concurrent > num_workers:
raise ValueError(f"{max_concurrent=} should be <= {num_workers=}!")
self.max_concurrent = max_concurrent
self.snapshot_frequency = snapshot_frequency
self.prebatch = prebatch
Expand Down

0 comments on commit 5238ca3

Please sign in to comment.