7
7
8
8
import dask
9
9
10
- from distributed import Adaptive , Client , LocalCluster , SpecCluster , Worker , wait
10
+ from distributed import (
11
+ Adaptive ,
12
+ Client ,
13
+ LocalCluster ,
14
+ Scheduler ,
15
+ SpecCluster ,
16
+ Worker ,
17
+ wait ,
18
+ )
11
19
from distributed .compatibility import WINDOWS
12
20
from distributed .metrics import time
13
21
from distributed .utils_test import async_wait_for , clean , gen_test , slowinc
@@ -18,7 +26,7 @@ def test_adaptive_local_cluster(loop):
18
26
n_workers = 0 ,
19
27
scheduler_port = 0 ,
20
28
silence_logs = False ,
21
- dashboard_address = None ,
29
+ dashboard_address = ":0" ,
22
30
loop = loop ,
23
31
) as cluster :
24
32
alc = cluster .adapt (interval = "100 ms" )
@@ -48,7 +56,7 @@ async def test_adaptive_local_cluster_multi_workers():
48
56
scheduler_port = 0 ,
49
57
silence_logs = False ,
50
58
processes = False ,
51
- dashboard_address = None ,
59
+ dashboard_address = ":0" ,
52
60
asynchronous = True ,
53
61
) as cluster :
54
62
@@ -76,8 +84,8 @@ async def test_adaptive_local_cluster_multi_workers():
76
84
77
85
78
86
@pytest .mark .xfail (reason = "changed API" )
79
- @pytest . mark . asyncio
80
- async def test_adaptive_scale_down_override (cleanup ):
87
+ @gen_test ()
88
+ async def test_adaptive_scale_down_override ():
81
89
class TestAdaptive (Adaptive ):
82
90
def __init__ (self , * args , ** kwargs ):
83
91
self .min_size = kwargs .pop ("min_size" , 0 )
@@ -95,7 +103,9 @@ class TestCluster(LocalCluster):
95
103
def scale_up (self , n , ** kwargs ):
96
104
assert False
97
105
98
- async with TestCluster (n_workers = 10 , processes = False , asynchronous = True ) as cluster :
106
+ async with TestCluster (
107
+ n_workers = 10 , processes = False , asynchronous = True , dashboard_address = ":0"
108
+ ) as cluster :
99
109
ta = cluster .adapt (
100
110
min_size = 2 , interval = 0.1 , scale_factor = 2 , Adaptive = TestAdaptive
101
111
)
@@ -113,7 +123,7 @@ async def test_min_max():
113
123
scheduler_port = 0 ,
114
124
silence_logs = False ,
115
125
processes = False ,
116
- dashboard_address = None ,
126
+ dashboard_address = ":0" ,
117
127
asynchronous = True ,
118
128
threads_per_worker = 1 ,
119
129
)
@@ -169,7 +179,7 @@ async def test_avoid_churn(cleanup):
169
179
processes = False ,
170
180
scheduler_port = 0 ,
171
181
silence_logs = False ,
172
- dashboard_address = None ,
182
+ dashboard_address = ":0" ,
173
183
) as cluster :
174
184
async with Client (cluster , asynchronous = True ) as client :
175
185
adapt = cluster .adapt (interval = "20 ms" , wait_count = 5 )
@@ -194,7 +204,7 @@ async def test_adapt_quickly():
194
204
processes = False ,
195
205
scheduler_port = 0 ,
196
206
silence_logs = False ,
197
- dashboard_address = None ,
207
+ dashboard_address = ":0" ,
198
208
)
199
209
client = await Client (cluster , asynchronous = True )
200
210
adapt = cluster .adapt (interval = "20 ms" , wait_count = 5 , maximum = 10 )
@@ -247,7 +257,7 @@ async def test_adapt_down():
247
257
processes = False ,
248
258
scheduler_port = 0 ,
249
259
silence_logs = False ,
250
- dashboard_address = None ,
260
+ dashboard_address = ":0" ,
251
261
) as cluster :
252
262
async with Client (cluster , asynchronous = True ) as client :
253
263
cluster .adapt (interval = "20ms" , maximum = 5 )
@@ -274,7 +284,7 @@ async def test_no_more_workers_than_tasks():
274
284
scheduler_port = 0 ,
275
285
silence_logs = False ,
276
286
processes = False ,
277
- dashboard_address = None ,
287
+ dashboard_address = ":0" ,
278
288
asynchronous = True ,
279
289
) as cluster :
280
290
adapt = cluster .adapt (minimum = 0 , maximum = 4 , interval = "10 ms" )
@@ -287,7 +297,7 @@ def test_basic_no_loop(loop):
287
297
with clean (threads = False ):
288
298
try :
289
299
with LocalCluster (
290
- 0 , scheduler_port = 0 , silence_logs = False , dashboard_address = None
300
+ 0 , scheduler_port = 0 , silence_logs = False , dashboard_address = ":0"
291
301
) as cluster :
292
302
with Client (cluster ) as client :
293
303
cluster .adapt ()
@@ -311,7 +321,7 @@ async def test_target_duration():
311
321
processes = False ,
312
322
scheduler_port = 0 ,
313
323
silence_logs = False ,
314
- dashboard_address = None ,
324
+ dashboard_address = ":0" ,
315
325
) as cluster :
316
326
adapt = cluster .adapt (interval = "20ms" , minimum = 2 , target_duration = "5s" )
317
327
async with Client (cluster , asynchronous = True ) as client :
@@ -327,6 +337,7 @@ async def test_target_duration():
327
337
async def test_worker_keys (cleanup ):
328
338
"""Ensure that redefining adapt with a lower maximum removes workers"""
329
339
async with SpecCluster (
340
+ scheduler = {"cls" : Scheduler , "options" : {"port" : 0 , "dashboard_address" : ":0" }},
330
341
workers = {
331
342
"a-1" : {"cls" : Worker },
332
343
"a-2" : {"cls" : Worker },
@@ -360,7 +371,7 @@ async def test_adapt_cores_memory(cleanup):
360
371
scheduler_port = 0 ,
361
372
silence_logs = False ,
362
373
processes = False ,
363
- dashboard_address = None ,
374
+ dashboard_address = ":0" ,
364
375
asynchronous = True ,
365
376
) as cluster :
366
377
adapt = cluster .adapt (minimum_cores = 3 , maximum_cores = 9 )
@@ -401,7 +412,7 @@ async def test_update_adaptive(cleanup):
401
412
scheduler_port = 0 ,
402
413
silence_logs = False ,
403
414
processes = False ,
404
- dashboard_address = None ,
415
+ dashboard_address = ":0" ,
405
416
asynchronous = True ,
406
417
) as cluster :
407
418
first = cluster .adapt (maxmimum = 1 )
@@ -415,7 +426,11 @@ async def test_update_adaptive(cleanup):
415
426
async def test_adaptive_no_memory_limit (cleanup ):
416
427
"""Make sure that adapt() does not keep creating workers when no memory limit is set."""
417
428
async with LocalCluster (
418
- n_workers = 0 , threads_per_worker = 1 , memory_limit = 0 , asynchronous = True
429
+ n_workers = 0 ,
430
+ threads_per_worker = 1 ,
431
+ memory_limit = 0 ,
432
+ asynchronous = True ,
433
+ dashboard_address = ":0" ,
419
434
) as cluster :
420
435
cluster .adapt (minimum = 1 , maximum = 10 , interval = "1 ms" )
421
436
async with Client (cluster , asynchronous = True ) as client :
@@ -447,7 +462,9 @@ async def _():
447
462
448
463
return self .sync (_ )
449
464
450
- async with RequiresAwaitCluster (n_workers = 0 , asynchronous = True ) as cluster :
465
+ async with RequiresAwaitCluster (
466
+ n_workers = 0 , asynchronous = True , dashboard_address = ":0"
467
+ ) as cluster :
451
468
async with Client (cluster , asynchronous = True ) as client :
452
469
futures = client .map (slowinc , range (5 ), delay = 0.05 )
453
470
assert len (cluster .workers ) == 0
@@ -465,7 +482,9 @@ async def test_adaptive_stopped():
465
482
We should ensure that the adapt PC is actually stopped once the cluster
466
483
stops.
467
484
"""
468
- async with LocalCluster (n_workers = 0 , asynchronous = True ) as cluster :
485
+ async with LocalCluster (
486
+ n_workers = 0 , asynchronous = True , dashboard_address = ":0"
487
+ ) as cluster :
469
488
instance = cluster .adapt (interval = "10ms" )
470
489
assert instance .periodic_callback is not None
471
490
0 commit comments