@@ -379,36 +379,33 @@ def wait_ready(self, timeout: Optional[int] = None, dashboard_check: bool = True
379379 Checks every five seconds.
380380 """
381381 print ("Waiting for requested resources to be set up..." )
382- ready = False
383- dashboard_ready = False
384- status = None
385382 time = 0
386- while not ready :
383+ while True :
384+ if timeout and time >= timeout :
385+ raise TimeoutError (
386+ f"wait() timed out after waiting { timeout } s for cluster to be ready"
387+ )
387388 status , ready = self .status (print_to_console = False )
388389 if status == CodeFlareClusterStatus .UNKNOWN :
389390 print (
390391 "WARNING: Current cluster status is unknown, have you run cluster.up yet?"
391392 )
392- if not ready :
393- if timeout and time >= timeout :
394- raise TimeoutError (
395- f"wait() timed out after waiting { timeout } s for cluster to be ready"
396- )
397- sleep (5 )
398- time += 5
393+ if ready :
394+ break
395+ sleep (5 )
396+ time += 5
399397 print ("Requested cluster is up and running!" )
400398
401- while dashboard_check and not dashboard_ready :
402- dashboard_ready = self .is_dashboard_ready ()
403- if not dashboard_ready :
404- if timeout and time >= timeout :
405- raise TimeoutError (
406- f"wait() timed out after waiting { timeout } s for dashboard to be ready"
407- )
408- sleep (5 )
409- time += 5
410- if dashboard_ready :
411- print ("Dashboard is ready!" )
399+ while dashboard_check :
400+ if timeout and time >= timeout :
401+ raise TimeoutError (
402+ f"wait() timed out after waiting { timeout } s for dashboard to be ready"
403+ )
404+ if self .is_dashboard_ready ():
405+ print ("Dashboard is ready!" )
406+ break
407+ sleep (5 )
408+ time += 5
412409
413410 def details (self , print_to_console : bool = True ) -> RayCluster :
414411 cluster = _copy_to_ray (self )
0 commit comments