Skip to content

Callback __init__() overrides subclass callback definitions  #1125

@maxhutch

Description

@maxhutch

The __init__ method in Callback is:

    def __init__(self, start=None, pretask=None, posttask=None, finish=None):
        self._start = start
        self._pretask = pretask
        self._posttask = posttask
        self._finish = finish

which overrides callbacks defined in subclasses, e.g.:

class TaskCounter(Callback):
    def _pretask(self, key, dask, state):
        count(key, dask, state)

which doesn't work, while:

class TaskCounter(Callback):
    def __init__(self):
        pass

    def _pretask(self, key, dask, state):
        count(key, dask, state)

does. Not sure quite what desired behavior here is, but the example in the docs:

class PrintKeys(Callback):
    def _pretask(self, key, dask, state):
        """Print the key of every task as it's started"""
        print("Computing: {0}!".format(repr(key)))

doesn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions