77
88import dask
99
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+ )
1119from distributed .compatibility import WINDOWS
1220from distributed .metrics import time
1321from distributed .utils_test import async_wait_for , clean , gen_test , slowinc
@@ -18,7 +26,7 @@ def test_adaptive_local_cluster(loop):
1826 n_workers = 0 ,
1927 scheduler_port = 0 ,
2028 silence_logs = False ,
21- dashboard_address = None ,
29+ dashboard_address = ":0" ,
2230 loop = loop ,
2331 ) as cluster :
2432 alc = cluster .adapt (interval = "100 ms" )
@@ -48,7 +56,7 @@ async def test_adaptive_local_cluster_multi_workers():
4856 scheduler_port = 0 ,
4957 silence_logs = False ,
5058 processes = False ,
51- dashboard_address = None ,
59+ dashboard_address = ":0" ,
5260 asynchronous = True ,
5361 ) as cluster :
5462
@@ -76,8 +84,8 @@ async def test_adaptive_local_cluster_multi_workers():
7684
7785
7886@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 ():
8189 class TestAdaptive (Adaptive ):
8290 def __init__ (self , * args , ** kwargs ):
8391 self .min_size = kwargs .pop ("min_size" , 0 )
@@ -95,7 +103,9 @@ class TestCluster(LocalCluster):
95103 def scale_up (self , n , ** kwargs ):
96104 assert False
97105
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 :
99109 ta = cluster .adapt (
100110 min_size = 2 , interval = 0.1 , scale_factor = 2 , Adaptive = TestAdaptive
101111 )
@@ -113,7 +123,7 @@ async def test_min_max():
113123 scheduler_port = 0 ,
114124 silence_logs = False ,
115125 processes = False ,
116- dashboard_address = None ,
126+ dashboard_address = ":0" ,
117127 asynchronous = True ,
118128 threads_per_worker = 1 ,
119129 )
@@ -169,7 +179,7 @@ async def test_avoid_churn(cleanup):
169179 processes = False ,
170180 scheduler_port = 0 ,
171181 silence_logs = False ,
172- dashboard_address = None ,
182+ dashboard_address = ":0" ,
173183 ) as cluster :
174184 async with Client (cluster , asynchronous = True ) as client :
175185 adapt = cluster .adapt (interval = "20 ms" , wait_count = 5 )
@@ -194,7 +204,7 @@ async def test_adapt_quickly():
194204 processes = False ,
195205 scheduler_port = 0 ,
196206 silence_logs = False ,
197- dashboard_address = None ,
207+ dashboard_address = ":0" ,
198208 )
199209 client = await Client (cluster , asynchronous = True )
200210 adapt = cluster .adapt (interval = "20 ms" , wait_count = 5 , maximum = 10 )
@@ -247,7 +257,7 @@ async def test_adapt_down():
247257 processes = False ,
248258 scheduler_port = 0 ,
249259 silence_logs = False ,
250- dashboard_address = None ,
260+ dashboard_address = ":0" ,
251261 ) as cluster :
252262 async with Client (cluster , asynchronous = True ) as client :
253263 cluster .adapt (interval = "20ms" , maximum = 5 )
@@ -274,7 +284,7 @@ async def test_no_more_workers_than_tasks():
274284 scheduler_port = 0 ,
275285 silence_logs = False ,
276286 processes = False ,
277- dashboard_address = None ,
287+ dashboard_address = ":0" ,
278288 asynchronous = True ,
279289 ) as cluster :
280290 adapt = cluster .adapt (minimum = 0 , maximum = 4 , interval = "10 ms" )
@@ -287,7 +297,7 @@ def test_basic_no_loop(loop):
287297 with clean (threads = False ):
288298 try :
289299 with LocalCluster (
290- 0 , scheduler_port = 0 , silence_logs = False , dashboard_address = None
300+ 0 , scheduler_port = 0 , silence_logs = False , dashboard_address = ":0"
291301 ) as cluster :
292302 with Client (cluster ) as client :
293303 cluster .adapt ()
@@ -311,7 +321,7 @@ async def test_target_duration():
311321 processes = False ,
312322 scheduler_port = 0 ,
313323 silence_logs = False ,
314- dashboard_address = None ,
324+ dashboard_address = ":0" ,
315325 ) as cluster :
316326 adapt = cluster .adapt (interval = "20ms" , minimum = 2 , target_duration = "5s" )
317327 async with Client (cluster , asynchronous = True ) as client :
@@ -327,6 +337,7 @@ async def test_target_duration():
327337async def test_worker_keys (cleanup ):
328338 """Ensure that redefining adapt with a lower maximum removes workers"""
329339 async with SpecCluster (
340+ scheduler = {"cls" : Scheduler , "options" : {"port" : 0 , "dashboard_address" : ":0" }},
330341 workers = {
331342 "a-1" : {"cls" : Worker },
332343 "a-2" : {"cls" : Worker },
@@ -360,7 +371,7 @@ async def test_adapt_cores_memory(cleanup):
360371 scheduler_port = 0 ,
361372 silence_logs = False ,
362373 processes = False ,
363- dashboard_address = None ,
374+ dashboard_address = ":0" ,
364375 asynchronous = True ,
365376 ) as cluster :
366377 adapt = cluster .adapt (minimum_cores = 3 , maximum_cores = 9 )
@@ -401,7 +412,7 @@ async def test_update_adaptive(cleanup):
401412 scheduler_port = 0 ,
402413 silence_logs = False ,
403414 processes = False ,
404- dashboard_address = None ,
415+ dashboard_address = ":0" ,
405416 asynchronous = True ,
406417 ) as cluster :
407418 first = cluster .adapt (maxmimum = 1 )
@@ -415,7 +426,11 @@ async def test_update_adaptive(cleanup):
415426async def test_adaptive_no_memory_limit (cleanup ):
416427 """Make sure that adapt() does not keep creating workers when no memory limit is set."""
417428 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" ,
419434 ) as cluster :
420435 cluster .adapt (minimum = 1 , maximum = 10 , interval = "1 ms" )
421436 async with Client (cluster , asynchronous = True ) as client :
@@ -447,7 +462,9 @@ async def _():
447462
448463 return self .sync (_ )
449464
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 :
451468 async with Client (cluster , asynchronous = True ) as client :
452469 futures = client .map (slowinc , range (5 ), delay = 0.05 )
453470 assert len (cluster .workers ) == 0
@@ -465,7 +482,9 @@ async def test_adaptive_stopped():
465482 We should ensure that the adapt PC is actually stopped once the cluster
466483 stops.
467484 """
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 :
469488 instance = cluster .adapt (interval = "10ms" )
470489 assert instance .periodic_callback is not None
471490
0 commit comments