I'm creating a dask scheduler using dask-kubernetes and putting it into adaptive mode.
from dask-kubernetes import KubeCluster
cluster = KubeCluster()
cluster.adapt(minimum=0, maximum=40)
I need each worker to run some setup code when they are created (setting some environment variables with os.environ
) in order for the tasks to execute correctly.
I see in the docs there is a --preload
flag for workers that you start from the command line. I'm guessing I need to set that directly into the adaptive scheduler somewhere.
How to I pass code to my workers to be executed when they start?