@@ -26,9 +26,9 @@ class RayJobStatus(TypedDict):
2626 jobId : NotRequired [str ]
2727 rayJobInfo : NotRequired [dict [str , Any ]]
2828 jobDeploymentStatus : str
29- rayClusterName : str
30- rayClusterStatus : RayClusterStatus
31- startTime : str
29+ rayClusterName : NotRequired [ str ]
30+ rayClusterStatus : NotRequired [ RayClusterStatus ]
31+ startTime : NotRequired [ str ]
3232
3333 dashboardURL : NotRequired [str ]
3434 endTime : NotRequired [str ]
@@ -55,7 +55,25 @@ def __init__(
5555 super ().__init__ (group = GROUP , version = VERSION , kind = KIND , plural = PLURAL , api_client = api_client )
5656
5757 def get_ray_cluster_name (self , name : str , namespace : str , timeout : float , poll_interval : float = 1.0 ) -> str :
58- return self .get_status (name , namespace , timeout = timeout , poll_interval = poll_interval )["rayClusterName" ]
58+ start_time = time .time ()
59+ status = None
60+
61+ while not time .time () - start_time > timeout :
62+ status = self .get_status (name , namespace , timeout = timeout , poll_interval = poll_interval )
63+ if ray_cluster_name := status .get ("rayClusterName" ):
64+ return ray_cluster_name
65+
66+ logger .debug (
67+ f"RayJob { namespace } /{ name } status does not yet contain rayClusterName. "
68+ f"Current status: { status } . Waiting..."
69+ )
70+
71+ time .sleep (poll_interval )
72+
73+ raise TimeoutError (
74+ f"Timed out ({ timeout :.1f} s) waiting for rayClusterName in RayJob { namespace } /{ name } status. "
75+ f"Last status: { status } "
76+ )
5977
6078 def get_job_submission_id (
6179 self , name : str , namespace : str , timeout : float , poll_interval : float = 1.0
0 commit comments