From 332f646f13804706ce6f9489e46c2472a9981129 Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Thu, 9 Jan 2025 10:23:31 +0200 Subject: [PATCH] Don't use the dask distributed Client if the scheduler is set to threads --- crystalball/crystalball.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crystalball/crystalball.py b/crystalball/crystalball.py index 7dce79d..115b150 100644 --- a/crystalball/crystalball.py +++ b/crystalball/crystalball.py @@ -157,15 +157,16 @@ def construct_client( address: str | None = None, workers: int = 1, ) -> Client: - + if scheduler not in ["threads", "distributed"]: raise ValueError(f"Unknown scheduler type: {scheduler}") - + # Following Quartical's constuction of a dask client if scheduler == "threads": log.info("Initializing dask client using threads scheduler.") - return exitstack.enter_context(Client(n_workers=num_workers)) - + exitstack.enter_context(dask.config.set(num_workers=num_workers)) + return None + address = address or os.environ.get("DASK_SCHEDULER_ADDRESS") if address: log.info(