Skip to content

Custom optimization functions are called twice, once without scheduler kwargs. #6381

@clarkzinzow

Description

@clarkzinzow

Custom optimization functions (those given as a scheduler optimizations=[foo] kwarg or set in the Dask config) are being called twice: the first time without scheduler kwargs, the second time with scheduler kwargs.

In [1]: import dask
   ...: import dask.array as da
   ...: import numpy as np

In [2]: def dummy_opt(dsk, keys, **kwargs):
   ...:     print(f"Called with kwargs: {kwargs}")
   ...:     return dsk

In [3]: da.from_array(np.array([1, 2])).compute(optimizations=[dummy_opt], dummy_kwarg="foo")
Called with kwargs: {}
Called with kwargs: {'dummy_kwarg': 'foo'}
Out[3]: array([1, 2])

This bug was introduced in this large performance-oriented PR, and affects the following versions: 2.20.0, 2.19.0, 2.18.1, 2.18.0, 2.17.2, 2.17.1, 2.17.0, and 2.16.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions