Skip to content

Commit

Permalink
Changes in docs for release: v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
codeflare-machine-account authored and openshift-merge-robot committed Aug 29, 2023
1 parent ba780da commit 89e6c5b
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 6 deletions.
36 changes: 34 additions & 2 deletions docs/cluster/auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>

import abc
from kubernetes import client, config
import os
from ..utils.kube_api_helpers import _kube_api_error_handling

global api_client
api_client = None
Expand Down Expand Up @@ -194,8 +196,23 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
&#34;&#34;&#34;
global config_path
global api_client
home_directory = os.path.expanduser(&#34;~&#34;)
if config_path == None and api_client == None:
config.load_kube_config()
if os.path.isfile(&#34;%s/.kube/config&#34; % home_directory):
try:
config.load_kube_config()
except Exception as e: # pragma: no cover
_kube_api_error_handling(e)
elif &#34;KUBERNETES_PORT&#34; in os.environ:
try:
config.load_incluster_config()
except Exception as e: # pragma: no cover
_kube_api_error_handling(e)
else:
raise PermissionError(
&#34;Action not permitted, have you put in correct/up-to-date auth credentials?&#34;
)

if config_path != None and api_client == None:
return config_path

Expand Down Expand Up @@ -253,8 +270,23 @@ <h2 class="section-title" id="header-functions">Functions</h2>
&#34;&#34;&#34;
global config_path
global api_client
home_directory = os.path.expanduser(&#34;~&#34;)
if config_path == None and api_client == None:
config.load_kube_config()
if os.path.isfile(&#34;%s/.kube/config&#34; % home_directory):
try:
config.load_kube_config()
except Exception as e: # pragma: no cover
_kube_api_error_handling(e)
elif &#34;KUBERNETES_PORT&#34; in os.environ:
try:
config.load_incluster_config()
except Exception as e: # pragma: no cover
_kube_api_error_handling(e)
else:
raise PermissionError(
&#34;Action not permitted, have you put in correct/up-to-date auth credentials?&#34;
)

if config_path != None and api_client == None:
return config_path</code></pre>
</details>
Expand Down
145 changes: 145 additions & 0 deletions docs/cluster/cluster.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,39 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
self.app_wrapper_yaml = self.create_app_wrapper()
self.app_wrapper_name = self.app_wrapper_yaml.split(&#34;.&#34;)[0]

def evaluate_config(self):
if not self.evaluate_dispatch_priority():
return False
else:
return True

def evaluate_dispatch_priority(self):
priority_class = self.config.dispatch_priority
if priority_class is None:
return True
else:
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
priority_classes = api_instance.list_cluster_custom_object(
group=&#34;scheduling.k8s.io&#34;,
version=&#34;v1&#34;,
plural=&#34;priorityclasses&#34;,
)
available_priority_classes = [
i[&#34;metadata&#34;][&#34;name&#34;] for i in priority_classes[&#34;items&#34;]
]
except Exception as e: # pragma: no cover
return _kube_api_error_handling(e)

if priority_class in available_priority_classes:
return True
else:
print(
f&#34;Priority class {priority_class} is not available in the cluster&#34;
)
return False

def create_app_wrapper(self):
&#34;&#34;&#34;
Called upon cluster object creation, creates an AppWrapper yaml based on
Expand Down Expand Up @@ -123,6 +156,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
env = self.config.envs
local_interactive = self.config.local_interactive
image_pull_secrets = self.config.image_pull_secrets
dispatch_priority = self.config.dispatch_priority
return generate_appwrapper(
name=name,
namespace=namespace,
Expand All @@ -139,6 +173,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
env=env,
local_interactive=local_interactive,
image_pull_secrets=image_pull_secrets,
dispatch_priority=dispatch_priority,
)

# creates a new cluster with the provided or default spec
Expand All @@ -147,6 +182,12 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
Applies the AppWrapper yaml, pushing the resource request onto
the MCAD queue.
&#34;&#34;&#34;

# Before attempting to bring up the cluster let&#39;s evaluate the ClusterConfig
if not self.evaluate_config():
print(&#34;Invalid Cluster Configuration&#34;)
return False

namespace = self.config.namespace
try:
config_check()
Expand Down Expand Up @@ -787,6 +828,39 @@ <h2 class="section-title" id="header-classes">Classes</h2>
self.app_wrapper_yaml = self.create_app_wrapper()
self.app_wrapper_name = self.app_wrapper_yaml.split(&#34;.&#34;)[0]

def evaluate_config(self):
if not self.evaluate_dispatch_priority():
return False
else:
return True

def evaluate_dispatch_priority(self):
priority_class = self.config.dispatch_priority
if priority_class is None:
return True
else:
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
priority_classes = api_instance.list_cluster_custom_object(
group=&#34;scheduling.k8s.io&#34;,
version=&#34;v1&#34;,
plural=&#34;priorityclasses&#34;,
)
available_priority_classes = [
i[&#34;metadata&#34;][&#34;name&#34;] for i in priority_classes[&#34;items&#34;]
]
except Exception as e: # pragma: no cover
return _kube_api_error_handling(e)

if priority_class in available_priority_classes:
return True
else:
print(
f&#34;Priority class {priority_class} is not available in the cluster&#34;
)
return False

def create_app_wrapper(self):
&#34;&#34;&#34;
Called upon cluster object creation, creates an AppWrapper yaml based on
Expand Down Expand Up @@ -817,6 +891,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
env = self.config.envs
local_interactive = self.config.local_interactive
image_pull_secrets = self.config.image_pull_secrets
dispatch_priority = self.config.dispatch_priority
return generate_appwrapper(
name=name,
namespace=namespace,
Expand All @@ -833,6 +908,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
env=env,
local_interactive=local_interactive,
image_pull_secrets=image_pull_secrets,
dispatch_priority=dispatch_priority,
)

# creates a new cluster with the provided or default spec
Expand All @@ -841,6 +917,12 @@ <h2 class="section-title" id="header-classes">Classes</h2>
Applies the AppWrapper yaml, pushing the resource request onto
the MCAD queue.
&#34;&#34;&#34;

# Before attempting to bring up the cluster let&#39;s evaluate the ClusterConfig
if not self.evaluate_config():
print(&#34;Invalid Cluster Configuration&#34;)
return False

namespace = self.config.namespace
try:
config_check()
Expand Down Expand Up @@ -1181,6 +1263,7 @@ <h3>Methods</h3>
env = self.config.envs
local_interactive = self.config.local_interactive
image_pull_secrets = self.config.image_pull_secrets
dispatch_priority = self.config.dispatch_priority
return generate_appwrapper(
name=name,
namespace=namespace,
Expand All @@ -1197,6 +1280,7 @@ <h3>Methods</h3>
env=env,
local_interactive=local_interactive,
image_pull_secrets=image_pull_secrets,
dispatch_priority=dispatch_priority,
)</code></pre>
</details>
</dd>
Expand Down Expand Up @@ -1246,6 +1330,59 @@ <h3>Methods</h3>
return _kube_api_error_handling(e)</code></pre>
</details>
</dd>
<dt id="codeflare_sdk.cluster.cluster.Cluster.evaluate_config"><code class="name flex">
<span>def <span class="ident">evaluate_config</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def evaluate_config(self):
if not self.evaluate_dispatch_priority():
return False
else:
return True</code></pre>
</details>
</dd>
<dt id="codeflare_sdk.cluster.cluster.Cluster.evaluate_dispatch_priority"><code class="name flex">
<span>def <span class="ident">evaluate_dispatch_priority</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def evaluate_dispatch_priority(self):
priority_class = self.config.dispatch_priority
if priority_class is None:
return True
else:
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
priority_classes = api_instance.list_cluster_custom_object(
group=&#34;scheduling.k8s.io&#34;,
version=&#34;v1&#34;,
plural=&#34;priorityclasses&#34;,
)
available_priority_classes = [
i[&#34;metadata&#34;][&#34;name&#34;] for i in priority_classes[&#34;items&#34;]
]
except Exception as e: # pragma: no cover
return _kube_api_error_handling(e)

if priority_class in available_priority_classes:
return True
else:
print(
f&#34;Priority class {priority_class} is not available in the cluster&#34;
)
return False</code></pre>
</details>
</dd>
<dt id="codeflare_sdk.cluster.cluster.Cluster.from_k8_cluster_object"><code class="name flex">
<span>def <span class="ident">from_k8_cluster_object</span></span>(<span>rc)</span>
</code></dt>
Expand Down Expand Up @@ -1486,6 +1623,12 @@ <h3>Methods</h3>
Applies the AppWrapper yaml, pushing the resource request onto
the MCAD queue.
&#34;&#34;&#34;

# Before attempting to bring up the cluster let&#39;s evaluate the ClusterConfig
if not self.evaluate_config():
print(&#34;Invalid Cluster Configuration&#34;)
return False

namespace = self.config.namespace
try:
config_check()
Expand Down Expand Up @@ -1570,6 +1713,8 @@ <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.details" href="#codeflare_sdk.cluster.cluster.Cluster.details">details</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.evaluate_config" href="#codeflare_sdk.cluster.cluster.Cluster.evaluate_config">evaluate_config</a></code></li>
<li><code><a title="codeflare_sdk.cluster.cluster.Cluster.evaluate_dispatch_priority" href="#codeflare_sdk.cluster.cluster.Cluster.evaluate_dispatch_priority">evaluate_dispatch_priority</a></code></li>
<li><code><a title="codeflare_sdk.cluster.cluster.Cluster.from_k8_cluster_object" href="#codeflare_sdk.cluster.cluster.Cluster.from_k8_cluster_object">from_k8_cluster_object</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>
Expand Down
13 changes: 10 additions & 3 deletions docs/cluster/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.config</code></h1>
envs: dict = field(default_factory=dict)
image: str = &#34;quay.io/project-codeflare/ray:2.5.0-py38-cu116&#34;
local_interactive: bool = False
image_pull_secrets: list = field(default_factory=list)</code></pre>
image_pull_secrets: list = field(default_factory=list)
dispatch_priority: str = None</code></pre>
</details>
</section>
<section>
Expand All @@ -92,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 = None, head_info: list = &lt;factory&gt;, machine_types: list = &lt;factory&gt;, min_cpus: int = 1, max_cpus: int = 1, num_workers: int = 1, min_memory: int = 2, max_memory: int = 2, num_gpus: int = 0, template: str = '/home/runner/work/codeflare-sdk/codeflare-sdk/src/codeflare_sdk/templates/base-template.yaml', instascale: bool = False, envs: dict = &lt;factory&gt;, image: str = 'quay.io/project-codeflare/ray:2.5.0-py38-cu116', local_interactive: bool = False, image_pull_secrets: list = &lt;factory&gt;)</span>
<span>(</span><span>name: str, namespace: str = None, head_info: list = &lt;factory&gt;, machine_types: list = &lt;factory&gt;, min_cpus: int = 1, max_cpus: int = 1, num_workers: int = 1, min_memory: int = 2, max_memory: int = 2, num_gpus: int = 0, template: str = '/home/runner/work/codeflare-sdk/codeflare-sdk/src/codeflare_sdk/templates/base-template.yaml', instascale: bool = False, envs: dict = &lt;factory&gt;, image: str = 'quay.io/project-codeflare/ray:2.5.0-py38-cu116', local_interactive: bool = False, image_pull_secrets: list = &lt;factory&gt;, dispatch_priority: str = None)</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,10 +123,15 @@ <h2 class="section-title" id="header-classes">Classes</h2>
envs: dict = field(default_factory=dict)
image: str = &#34;quay.io/project-codeflare/ray:2.5.0-py38-cu116&#34;
local_interactive: bool = False
image_pull_secrets: list = field(default_factory=list)</code></pre>
image_pull_secrets: list = field(default_factory=list)
dispatch_priority: str = None</code></pre>
</details>
<h3>Class variables</h3>
<dl>
<dt id="codeflare_sdk.cluster.config.ClusterConfiguration.dispatch_priority"><code class="name">var <span class="ident">dispatch_priority</span> : str</code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="codeflare_sdk.cluster.config.ClusterConfiguration.envs"><code class="name">var <span class="ident">envs</span> : dict</code></dt>
<dd>
<div class="desc"></div>
Expand Down Expand Up @@ -211,6 +217,7 @@ <h1>Index</h1>
<li>
<h4><code><a title="codeflare_sdk.cluster.config.ClusterConfiguration" href="#codeflare_sdk.cluster.config.ClusterConfiguration">ClusterConfiguration</a></code></h4>
<ul class="two-column">
<li><code><a title="codeflare_sdk.cluster.config.ClusterConfiguration.dispatch_priority" href="#codeflare_sdk.cluster.config.ClusterConfiguration.dispatch_priority">dispatch_priority</a></code></li>
<li><code><a title="codeflare_sdk.cluster.config.ClusterConfiguration.envs" href="#codeflare_sdk.cluster.config.ClusterConfiguration.envs">envs</a></code></li>
<li><code><a title="codeflare_sdk.cluster.config.ClusterConfiguration.head_info" href="#codeflare_sdk.cluster.config.ClusterConfiguration.head_info">head_info</a></code></li>
<li><code><a title="codeflare_sdk.cluster.config.ClusterConfiguration.image" href="#codeflare_sdk.cluster.config.ClusterConfiguration.image">image</a></code></li>
Expand Down
Loading

0 comments on commit 89e6c5b

Please sign in to comment.