Skip to content

Prepare for 0.2.0 release #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 119 additions & 7 deletions docs/cluster/cluster.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
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
Expand Down Expand Up @@ -172,9 +173,11 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
try:
with oc.project(namespace):
route = oc.invoke(
&#34;get&#34;, [&#34;route&#34;, &#34;-o&#34;, &#34;jsonpath=&#39;{$.items[0].spec.host}&#39;&#34;]
&#34;get&#34;, [&#34;route&#34;, &#34;-o&#34;, &#34;jsonpath=&#39;{$.items[*].spec.host}&#39;&#34;]
)
route = route.out().strip().strip(&#34;&#39;&#34;)
route = route.out().split(&#34; &#34;)
route = [x for x in route if f&#34;ray-dashboard-{self.config.name}&#34; in x]
route = route[0].strip().strip(&#34;&#39;&#34;)
return f&#34;http://{route}&#34;
except:
return &#34;Dashboard route not available yet. Did you run cluster.up()?&#34;
Expand Down Expand Up @@ -232,6 +235,30 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
pretty_print.print_clusters([cluster])
return status, ready

def list_jobs(self) -&gt; List:
&#34;&#34;&#34;
This method accesses the head ray node in your cluster and lists the running jobs.
&#34;&#34;&#34;
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) -&gt; str:
&#34;&#34;&#34;
This method accesses the head ray node in your cluster and returns the job status for the provided job id.
&#34;&#34;&#34;
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) -&gt; str:
&#34;&#34;&#34;
This method accesses the head ray node in your cluster and returns the logs for the provided job id.
&#34;&#34;&#34;
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() -&gt; str:
&#34;&#34;&#34;
Expand Down Expand Up @@ -549,9 +576,11 @@ <h2 class="section-title" id="header-classes">Classes</h2>
try:
with oc.project(namespace):
route = oc.invoke(
&#34;get&#34;, [&#34;route&#34;, &#34;-o&#34;, &#34;jsonpath=&#39;{$.items[0].spec.host}&#39;&#34;]
&#34;get&#34;, [&#34;route&#34;, &#34;-o&#34;, &#34;jsonpath=&#39;{$.items[*].spec.host}&#39;&#34;]
)
route = route.out().strip().strip(&#34;&#39;&#34;)
route = route.out().split(&#34; &#34;)
route = [x for x in route if f&#34;ray-dashboard-{self.config.name}&#34; in x]
route = route[0].strip().strip(&#34;&#39;&#34;)
return f&#34;http://{route}&#34;
except:
return &#34;Dashboard route not available yet. Did you run cluster.up()?&#34;
Expand Down Expand Up @@ -607,7 +636,31 @@ <h2 class="section-title" id="header-classes">Classes</h2>
# overriding the number of gpus with requested
cluster.worker_gpu = self.config.gpu
pretty_print.print_clusters([cluster])
return status, ready</code></pre>
return status, ready

def list_jobs(self) -&gt; List:
&#34;&#34;&#34;
This method accesses the head ray node in your cluster and lists the running jobs.
&#34;&#34;&#34;
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) -&gt; str:
&#34;&#34;&#34;
This method accesses the head ray node in your cluster and returns the job status for the provided job id.
&#34;&#34;&#34;
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) -&gt; str:
&#34;&#34;&#34;
This method accesses the head ray node in your cluster and returns the logs for the provided job id.
&#34;&#34;&#34;
dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
client = JobSubmissionClient(dashboard_route)
return client.get_job_logs(job_id)</code></pre>
</details>
<h3>Methods</h3>
<dl>
Expand All @@ -627,9 +680,11 @@ <h3>Methods</h3>
try:
with oc.project(namespace):
route = oc.invoke(
&#34;get&#34;, [&#34;route&#34;, &#34;-o&#34;, &#34;jsonpath=&#39;{$.items[0].spec.host}&#39;&#34;]
&#34;get&#34;, [&#34;route&#34;, &#34;-o&#34;, &#34;jsonpath=&#39;{$.items[*].spec.host}&#39;&#34;]
)
route = route.out().strip().strip(&#34;&#39;&#34;)
route = route.out().split(&#34; &#34;)
route = [x for x in route if f&#34;ray-dashboard-{self.config.name}&#34; in x]
route = route[0].strip().strip(&#34;&#39;&#34;)
return f&#34;http://{route}&#34;
except:
return &#34;Dashboard route not available yet. Did you run cluster.up()?&#34;</code></pre>
Expand Down Expand Up @@ -779,6 +834,60 @@ <h3>Methods</h3>
return status, ready</code></pre>
</details>
</dd>
<dt id="codeflare_sdk.cluster.cluster.Cluster.job_logs"><code class="name flex">
<span>def <span class="ident">job_logs</span></span>(<span>self, job_id: str) ‑> str</span>
</code></dt>
<dd>
<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>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def job_logs(self, job_id: str) -&gt; str:
&#34;&#34;&#34;
This method accesses the head ray node in your cluster and returns the logs for the provided job id.
&#34;&#34;&#34;
dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
client = JobSubmissionClient(dashboard_route)
return client.get_job_logs(job_id)</code></pre>
</details>
</dd>
<dt id="codeflare_sdk.cluster.cluster.Cluster.job_status"><code class="name flex">
<span>def <span class="ident">job_status</span></span>(<span>self, job_id: str) ‑> str</span>
</code></dt>
<dd>
<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>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def job_status(self, job_id: str) -&gt; str:
&#34;&#34;&#34;
This method accesses the head ray node in your cluster and returns the job status for the provided job id.
&#34;&#34;&#34;
dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
client = JobSubmissionClient(dashboard_route)
return client.get_job_status(job_id)</code></pre>
</details>
</dd>
<dt id="codeflare_sdk.cluster.cluster.Cluster.list_jobs"><code class="name flex">
<span>def <span class="ident">list_jobs</span></span>(<span>self) ‑> List</span>
</code></dt>
<dd>
<div class="desc"><p>This method accesses the head ray node in your cluster and lists the running jobs.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def list_jobs(self) -&gt; List:
&#34;&#34;&#34;
This method accesses the head ray node in your cluster and lists the running jobs.
&#34;&#34;&#34;
dashboard_route = self.cluster_dashboard_uri(namespace=self.config.namespace)
client = JobSubmissionClient(dashboard_route)
return client.list_jobs()</code></pre>
</details>
</dd>
<dt id="codeflare_sdk.cluster.cluster.Cluster.status"><code class="name flex">
<span>def <span class="ident">status</span></span>(<span>self, print_to_console: bool = True)</span>
</code></dt>
Expand Down Expand Up @@ -863,6 +972,9 @@ <h4><code><a title="codeflare_sdk.cluster.cluster.Cluster" href="#codeflare_sdk.
<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>
<li><code><a title="codeflare_sdk.cluster.cluster.Cluster.down" href="#codeflare_sdk.cluster.cluster.Cluster.down">down</a></code></li>
<li><code><a title="codeflare_sdk.cluster.cluster.Cluster.is_ready" href="#codeflare_sdk.cluster.cluster.Cluster.is_ready">is_ready</a></code></li>
<li><code><a title="codeflare_sdk.cluster.cluster.Cluster.job_logs" href="#codeflare_sdk.cluster.cluster.Cluster.job_logs">job_logs</a></code></li>
<li><code><a title="codeflare_sdk.cluster.cluster.Cluster.job_status" href="#codeflare_sdk.cluster.cluster.Cluster.job_status">job_status</a></code></li>
<li><code><a title="codeflare_sdk.cluster.cluster.Cluster.list_jobs" href="#codeflare_sdk.cluster.cluster.Cluster.list_jobs">list_jobs</a></code></li>
<li><code><a title="codeflare_sdk.cluster.cluster.Cluster.status" href="#codeflare_sdk.cluster.cluster.Cluster.status">status</a></code></li>
<li><code><a title="codeflare_sdk.cluster.cluster.Cluster.up" href="#codeflare_sdk.cluster.cluster.Cluster.up">up</a></code></li>
</ul>
Expand Down
6 changes: 3 additions & 3 deletions docs/cluster/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.config</code></h1>
template: str = f&#34;{dir}/templates/new-template.yaml&#34;
instascale: bool = False
envs: dict = field(default_factory=dict)
image: str = &#34;ghcr.io/ibm-ai-foundation/base:ray1.13.0-py38-gpu-pytorch1.12.0cu116-20220826-202124&#34;
image: str = &#34;ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103&#34;
auth: Authentication = Authentication()</code></pre>
</details>
</section>
Expand All @@ -93,7 +93,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="codeflare_sdk.cluster.config.ClusterConfiguration"><code class="flex name class">
<span>class <span class="ident">ClusterConfiguration</span></span>
<span>(</span><span>name: str, namespace: str = 'default', head_info: list = &lt;factory&gt;, machine_types: list = &lt;factory&gt;, 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 = &lt;factory&gt;, image: str = 'ghcr.io/ibm-ai-foundation/base:ray1.13.0-py38-gpu-pytorch1.12.0cu116-20220826-202124', auth: <a title="codeflare_sdk.cluster.auth.Authentication" href="auth.html#codeflare_sdk.cluster.auth.Authentication">Authentication</a> = &lt;codeflare_sdk.cluster.auth.Authentication object&gt;)</span>
<span>(</span><span>name: str, namespace: str = 'default', head_info: list = &lt;factory&gt;, machine_types: list = &lt;factory&gt;, 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 = &lt;factory&gt;, image: str = 'ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103', auth: <a title="codeflare_sdk.cluster.auth.Authentication" href="auth.html#codeflare_sdk.cluster.auth.Authentication">Authentication</a> = &lt;codeflare_sdk.cluster.auth.Authentication object&gt;)</span>
</code></dt>
<dd>
<div class="desc"><p>This dataclass is used to specify resource requirements and other details, and
Expand Down Expand Up @@ -122,7 +122,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
template: str = f&#34;{dir}/templates/new-template.yaml&#34;
instascale: bool = False
envs: dict = field(default_factory=dict)
image: str = &#34;ghcr.io/ibm-ai-foundation/base:ray1.13.0-py38-gpu-pytorch1.12.0cu116-20220826-202124&#34;
image: str = &#34;ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103&#34;
auth: Authentication = Authentication()</code></pre>
</details>
<h3>Class variables</h3>
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"