-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[Core] Make multiprocessing pool raise TypeError when provided a non-iterable in imap or imap_unordered #31799
[Core] Make multiprocessing pool raise TypeError when provided a non-iterable in imap or imap_unordered #31799
Conversation
ac73679
to
67d71e9
Compare
We will wait until Ray 2.4 to merge this. In Ray 2.3 we will raise a deprecation warning, see PR #31845 |
with pytest.raises(TypeError, match="object is not iterable"): | ||
pool.imap(fn, non_iterable) | ||
|
||
with pytest.raises(TypeError, match="object is not iterable"): | ||
pool.imap_unordered(fn, non_iterable) | ||
|
||
with pytest.raises(TypeError, match="object is not iterable"): | ||
pool.map(fn, non_iterable) | ||
|
||
with pytest.raises(TypeError, match="object is not iterable"): | ||
pool.map_async(fn, non_iterable) | ||
|
||
with pytest.raises(TypeError, match="must be an iterable, not"): | ||
pool.starmap(fn, [non_iterable]) | ||
|
||
with pytest.raises(TypeError, match="must be an iterable, not"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where are these error messages coming from, the iter
call?
Not sure what it looks like, but should we instead wrap it and write a more user-friendly error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can; I opted not to because this is the same error that Pool from Python multiprocessing raises.
…or on non-iterable arguments, matching Python multiprocessing.Pool behavior. Signed-off-by: Cade Daniel <[email protected]>
67d71e9
to
1f63120
Compare
nice! |
…iterable in imap or imap_unordered ray-project#31799 This PR modifies ray.util.multiprocessing.Pool so that pool.imap and pool.imap_unordered throw TypeError when given non-iterable inputs. Signed-off-by: Cade Daniel <[email protected]> Signed-off-by: Jack He <[email protected]>
…iterable in imap or imap_unordered ray-project#31799 This PR modifies ray.util.multiprocessing.Pool so that pool.imap and pool.imap_unordered throw TypeError when given non-iterable inputs. Signed-off-by: Cade Daniel <[email protected]> Signed-off-by: Edward Oakes <[email protected]>
…iterable in imap or imap_unordered ray-project#31799 This PR modifies ray.util.multiprocessing.Pool so that pool.imap and pool.imap_unordered throw TypeError when given non-iterable inputs. Signed-off-by: Cade Daniel <[email protected]>
…iterable in imap or imap_unordered ray-project#31799 This PR modifies ray.util.multiprocessing.Pool so that pool.imap and pool.imap_unordered throw TypeError when given non-iterable inputs. Signed-off-by: Cade Daniel <[email protected]> Signed-off-by: elliottower <[email protected]>
…iterable in imap or imap_unordered ray-project#31799 This PR modifies ray.util.multiprocessing.Pool so that pool.imap and pool.imap_unordered throw TypeError when given non-iterable inputs. Signed-off-by: Cade Daniel <[email protected]> Signed-off-by: Jack He <[email protected]>
TL;DR
This PR modifies
ray.util.multiprocessing.Pool
so thatpool.imap
andpool.imap_unordered
throwTypeError
when given non-iterable inputs.More details
We want the API of
ray.util.multiprocessing.Pool
to closely resemble that ofmultiprocessing.Pool
. One Ray user pointed out in #24237 that ourimap
andimap_unordered
implementations differ slightly frommultiprocessing.Pool
in what arguments they accept. See the following usage:With this PR, this code produces no exception. Without this PR, this fails:
Closes #24237