Skip to content
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

Cannot pass empty dict as argument to function in client.submit/client.map #8953

Closed
Tracked by #407
wence- opened this issue Dec 2, 2024 · 0 comments · Fixed by dask/dask#11571 or rapidsai/cudf#17492
Closed
Tracked by #407
Assignees

Comments

@wence-
Copy link
Contributor

wence- commented Dec 2, 2024

Describe the issue:

Since the merge #8920 (and dask/dask#11477) it looks like one cannot pass empty dictionaries as arguments to functions through client.submit or client.map

Minimal Complete Verifiable Example:

import distributed

client = distributed.Client()

def identity(*args, **kwargs):
    return args, kwargs

client.submit(identity, {}).result() # ValueError: Dict needs at least one argument

client.submit(identity, x={}).result() # ValueError: Dict needs at least one argument

client.submit(identity, x=None).result() # Fine.

client.map(identity, [None], kw={"foo": {"bar": {}}}) # ValueError: Dict needs at least one argument

This patch in dask allows the above examples to complete for me:

diff --git a/dask/_task_spec.py b/dask/_task_spec.py
index 82b896b6..c67318fb 100644
--- a/dask/_task_spec.py
+++ b/dask/_task_spec.py
@@ -728,8 +728,6 @@ class Dict(NestedContainer):
             if len(args) > 1:
                 raise ValueError("Dict can only take one positional argument")
             kwargs = args[0]
-        elif not kwargs:
-            raise ValueError("Dict needs at least one argument")
         super().__init__(
             *(Tuple(*it) for it in kwargs.items()), _dependencies=_dependencies
         )

However, I am not sure if that is incorrectly relaxing an invariant that should be upheld by the Dict class (namely that it has at least one entry).

Environment:

  • Dask version: 2024.11.2+23.g0f3e5ff6
  • Python version: 3.12
wence- added a commit to wence-/cudf that referenced this issue Dec 2, 2024
@fjetter fjetter self-assigned this Dec 2, 2024
rapids-bot bot pushed a commit to rapidsai/cudf that referenced this issue Dec 2, 2024
Temporarily skip tests failing due to an upstream dask change.

Authors:
  - Lawrence Mitchell (https://github.com/wence-)

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)
  - Matthew Murray (https://github.com/Matt711)

URL: #17472
Matt711 added a commit to rapidsai/cudf that referenced this issue Dec 3, 2024
AyodeAwe pushed a commit to rapidsai/cudf that referenced this issue Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants