@@ -54,6 +54,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
5454from typing import List, Optional, Tuple
5555
5656import openshift as oc
57+ from ray.job_submission import JobSubmissionClient
5758
5859from ..utils import pretty_print
5960from ..utils.generate_yaml import generate_appwrapper
@@ -172,9 +173,11 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
172173        try:
173174            with oc.project(namespace):
174175                route = oc.invoke(
175-                     "get", ["route", "-o", "jsonpath='{$.items[0 ].spec.host}'"]
176+                     "get", ["route", "-o", "jsonpath='{$.items[* ].spec.host}'"]
176177                )
177-                 route = route.out().strip().strip("'")
178+                 route = route.out().split(" ")
179+                 route = [x for x in route if f"ray-dashboard-{self.config.name}" in x]
180+                 route = route[0].strip().strip("'")
178181            return f"http://{route}"
179182        except:
180183            return "Dashboard route not available yet. Did you run cluster.up()?"
@@ -232,6 +235,30 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
232235                pretty_print.print_clusters([cluster])
233236        return status, ready
234237
238+     def list_jobs(self) -> List:
239+         """
240+         This method accesses the head ray node in your cluster and lists the running jobs.
241+         """
242+         dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
243+         client = JobSubmissionClient(dashboard_route)
244+         return client.list_jobs()
245+ 
246+     def job_status(self, job_id: str) -> str:
247+         """
248+         This method accesses the head ray node in your cluster and returns the job status for the provided job id.
249+         """
250+         dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
251+         client = JobSubmissionClient(dashboard_route)
252+         return client.get_job_status(job_id)
253+ 
254+     def job_logs(self, job_id: str) -> str:
255+         """
256+         This method accesses the head ray node in your cluster and returns the logs for the provided job id.
257+         """
258+         dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
259+         client = JobSubmissionClient(dashboard_route)
260+         return client.get_job_logs(job_id)
261+ 
235262
236263def get_current_namespace() -> str:
237264    """
@@ -549,9 +576,11 @@ <h2 class="section-title" id="header-classes">Classes</h2>
549576        try:
550577            with oc.project(namespace):
551578                route = oc.invoke(
552-                     "get", ["route", "-o", "jsonpath='{$.items[0 ].spec.host}'"]
579+                     "get", ["route", "-o", "jsonpath='{$.items[* ].spec.host}'"]
553580                )
554-                 route = route.out().strip().strip("'")
581+                 route = route.out().split(" ")
582+                 route = [x for x in route if f"ray-dashboard-{self.config.name}" in x]
583+                 route = route[0].strip().strip("'")
555584            return f"http://{route}"
556585        except:
557586            return "Dashboard route not available yet. Did you run cluster.up()?"
@@ -607,7 +636,31 @@ <h2 class="section-title" id="header-classes">Classes</h2>
607636                # overriding the number of gpus with requested
608637                cluster.worker_gpu = self.config.gpu
609638                pretty_print.print_clusters([cluster])
610-         return status, ready</ code > </ pre > 
639+         return status, ready
640+ 
641+     def list_jobs(self) -> List:
642+         """
643+         This method accesses the head ray node in your cluster and lists the running jobs.
644+         """
645+         dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
646+         client = JobSubmissionClient(dashboard_route)
647+         return client.list_jobs()
648+ 
649+     def job_status(self, job_id: str) -> str:
650+         """
651+         This method accesses the head ray node in your cluster and returns the job status for the provided job id.
652+         """
653+         dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
654+         client = JobSubmissionClient(dashboard_route)
655+         return client.get_job_status(job_id)
656+ 
657+     def job_logs(self, job_id: str) -> str:
658+         """
659+         This method accesses the head ray node in your cluster and returns the logs for the provided job id.
660+         """
661+         dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
662+         client = JobSubmissionClient(dashboard_route)
663+         return client.get_job_logs(job_id)</ code > </ pre > 
611664</ details > 
612665< h3 > Methods</ h3 > 
613666< dl > 
@@ -627,9 +680,11 @@ <h3>Methods</h3>
627680    try:
628681        with oc.project(namespace):
629682            route = oc.invoke(
630-                 "get", ["route", "-o", "jsonpath='{$.items[0 ].spec.host}'"]
683+                 "get", ["route", "-o", "jsonpath='{$.items[* ].spec.host}'"]
631684            )
632-             route = route.out().strip().strip("'")
685+             route = route.out().split(" ")
686+             route = [x for x in route if f"ray-dashboard-{self.config.name}" in x]
687+             route = route[0].strip().strip("'")
633688        return f"http://{route}"
634689    except:
635690        return "Dashboard route not available yet. Did you run cluster.up()?"</ code > </ pre > 
@@ -779,6 +834,60 @@ <h3>Methods</h3>
779834    return status, ready</ code > </ pre > 
780835</ details > 
781836</ dd > 
837+ < dt  id ="codeflare_sdk.cluster.cluster.Cluster.job_logs "> < code  class ="name flex "> 
838+ < span > def < span  class ="ident "> job_logs</ span > </ span > (< span > self, job_id: str) ‑>  str</ span > 
839+ </ code > </ dt > 
840+ < dd > 
841+ < div  class ="desc "> < p > This method accesses the head ray node in your cluster and returns the logs for the provided job id.</ p > </ div > 
842+ < details  class ="source "> 
843+ < summary > 
844+ < span > Expand source code</ span > 
845+ </ summary > 
846+ < pre > < code  class ="python "> def job_logs(self, job_id: str) -> str:
847+     """
848+     This method accesses the head ray node in your cluster and returns the logs for the provided job id.
849+     """
850+     dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
851+     client = JobSubmissionClient(dashboard_route)
852+     return client.get_job_logs(job_id)</ code > </ pre > 
853+ </ details > 
854+ </ dd > 
855+ < dt  id ="codeflare_sdk.cluster.cluster.Cluster.job_status "> < code  class ="name flex "> 
856+ < span > def < span  class ="ident "> job_status</ span > </ span > (< span > self, job_id: str) ‑>  str</ span > 
857+ </ code > </ dt > 
858+ < dd > 
859+ < div  class ="desc "> < p > This method accesses the head ray node in your cluster and returns the job status for the provided job id.</ p > </ div > 
860+ < details  class ="source "> 
861+ < summary > 
862+ < span > Expand source code</ span > 
863+ </ summary > 
864+ < pre > < code  class ="python "> def job_status(self, job_id: str) -> str:
865+     """
866+     This method accesses the head ray node in your cluster and returns the job status for the provided job id.
867+     """
868+     dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
869+     client = JobSubmissionClient(dashboard_route)
870+     return client.get_job_status(job_id)</ code > </ pre > 
871+ </ details > 
872+ </ dd > 
873+ < dt  id ="codeflare_sdk.cluster.cluster.Cluster.list_jobs "> < code  class ="name flex "> 
874+ < span > def < span  class ="ident "> list_jobs</ span > </ span > (< span > self) ‑>  List</ span > 
875+ </ code > </ dt > 
876+ < dd > 
877+ < div  class ="desc "> < p > This method accesses the head ray node in your cluster and lists the running jobs.</ p > </ div > 
878+ < details  class ="source "> 
879+ < summary > 
880+ < span > Expand source code</ span > 
881+ </ summary > 
882+ < pre > < code  class ="python "> def list_jobs(self) -> List:
883+     """
884+     This method accesses the head ray node in your cluster and lists the running jobs.
885+     """
886+     dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
887+     client = JobSubmissionClient(dashboard_route)
888+     return client.list_jobs()</ code > </ pre > 
889+ </ details > 
890+ </ dd > 
782891< dt  id ="codeflare_sdk.cluster.cluster.Cluster.status "> < code  class ="name flex "> 
783892< span > def < span  class ="ident "> status</ span > </ span > (< span > self, print_to_console: bool = True)</ span > 
784893</ code > </ dt > 
@@ -863,6 +972,9 @@ <h4><code><a title="codeflare_sdk.cluster.cluster.Cluster" href="#codeflare_sdk.
863972< li > < code > < a  title ="codeflare_sdk.cluster.cluster.Cluster.create_app_wrapper " href ="#codeflare_sdk.cluster.cluster.Cluster.create_app_wrapper "> create_app_wrapper</ a > </ code > </ li > 
864973< li > < code > < a  title ="codeflare_sdk.cluster.cluster.Cluster.down " href ="#codeflare_sdk.cluster.cluster.Cluster.down "> down</ a > </ code > </ li > 
865974< li > < code > < a  title ="codeflare_sdk.cluster.cluster.Cluster.is_ready " href ="#codeflare_sdk.cluster.cluster.Cluster.is_ready "> is_ready</ a > </ code > </ li > 
975+ < li > < code > < a  title ="codeflare_sdk.cluster.cluster.Cluster.job_logs " href ="#codeflare_sdk.cluster.cluster.Cluster.job_logs "> job_logs</ a > </ code > </ li > 
976+ < li > < code > < a  title ="codeflare_sdk.cluster.cluster.Cluster.job_status " href ="#codeflare_sdk.cluster.cluster.Cluster.job_status "> job_status</ a > </ code > </ li > 
977+ < li > < code > < a  title ="codeflare_sdk.cluster.cluster.Cluster.list_jobs " href ="#codeflare_sdk.cluster.cluster.Cluster.list_jobs "> list_jobs</ a > </ code > </ li > 
866978< li > < code > < a  title ="codeflare_sdk.cluster.cluster.Cluster.status " href ="#codeflare_sdk.cluster.cluster.Cluster.status "> status</ a > </ code > </ li > 
867979< li > < code > < a  title ="codeflare_sdk.cluster.cluster.Cluster.up " href ="#codeflare_sdk.cluster.cluster.Cluster.up "> up</ a > </ code > </ li > 
868980</ ul > 
0 commit comments