Skip to content

Commit cc3bad0

Browse files
authored
Merge pull request #18 from janelia-cellmap/dask_info
wait for a worker to spawn before getting allocated memory size (per worker)
2 parents a7244d1 + c5ad3be commit cc3bad0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/zarrify/formats/tiff.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,15 @@ def write_to_zarr(self,
8686
# compute size of the slab
8787
slab_size_bytes = np.prod(slice_chunks) * np.dtype(self.dtype).itemsize
8888

89-
# get dask worker allocated memery size
90-
dask_worker_memory_bytes = next(iter(client.scheduler_info()["workers"].values()))["memory_limit"]
89+
# get dask worker allocated memory size
90+
# Wait for at least one worker to be available
91+
try:
92+
client.wait_for_workers(n_workers=1, timeout=30) # Wait up to 30 seconds for 1 worker
93+
workers_info = client.scheduler_info()["workers"]
94+
dask_worker_memory_bytes = next(iter(workers_info.values()))["memory_limit"]
95+
96+
except Exception as e:
97+
logger.warning(f"Failed to get worker memory info: {e}")
9198

9299
logger.info(f"Slab size: {slab_size_bytes / 1e9} GB")
93100
logger.info(f"Dask memory limit: {dask_worker_memory_bytes / 1e9} GB")

0 commit comments

Comments
 (0)