Skip to content

Use HighLevelGraph optimizations in delayed - #7298

Closed
jrbourbeau wants to merge 2 commits into
dask:mainfrom
jrbourbeau:delayed-hlg-optimize
Closed

jrbourbeau wants to merge 2 commits into
dask:mainfrom
jrbourbeau:delayed-hlg-optimize

Conversation

@jrbourbeau

@jrbourbeau jrbourbeau commented Mar 1, 2021 •

Copy link
Copy Markdown
Member

This PR updates the default graph manipulation for delayed objects to use HighLevelGraph.cull instead of the low-level (dict) graph cull routine. This allows us to maintain annotations through our optimization pipeline (xref #7036).

cc @ian-r-rose @madsbk

@ian-r-rose

ian-r-rose commented Mar 2, 2021 •

Copy link
Copy Markdown
Collaborator

I suspect that this doesn't fully fix the problem -- since your test doesn't have any cull-able layers, HighLevelGraph.cull just gives you back the same graph.

If we write a test that requires culling, we may yet run into #7036

Edit: here is an example that still fails here:

with dask.annotate(foo="bar"):
    a = delayed(add)(1, 2)
    b = delayed(add)(3, 4)
    d = delayed((a,b))

    

assert type(d.dask) is HighLevelGraph
assert next(iter(d.dask.layers.values())).annotations == {"foo": "bar"}

# Ensure optimizing a Delayed object returns a HighLevelGraph
# and doesn't loose annotations
(d_opt,) = dask.optimize(d[0])
assert type(d_opt.dask) is HighLevelGraph
assert next(iter(d_opt.dask.layers.values())).annotations == {"foo": "bar"}

@jrbourbeau

Copy link
Copy Markdown
Member Author

Ah, thanks for pointing that out and providing a nice code snippet (the last assert does indeed fail with the changes here). I'll have to think about this a bit more

Base automatically changed from master to main March 8, 2021 20:20
@jrbourbeau

Copy link
Copy Markdown
Member Author

Closing in favor of #8316

@jrbourbeau jrbourbeau closed this Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants