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

fix: better error message when no collections passed to map_partitions. #325

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/dask_awkward/lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,16 @@ def map_partitions(
kwarg_flat_deps, kwarg_repacker = unpack_collections(kwargs, traverse=traverse)
flat_deps, _ = unpack_collections(*args, *kwargs.values(), traverse=traverse)

if len(flat_deps) == 0:
message = (
"map_partitions expects at least one Dask collection instance, "
"you are passing non-Dask collections to dask-awkward code.\n"
"observed argument types:\n"
)
for arg in args:
message += f"- {type(arg)}"
raise TypeError(message)

arg_flat_deps_expanded = []
arg_repackers = []
arg_lens_for_repackers = []
Expand Down
8 changes: 8 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,11 @@ def test_dask_array_in_map_partitions(daa, caa):
def test_dask_awkward_Array_copy(daa):
c = copy.copy(daa)
assert_eq(daa, c)


def test_map_partitions_no_dask_collections_passed(caa):
with pytest.raises(
TypeError,
match="map_partitions expects at least one Dask collection",
):
dak.num(caa.points.x, axis=1)
Loading