Skip to content

Commit

Permalink
Changes in docs for release: v0.16.1
Browse files Browse the repository at this point in the history
  • Loading branch information
codeflare-machine-account authored and openshift-merge-bot[bot] committed May 13, 2024
1 parent f69d5e4 commit 7e87599
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 104 deletions.
158 changes: 98 additions & 60 deletions docs/detailed-documentation/cluster/cluster.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
cluster setup queue, a list of all existing clusters, and the user&#39;s working namespace.
&#34;&#34;&#34;

import re
from time import sleep
from typing import List, Optional, Tuple, Dict

Expand All @@ -73,11 +74,13 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
RayClusterStatus,
)
from kubernetes import client, config
from kubernetes.utils import parse_quantity
import yaml
import os
import requests

from kubernetes import config
from kubernetes.client.rest import ApiException


class Cluster:
Expand Down Expand Up @@ -216,6 +219,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
write_to_file = self.config.write_to_file
verify_tls = self.config.verify_tls
local_queue = self.config.local_queue
labels = self.config.labels
return generate_appwrapper(
name=name,
namespace=namespace,
Expand All @@ -240,6 +244,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
write_to_file=write_to_file,
verify_tls=verify_tls,
local_queue=local_queue,
labels=labels,
)

# creates a new cluster with the provided or default spec
Expand All @@ -248,6 +253,10 @@ <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;

# check if RayCluster CustomResourceDefinition exists if not throw RuntimeError
self._throw_for_no_raycluster()

namespace = self.config.namespace

try:
Expand Down Expand Up @@ -278,12 +287,32 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
except Exception as e: # pragma: no cover
return _kube_api_error_handling(e)

def _throw_for_no_raycluster(self):
api_instance = client.CustomObjectsApi(api_config_handler())
try:
api_instance.list_namespaced_custom_object(
group=&#34;ray.io&#34;,
version=&#34;v1&#34;,
namespace=self.config.namespace,
plural=&#34;rayclusters&#34;,
)
except ApiException as e:
if e.status == 404:
raise RuntimeError(
&#34;RayCluster CustomResourceDefinition unavailable contact your administrator.&#34;
)
else:
raise RuntimeError(
&#34;Failed to get RayCluster CustomResourceDefinition: &#34; + str(e)
)

def down(self):
&#34;&#34;&#34;
Deletes the AppWrapper yaml, scaling-down and deleting all resources
associated with the cluster.
&#34;&#34;&#34;
namespace = self.config.namespace
self._throw_for_no_raycluster()
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
Expand Down Expand Up @@ -520,26 +549,18 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
namespace=rc[&#34;metadata&#34;][&#34;namespace&#34;],
machine_types=machine_types,
num_workers=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;minReplicas&#34;],
min_cpus=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;requests&#34;][&#34;cpu&#34;]
),
max_cpus=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;limits&#34;][&#34;cpu&#34;]
),
min_memory=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;requests&#34;][&#34;memory&#34;][:-1]
),
max_memory=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;limits&#34;][&#34;memory&#34;][:-1]
),
min_cpus=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;requests&#34;][&#34;cpu&#34;],
max_cpus=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;limits&#34;][&#34;cpu&#34;],
min_memory=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;requests&#34;][&#34;memory&#34;],
max_memory=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;limits&#34;][&#34;memory&#34;],
num_gpus=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
Expand Down Expand Up @@ -1265,6 +1286,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
write_to_file = self.config.write_to_file
verify_tls = self.config.verify_tls
local_queue = self.config.local_queue
labels = self.config.labels
return generate_appwrapper(
name=name,
namespace=namespace,
Expand All @@ -1289,6 +1311,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
write_to_file=write_to_file,
verify_tls=verify_tls,
local_queue=local_queue,
labels=labels,
)

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

# check if RayCluster CustomResourceDefinition exists if not throw RuntimeError
self._throw_for_no_raycluster()

namespace = self.config.namespace

try:
Expand Down Expand Up @@ -1327,12 +1354,32 @@ <h2 class="section-title" id="header-classes">Classes</h2>
except Exception as e: # pragma: no cover
return _kube_api_error_handling(e)

def _throw_for_no_raycluster(self):
api_instance = client.CustomObjectsApi(api_config_handler())
try:
api_instance.list_namespaced_custom_object(
group=&#34;ray.io&#34;,
version=&#34;v1&#34;,
namespace=self.config.namespace,
plural=&#34;rayclusters&#34;,
)
except ApiException as e:
if e.status == 404:
raise RuntimeError(
&#34;RayCluster CustomResourceDefinition unavailable contact your administrator.&#34;
)
else:
raise RuntimeError(
&#34;Failed to get RayCluster CustomResourceDefinition: &#34; + str(e)
)

def down(self):
&#34;&#34;&#34;
Deletes the AppWrapper yaml, scaling-down and deleting all resources
associated with the cluster.
&#34;&#34;&#34;
namespace = self.config.namespace
self._throw_for_no_raycluster()
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
Expand Down Expand Up @@ -1569,26 +1616,18 @@ <h2 class="section-title" id="header-classes">Classes</h2>
namespace=rc[&#34;metadata&#34;][&#34;namespace&#34;],
machine_types=machine_types,
num_workers=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;minReplicas&#34;],
min_cpus=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;requests&#34;][&#34;cpu&#34;]
),
max_cpus=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;limits&#34;][&#34;cpu&#34;]
),
min_memory=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;requests&#34;][&#34;memory&#34;][:-1]
),
max_memory=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;limits&#34;][&#34;memory&#34;][:-1]
),
min_cpus=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;requests&#34;][&#34;cpu&#34;],
max_cpus=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;limits&#34;][&#34;cpu&#34;],
min_memory=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;requests&#34;][&#34;memory&#34;],
max_memory=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;limits&#34;][&#34;memory&#34;],
num_gpus=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
Expand Down Expand Up @@ -1811,6 +1850,7 @@ <h3>Methods</h3>
write_to_file = self.config.write_to_file
verify_tls = self.config.verify_tls
local_queue = self.config.local_queue
labels = self.config.labels
return generate_appwrapper(
name=name,
namespace=namespace,
Expand All @@ -1835,6 +1875,7 @@ <h3>Methods</h3>
write_to_file=write_to_file,
verify_tls=verify_tls,
local_queue=local_queue,
labels=labels,
)</code></pre>
</details>
</dd>
Expand Down Expand Up @@ -1870,6 +1911,7 @@ <h3>Methods</h3>
associated with the cluster.
&#34;&#34;&#34;
namespace = self.config.namespace
self._throw_for_no_raycluster()
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
Expand Down Expand Up @@ -1944,26 +1986,18 @@ <h3>Methods</h3>
namespace=rc[&#34;metadata&#34;][&#34;namespace&#34;],
machine_types=machine_types,
num_workers=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;minReplicas&#34;],
min_cpus=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;requests&#34;][&#34;cpu&#34;]
),
max_cpus=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;limits&#34;][&#34;cpu&#34;]
),
min_memory=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;requests&#34;][&#34;memory&#34;][:-1]
),
max_memory=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;limits&#34;][&#34;memory&#34;][:-1]
),
min_cpus=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;requests&#34;][&#34;cpu&#34;],
max_cpus=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;limits&#34;][&#34;cpu&#34;],
min_memory=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;requests&#34;][&#34;memory&#34;],
max_memory=rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][
&#34;containers&#34;
][0][&#34;resources&#34;][&#34;limits&#34;][&#34;memory&#34;],
num_gpus=int(
rc[&#34;spec&#34;][&#34;workerGroupSpecs&#34;][0][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
Expand Down Expand Up @@ -2168,6 +2202,10 @@ <h3>Methods</h3>
Applies the AppWrapper yaml, pushing the resource request onto
the MCAD queue.
&#34;&#34;&#34;

# check if RayCluster CustomResourceDefinition exists if not throw RuntimeError
self._throw_for_no_raycluster()

namespace = self.config.namespace

try:
Expand Down
Loading

0 comments on commit 7e87599

Please sign in to comment.