We are in the process of adopting Dask and believe there are cases where running locally is sufficient but in other cases we will definitely need to run on clusters (created via Coiled). Is there a way to programmatically determine if your code is connected to a cluster?
Thanks in advance for your help!
You can call
Client.current() to see if a client exists and is connected to a cluster. If it isn’t it will raise a
from dask.distributed import Client
current_client = Client.current()
If perhaps the question was: there is indeed a distributed client, but you want to know whether it is a LocalCluster or something else, you can look at the client object’s