Commit b9c7b11 1 parent dd88867 commit b9c7b11 Copy full SHA for b9c7b11
File tree 2 files changed +24
-10
lines changed
2 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -268,9 +268,20 @@ def run(self,
268
268
if scheduler is None and n_jobs == 1 :
269
269
scheduler = 'single-threaded'
270
270
271
- # fall back to multiprocessing, we tried everything
272
- if scheduler is None :
273
- scheduler = 'multiprocessing'
271
+ if n_blocks is None :
272
+ if scheduler == 'multiprocessing' :
273
+ n_blocks = n_jobs
274
+ else :
275
+ try :
276
+ from dask import distributed
277
+ if isinstance (scheduler , distributed .Client ):
278
+ n_blocks = len (scheduler .ncores ())
279
+ except ImportError :
280
+ n_blocks = 1
281
+ warnings .warn (
282
+ "Couldn't guess ideal number of blocks from scheduler. "
283
+ "Setting n_blocks=1. "
284
+ "Please provide `n_blocks` in call to method." )
274
285
275
286
scheduler_kwargs = {'scheduler' : scheduler }
276
287
if scheduler == 'multiprocessing' :
Original file line number Diff line number Diff line change @@ -315,14 +315,17 @@ def run(self,
315
315
if n_blocks is None :
316
316
if scheduler == 'multiprocessing' :
317
317
n_blocks = n_jobs
318
- elif isinstance (scheduler , dask .distributed .Client ):
319
- n_blocks = len (scheduler .ncores ())
320
318
else :
321
- n_blocks = 1
322
- warnings .warn (
323
- "Couldn't guess ideal number of blocks from scheduler. "
324
- "Setting n_blocks=1. "
325
- "Please provide `n_blocks` in call to method." )
319
+ try :
320
+ from dask import distributed
321
+ if isinstance (scheduler , distributed .Client ):
322
+ n_blocks = len (scheduler .ncores ())
323
+ except ImportError :
324
+ n_blocks = 1
325
+ warnings .warn (
326
+ "Couldn't guess ideal number of blocks from scheduler. "
327
+ "Setting n_blocks=1. "
328
+ "Please provide `n_blocks` in call to method." )
326
329
327
330
scheduler_kwargs = {'scheduler' : scheduler }
328
331
if scheduler == 'multiprocessing' :
You can’t perform that action at this time.
0 commit comments