Hi,
I’m trying to pre-load a worker plugin in a docker setup. Below the snippet from the dask.yaml file.
It does load the script successfully however the plugin is not getting registered.
The only way I’m able to register the worker plugin is through calling client.register_plugin from the client side. However I want the worker plugin to already be available when it starts up.
distributed:
worker:
preload:
- /etc/dask/workerStartup.py
import click
from dask.distributed import Client, WorkerPlugin
class ErrorLogger(WorkerPlugin):
def __init__(self):
pass
def setup(self, worker):
self.worker = worker
def transition(self, key, start, finish, *args, **kwargs):
log.info('somewhere here...')
import sys
sys.exit(-1) # Just a test.
def dask_setup(worker):
plugin = ErrorLogger()
worker.client.register_worker_plugin(plugin)
Alternatively I tried setting it up through the scheduler preload.
It loads as well but yet again the worker plugin is not available.
@click.command()
def dask_setup(scheduler):
plugin = ErrorLogger()
async def setup_worker(worker):
await worker.plugin_add(plugin=plugin, name='my_worker_plugin')
scheduler.worker_plugins.append({'setup': setup_worker})
for worker in scheduler.workers.values():
scheduler.loop.add_callback(setup_worker, worker)
Is there away to do this?
Any help would be appreciated.
Regards,
Christian