A Dask question. I frequently use `Client.register...
# ask-community
r
A Dask question. I frequently use
Client.register_worker_plugin
(https://docs.dask.org/en/latest/futures.html#distributed.Client.register_worker_plugin) with my Dask clusters to install custom pip packages (e.g. install from dev branch for debugging.) If I am using prefect with an existing dask scheduler, how can I call
client.register_worker_plugin
? I tried
Copy code
executor = DaskExecutor(
    address=cluster.scheduler_address,
    client_kwargs={"security": cluster.security}
)
executor.client.register_worker_plugin
but it looks like the
client
attribute on
executor
is None.
z
Hi! I think you may need to try getting the client from within a task and registering the worker plugin there? You'd then just make this the first task of your flow.
r
Actually it's even easier! I can just create a separate
dask.distributed.Client
, independent from prefect, and call
register_worker_plugin
from that Client
the installed pip packages are then available when the prefect flow runs
I assumed (wrongly) that this would not work; should have tried it before asking the question! 😆
z
👍 I presume that won't work if it's an ephemeral cluster? but glad it's working
r
the cluster has to be created outside of prefect for that to work
is that non-ephemeral, by your definition?