|
22 | 22 | from typing import List, Optional, Tuple
|
23 | 23 |
|
24 | 24 | import openshift as oc
|
| 25 | +from ray.job_submission import JobSubmissionClient |
25 | 26 |
|
26 | 27 | from ..utils import pretty_print
|
27 | 28 | from ..utils.generate_yaml import generate_appwrapper
|
@@ -140,9 +141,11 @@ def cluster_dashboard_uri(self, namespace: str = "default") -> str:
|
140 | 141 | try:
|
141 | 142 | with oc.project(namespace):
|
142 | 143 | route = oc.invoke(
|
143 |
| - "get", ["route", "-o", "jsonpath='{$.items[0].spec.host}'"] |
| 144 | + "get", ["route", "-o", "jsonpath='{$.items[*].spec.host}'"] |
144 | 145 | )
|
145 |
| - route = route.out().strip().strip("'") |
| 146 | + route = route.out().split(" ") |
| 147 | + route = [x for x in route if f"ray-dashboard-{self.config.name}" in x] |
| 148 | + route = route[0].strip().strip("'") |
146 | 149 | return f"http://{route}"
|
147 | 150 | except:
|
148 | 151 | return "Dashboard route not available yet. Did you run cluster.up()?"
|
@@ -200,6 +203,30 @@ def is_ready(self, print_to_console: bool = True):
|
200 | 203 | pretty_print.print_clusters([cluster])
|
201 | 204 | return status, ready
|
202 | 205 |
|
| 206 | + def list_jobs(self) -> List: |
| 207 | + """ |
| 208 | + This method accesses the head ray node in your cluster and lists the running jobs. |
| 209 | + """ |
| 210 | + dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace) |
| 211 | + client = JobSubmissionClient(dashboard_route) |
| 212 | + return client.list_jobs() |
| 213 | + |
| 214 | + def job_status(self, job_id: str) -> str: |
| 215 | + """ |
| 216 | + This method accesses the head ray node in your cluster and returns the job status for the provided job id. |
| 217 | + """ |
| 218 | + dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace) |
| 219 | + client = JobSubmissionClient(dashboard_route) |
| 220 | + return client.get_job_status(job_id) |
| 221 | + |
| 222 | + def job_logs(self, job_id: str) -> str: |
| 223 | + """ |
| 224 | + This method accesses the head ray node in your cluster and returns the logs for the provided job id. |
| 225 | + """ |
| 226 | + dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace) |
| 227 | + client = JobSubmissionClient(dashboard_route) |
| 228 | + return client.get_job_logs(job_id) |
| 229 | + |
203 | 230 |
|
204 | 231 | def get_current_namespace() -> str:
|
205 | 232 | """
|
|
0 commit comments