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: projected AwkwardInputLayers have __dask_tokenize__ #470

Merged
merged 5 commits into from
Feb 13, 2024
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
15 changes: 14 additions & 1 deletion src/dask_awkward/layers/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ def io_func_implements_report(func: ImplementsIOFunction) -> bool:
return hasattr(func, "return_report")


class AwkwardTokenizable:

def __init__(self, ret_val, parent_name):
self.parent_name = parent_name
self.ret_val = ret_val

def __dask_tokenize__(self):
return ("AwkwardTokenizable", self.parent_name)

def __call__(self, *_, **__):
return self.ret_val


class AwkwardInputLayer(AwkwardBlockwiseLayer):
"""A layer known to perform IO and produce Awkward arrays

Expand Down Expand Up @@ -230,7 +243,7 @@ def prepare_for_projection(self) -> tuple[AwkwardInputLayer, TypeTracerReport, T
new_input_layer = AwkwardInputLayer(
name=self.name,
inputs=[None][: int(list(self.numblocks.values())[0][0])],
io_func=lambda *_, **__: new_return,
io_func=AwkwardTokenizable(new_return, self.name),
label=self.label,
produces_tasks=self.produces_tasks,
creation_info=self.creation_info,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def test_basic_root_works():
.fill(events.MET_pt)
)

columns = list(dak.necessary_columns(q1_hist).values())[0]
assert columns == frozenset({"MET_pt"})
dask.compute(q1_hist)


Expand Down
Loading