Skip to content

Commit

Permalink
cache the delayed heavy object so we always use the same key in the t…
Browse files Browse the repository at this point in the history
…ask graph
  • Loading branch information
lgray committed Jan 13, 2024
1 parent b6192a7 commit 4b9147f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/coffea/lookup_tools/lookup_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ def __call__(self, *args, **kwargs):

out_meta = tomap(self, *tuple([arg._meta for arg in actual_args]))

delayed_corr = dask.delayed(self)
if not hasattr(self, "_delayed_corr"):
setattr(self, "_delayed_corr", dask.delayed(self))

return dask_awkward.map_partitions(
tomap,
delayed_corr,
self._delayed_corr,
*actual_args,
label=dask_label,
meta=out_meta,
Expand Down
5 changes: 3 additions & 2 deletions src/coffea/ml_tools/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,11 @@ def __call__(self, wrapper, *args):
packed_metas = repack(flattened_metas)

wrap_meta = wrap(self, *packed_metas)
delayed_wrapper = dask.delayed(self)
if not hasattr(self, "_delayed_wrapper"):
setattr(self, "_delayed_wrapper", dask.delayed(self))
arr = dask_awkward.lib.core.map_partitions(
wrap,
delayed_wrapper,
self._delayed_wrapper,
*packed_args,
label=f"numpy_call_{self.__class__.__name__}_",
meta=wrap_meta,
Expand Down

0 comments on commit 4b9147f

Please sign in to comment.