diff --git a/docs/cluster/cluster.html b/docs/cluster/cluster.html index 8231fd4fc..5f3a6aad9 100644 --- a/docs/cluster/cluster.html +++ b/docs/cluster/cluster.html @@ -54,6 +54,7 @@

Module codeflare_sdk.cluster.cluster

from typing import List, Optional, Tuple import openshift as oc +from ray.job_submission import JobSubmissionClient from ..utils import pretty_print from ..utils.generate_yaml import generate_appwrapper @@ -172,9 +173,11 @@

Module codeflare_sdk.cluster.cluster

try: with oc.project(namespace): route = oc.invoke( - "get", ["route", "-o", "jsonpath='{$.items[0].spec.host}'"] + "get", ["route", "-o", "jsonpath='{$.items[*].spec.host}'"] ) - route = route.out().strip().strip("'") + route = route.out().split(" ") + route = [x for x in route if f"ray-dashboard-{self.config.name}" in x] + route = route[0].strip().strip("'") return f"http://{route}" except: return "Dashboard route not available yet. Did you run cluster.up()?" @@ -232,6 +235,30 @@

Module codeflare_sdk.cluster.cluster

pretty_print.print_clusters([cluster]) return status, ready + def list_jobs(self) -> List: + """ + This method accesses the head ray node in your cluster and lists the running jobs. + """ + dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace) + client = JobSubmissionClient(dashboard_route) + return client.list_jobs() + + def job_status(self, job_id: str) -> str: + """ + This method accesses the head ray node in your cluster and returns the job status for the provided job id. + """ + dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace) + client = JobSubmissionClient(dashboard_route) + return client.get_job_status(job_id) + + def job_logs(self, job_id: str) -> str: + """ + This method accesses the head ray node in your cluster and returns the logs for the provided job id. + """ + dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace) + client = JobSubmissionClient(dashboard_route) + return client.get_job_logs(job_id) + def get_current_namespace() -> str: """ @@ -549,9 +576,11 @@

Classes

try: with oc.project(namespace): route = oc.invoke( - "get", ["route", "-o", "jsonpath='{$.items[0].spec.host}'"] + "get", ["route", "-o", "jsonpath='{$.items[*].spec.host}'"] ) - route = route.out().strip().strip("'") + route = route.out().split(" ") + route = [x for x in route if f"ray-dashboard-{self.config.name}" in x] + route = route[0].strip().strip("'") return f"http://{route}" except: return "Dashboard route not available yet. Did you run cluster.up()?" @@ -607,7 +636,31 @@

Classes

# overriding the number of gpus with requested cluster.worker_gpu = self.config.gpu pretty_print.print_clusters([cluster]) - return status, ready + return status, ready + + def list_jobs(self) -> List: + """ + This method accesses the head ray node in your cluster and lists the running jobs. + """ + dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace) + client = JobSubmissionClient(dashboard_route) + return client.list_jobs() + + def job_status(self, job_id: str) -> str: + """ + This method accesses the head ray node in your cluster and returns the job status for the provided job id. + """ + dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace) + client = JobSubmissionClient(dashboard_route) + return client.get_job_status(job_id) + + def job_logs(self, job_id: str) -> str: + """ + This method accesses the head ray node in your cluster and returns the logs for the provided job id. + """ + dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace) + client = JobSubmissionClient(dashboard_route) + return client.get_job_logs(job_id)

Methods

@@ -627,9 +680,11 @@

Methods

try: with oc.project(namespace): route = oc.invoke( - "get", ["route", "-o", "jsonpath='{$.items[0].spec.host}'"] + "get", ["route", "-o", "jsonpath='{$.items[*].spec.host}'"] ) - route = route.out().strip().strip("'") + route = route.out().split(" ") + route = [x for x in route if f"ray-dashboard-{self.config.name}" in x] + route = route[0].strip().strip("'") return f"http://{route}" except: return "Dashboard route not available yet. Did you run cluster.up()?" @@ -779,6 +834,60 @@

Methods

return status, ready +
+def job_logs(self, job_id: str) ‑> str +
+
+

This method accesses the head ray node in your cluster and returns the logs for the provided job id.

+
+ +Expand source code + +
def job_logs(self, job_id: str) -> str:
+    """
+    This method accesses the head ray node in your cluster and returns the logs for the provided job id.
+    """
+    dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
+    client = JobSubmissionClient(dashboard_route)
+    return client.get_job_logs(job_id)
+
+
+
+def job_status(self, job_id: str) ‑> str +
+
+

This method accesses the head ray node in your cluster and returns the job status for the provided job id.

+
+ +Expand source code + +
def job_status(self, job_id: str) -> str:
+    """
+    This method accesses the head ray node in your cluster and returns the job status for the provided job id.
+    """
+    dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
+    client = JobSubmissionClient(dashboard_route)
+    return client.get_job_status(job_id)
+
+
+
+def list_jobs(self) ‑> List +
+
+

This method accesses the head ray node in your cluster and lists the running jobs.

+
+ +Expand source code + +
def list_jobs(self) -> List:
+    """
+    This method accesses the head ray node in your cluster and lists the running jobs.
+    """
+    dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
+    client = JobSubmissionClient(dashboard_route)
+    return client.list_jobs()
+
+
def status(self, print_to_console: bool = True)
@@ -863,6 +972,9 @@

create_app_wrapper
  • down
  • is_ready
  • +
  • job_logs
  • +
  • job_status
  • +
  • list_jobs
  • status
  • up
  • diff --git a/docs/cluster/config.html b/docs/cluster/config.html index d5b2c8dba..476ab6fce 100644 --- a/docs/cluster/config.html +++ b/docs/cluster/config.html @@ -78,7 +78,7 @@

    Module codeflare_sdk.cluster.config

    template: str = f"{dir}/templates/new-template.yaml" instascale: bool = False envs: dict = field(default_factory=dict) - image: str = "ghcr.io/ibm-ai-foundation/base:ray1.13.0-py38-gpu-pytorch1.12.0cu116-20220826-202124" + image: str = "ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103" auth: Authentication = Authentication() @@ -93,7 +93,7 @@

    Classes

    class ClusterConfiguration -(name: str, namespace: str = 'default', head_info: list = <factory>, machine_types: list = <factory>, min_cpus: int = 1, max_cpus: int = 1, min_worker: int = 1, max_worker: int = 1, min_memory: int = 2, max_memory: int = 2, gpu: int = 0, template: str = '/home/meyceoz/Documents/codeflare-sdk/src/codeflare_sdk/templates/new-template.yaml', instascale: bool = False, envs: dict = <factory>, image: str = 'ghcr.io/ibm-ai-foundation/base:ray1.13.0-py38-gpu-pytorch1.12.0cu116-20220826-202124', auth: Authentication = <codeflare_sdk.cluster.auth.Authentication object>) +(name: str, namespace: str = 'default', head_info: list = <factory>, machine_types: list = <factory>, min_cpus: int = 1, max_cpus: int = 1, min_worker: int = 1, max_worker: int = 1, min_memory: int = 2, max_memory: int = 2, gpu: int = 0, template: str = '/home/meyceoz/Documents/codeflare-sdk/src/codeflare_sdk/templates/new-template.yaml', instascale: bool = False, envs: dict = <factory>, image: str = 'ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103', auth: Authentication = <codeflare_sdk.cluster.auth.Authentication object>)

    This dataclass is used to specify resource requirements and other details, and @@ -122,7 +122,7 @@

    Classes

    template: str = f"{dir}/templates/new-template.yaml" instascale: bool = False envs: dict = field(default_factory=dict) - image: str = "ghcr.io/ibm-ai-foundation/base:ray1.13.0-py38-gpu-pytorch1.12.0cu116-20220826-202124" + image: str = "ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103" auth: Authentication = Authentication()

    Class variables

    diff --git a/pyproject.toml b/pyproject.toml index 187e52dc0..edaa3c211 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "codeflare-sdk" -version = "0.1.7" +version = "0.2.0" description = "Python SDK for codeflare client" license = "Apache-2.0" @@ -23,3 +23,4 @@ keywords = ['codeflare', 'python', 'sdk', 'client', 'batch', 'scale'] python = "^3.6" openshift-client = "1.0.18" rich = "^12.5" +ray = "2.1.0"