Skip to content

Changes in docs for release: v0.11.0 #391

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
Oct 31, 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
192 changes: 101 additions & 91 deletions docs/cluster/cluster.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>

from .auth import config_check, api_config_handler
from ..utils import pretty_print
from ..utils.generate_yaml import generate_appwrapper
from ..utils.generate_yaml import (
generate_appwrapper,
)
from ..utils.kube_api_helpers import _kube_api_error_handling
from ..utils.openshift_oauth import (
create_openshift_oauth_objects,
Expand Down Expand Up @@ -207,6 +209,8 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
local_interactive = self.config.local_interactive
image_pull_secrets = self.config.image_pull_secrets
dispatch_priority = self.config.dispatch_priority
ingress_domain = self.config.ingress_domain
ingress_options = self.config.ingress_options
return generate_appwrapper(
name=name,
namespace=namespace,
Expand All @@ -230,6 +234,8 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
dispatch_priority=dispatch_priority,
priority_val=priority_val,
openshift_oauth=self.config.openshift_oauth,
ingress_domain=ingress_domain,
ingress_options=ingress_options,
)

# creates a new cluster with the provided or default spec
Expand Down Expand Up @@ -368,7 +374,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
timeout=5,
verify=self._client_verify_tls,
)
except requests.exceptions.SSLError:
except requests.exceptions.SSLError: # pragma no cover
# SSL exception occurs when oauth ingress has been created but cluster is not up
return False
if response.status_code == 200:
Expand Down Expand Up @@ -431,27 +437,24 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
&#34;&#34;&#34;
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
routes = api_instance.list_namespaced_custom_object(
group=&#34;route.openshift.io&#34;,
version=&#34;v1&#34;,
namespace=self.config.namespace,
plural=&#34;routes&#34;,
)
except Exception as e: # pragma: no cover
api_instance = client.NetworkingV1Api(api_config_handler())
ingresses = api_instance.list_namespaced_ingress(self.config.namespace)
except Exception as e: # pragma no cover
return _kube_api_error_handling(e)

for route in routes[&#34;items&#34;]:
if route[&#34;metadata&#34;][
&#34;name&#34;
] == f&#34;ray-dashboard-{self.config.name}&#34; or route[&#34;metadata&#34;][
&#34;name&#34;
].startswith(
f&#34;{self.config.name}-ingress&#34;
for ingress in ingresses.items:
annotations = ingress.metadata.annotations
protocol = &#34;http&#34;
if (
ingress.metadata.name == f&#34;ray-dashboard-{self.config.name}&#34;
or ingress.metadata.name.startswith(f&#34;{self.config.name}-ingress&#34;)
):
protocol = &#34;https&#34; if route[&#34;spec&#34;].get(&#34;tls&#34;) else &#34;http&#34;
return f&#34;{protocol}://{route[&#39;spec&#39;][&#39;host&#39;]}&#34;
return &#34;Dashboard route not available yet, have you run cluster.up()?&#34;
if annotations == None:
protocol = &#34;http&#34;
elif &#34;route.openshift.io/termination&#34; in annotations:
protocol = &#34;https&#34;
return f&#34;{protocol}://{ingress.spec.rules[0].host}&#34;
return &#34;Dashboard ingress not available yet, have you run cluster.up()?&#34;

def list_jobs(self) -&gt; List:
&#34;&#34;&#34;
Expand Down Expand Up @@ -530,8 +533,8 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>

def local_client_url(self):
if self.config.local_interactive == True:
ingress_domain = _get_ingress_domain()
return f&#34;ray://rayclient-{self.config.name}-{self.config.namespace}.{ingress_domain}&#34;
ingress_domain = _get_ingress_domain(self)
return f&#34;ray://{ingress_domain}&#34;
else:
return &#34;None&#34;

Expand Down Expand Up @@ -687,16 +690,23 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
return False


def _get_ingress_domain():
# Cant test this until get_current_namespace is fixed
def _get_ingress_domain(self): # pragma: no cover
try:
config_check()
api_client = client.CustomObjectsApi(api_config_handler())
ingress = api_client.get_cluster_custom_object(
&#34;config.openshift.io&#34;, &#34;v1&#34;, &#34;ingresses&#34;, &#34;cluster&#34;
)
api_client = client.NetworkingV1Api(api_config_handler())
if self.config.namespace != None:
namespace = self.config.namespace
else:
namespace = get_current_namespace()
ingresses = api_client.list_namespaced_ingress(namespace)
except Exception as e: # pragma: no cover
return _kube_api_error_handling(e)
return ingress[&#34;spec&#34;][&#34;domain&#34;]
domain = None
for ingress in ingresses.items:
if ingress.spec.rules[0].http.paths[0].backend.service.port.number == 10001:
domain = ingress.spec.rules[0].host
return domain


def _app_wrapper_status(name, namespace=&#34;default&#34;) -&gt; Optional[AppWrapper]:
Expand Down Expand Up @@ -788,27 +798,25 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
status = RayClusterStatus(rc[&#34;status&#34;][&#34;state&#34;].lower())
else:
status = RayClusterStatus.UNKNOWN

config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
# UPDATE THIS
routes = api_instance.list_namespaced_custom_object(
group=&#34;route.openshift.io&#34;,
version=&#34;v1&#34;,
namespace=rc[&#34;metadata&#34;][&#34;namespace&#34;],
plural=&#34;routes&#34;,
)
ray_route = None
for route in routes[&#34;items&#34;]:
if route[&#34;metadata&#34;][
&#34;name&#34;
] == f&#34;ray-dashboard-{rc[&#39;metadata&#39;][&#39;name&#39;]}&#34; or route[&#34;metadata&#34;][
&#34;name&#34;
].startswith(
f&#34;{rc[&#39;metadata&#39;][&#39;name&#39;]}-ingress&#34;
try:
config_check()
api_instance = client.NetworkingV1Api(api_config_handler())
ingresses = api_instance.list_namespaced_ingress(rc[&#34;metadata&#34;][&#34;namespace&#34;])
except Exception as e: # pragma no cover
return _kube_api_error_handling(e)
ray_ingress = None
for ingress in ingresses.items:
annotations = ingress.metadata.annotations
protocol = &#34;http&#34;
if (
ingress.metadata.name == f&#34;ray-dashboard-{rc[&#39;metadata&#39;][&#39;name&#39;]}&#34;
or ingress.metadata.name.startswith(f&#34;{rc[&#39;metadata&#39;][&#39;name&#39;]}-ingress&#34;)
):
protocol = &#34;https&#34; if route[&#34;spec&#34;].get(&#34;tls&#34;) else &#34;http&#34;
ray_route = f&#34;{protocol}://{route[&#39;spec&#39;][&#39;host&#39;]}&#34;
if annotations == None:
protocol = &#34;http&#34;
elif &#34;route.openshift.io/termination&#34; in annotations:
protocol = &#34;https&#34;
ray_ingress = f&#34;{protocol}://{ingress.spec.rules[0].host}&#34;

return RayCluster(
name=rc[&#34;metadata&#34;][&#34;name&#34;],
Expand All @@ -826,7 +834,6 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
][&#34;resources&#34;][&#34;limits&#34;][&#34;cpu&#34;],
worker_gpu=0, # hard to detect currently how many gpus, can override it with what the user asked for
namespace=rc[&#34;metadata&#34;][&#34;namespace&#34;],
dashboard=ray_route,
head_cpus=rc[&#34;spec&#34;][&#34;headGroupSpec&#34;][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;limits&#34;][&#34;cpu&#34;],
Expand All @@ -836,6 +843,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
head_gpu=rc[&#34;spec&#34;][&#34;headGroupSpec&#34;][&#34;template&#34;][&#34;spec&#34;][&#34;containers&#34;][0][
&#34;resources&#34;
][&#34;limits&#34;][&#34;nvidia.com/gpu&#34;],
dashboard=ray_ingress,
)


Expand Down Expand Up @@ -1136,6 +1144,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
local_interactive = self.config.local_interactive
image_pull_secrets = self.config.image_pull_secrets
dispatch_priority = self.config.dispatch_priority
ingress_domain = self.config.ingress_domain
ingress_options = self.config.ingress_options
return generate_appwrapper(
name=name,
namespace=namespace,
Expand All @@ -1159,6 +1169,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
dispatch_priority=dispatch_priority,
priority_val=priority_val,
openshift_oauth=self.config.openshift_oauth,
ingress_domain=ingress_domain,
ingress_options=ingress_options,
)

# creates a new cluster with the provided or default spec
Expand Down Expand Up @@ -1297,7 +1309,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
timeout=5,
verify=self._client_verify_tls,
)
except requests.exceptions.SSLError:
except requests.exceptions.SSLError: # pragma no cover
# SSL exception occurs when oauth ingress has been created but cluster is not up
return False
if response.status_code == 200:
Expand Down Expand Up @@ -1360,27 +1372,24 @@ <h2 class="section-title" id="header-classes">Classes</h2>
&#34;&#34;&#34;
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
routes = api_instance.list_namespaced_custom_object(
group=&#34;route.openshift.io&#34;,
version=&#34;v1&#34;,
namespace=self.config.namespace,
plural=&#34;routes&#34;,
)
except Exception as e: # pragma: no cover
api_instance = client.NetworkingV1Api(api_config_handler())
ingresses = api_instance.list_namespaced_ingress(self.config.namespace)
except Exception as e: # pragma no cover
return _kube_api_error_handling(e)

for route in routes[&#34;items&#34;]:
if route[&#34;metadata&#34;][
&#34;name&#34;
] == f&#34;ray-dashboard-{self.config.name}&#34; or route[&#34;metadata&#34;][
&#34;name&#34;
].startswith(
f&#34;{self.config.name}-ingress&#34;
for ingress in ingresses.items:
annotations = ingress.metadata.annotations
protocol = &#34;http&#34;
if (
ingress.metadata.name == f&#34;ray-dashboard-{self.config.name}&#34;
or ingress.metadata.name.startswith(f&#34;{self.config.name}-ingress&#34;)
):
protocol = &#34;https&#34; if route[&#34;spec&#34;].get(&#34;tls&#34;) else &#34;http&#34;
return f&#34;{protocol}://{route[&#39;spec&#39;][&#39;host&#39;]}&#34;
return &#34;Dashboard route not available yet, have you run cluster.up()?&#34;
if annotations == None:
protocol = &#34;http&#34;
elif &#34;route.openshift.io/termination&#34; in annotations:
protocol = &#34;https&#34;
return f&#34;{protocol}://{ingress.spec.rules[0].host}&#34;
return &#34;Dashboard ingress not available yet, have you run cluster.up()?&#34;

def list_jobs(self) -&gt; List:
&#34;&#34;&#34;
Expand Down Expand Up @@ -1459,8 +1468,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>

def local_client_url(self):
if self.config.local_interactive == True:
ingress_domain = _get_ingress_domain()
return f&#34;ray://rayclient-{self.config.name}-{self.config.namespace}.{ingress_domain}&#34;
ingress_domain = _get_ingress_domain(self)
return f&#34;ray://{ingress_domain}&#34;
else:
return &#34;None&#34;

Expand Down Expand Up @@ -1580,27 +1589,24 @@ <h3>Methods</h3>
&#34;&#34;&#34;
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
routes = api_instance.list_namespaced_custom_object(
group=&#34;route.openshift.io&#34;,
version=&#34;v1&#34;,
namespace=self.config.namespace,
plural=&#34;routes&#34;,
)
except Exception as e: # pragma: no cover
api_instance = client.NetworkingV1Api(api_config_handler())
ingresses = api_instance.list_namespaced_ingress(self.config.namespace)
except Exception as e: # pragma no cover
return _kube_api_error_handling(e)

for route in routes[&#34;items&#34;]:
if route[&#34;metadata&#34;][
&#34;name&#34;
] == f&#34;ray-dashboard-{self.config.name}&#34; or route[&#34;metadata&#34;][
&#34;name&#34;
].startswith(
f&#34;{self.config.name}-ingress&#34;
for ingress in ingresses.items:
annotations = ingress.metadata.annotations
protocol = &#34;http&#34;
if (
ingress.metadata.name == f&#34;ray-dashboard-{self.config.name}&#34;
or ingress.metadata.name.startswith(f&#34;{self.config.name}-ingress&#34;)
):
protocol = &#34;https&#34; if route[&#34;spec&#34;].get(&#34;tls&#34;) else &#34;http&#34;
return f&#34;{protocol}://{route[&#39;spec&#39;][&#39;host&#39;]}&#34;
return &#34;Dashboard route not available yet, have you run cluster.up()?&#34;</code></pre>
if annotations == None:
protocol = &#34;http&#34;
elif &#34;route.openshift.io/termination&#34; in annotations:
protocol = &#34;https&#34;
return f&#34;{protocol}://{ingress.spec.rules[0].host}&#34;
return &#34;Dashboard ingress not available yet, have you run cluster.up()?&#34;</code></pre>
</details>
</dd>
<dt id="codeflare_sdk.cluster.cluster.Cluster.cluster_uri"><code class="name flex">
Expand Down Expand Up @@ -1678,6 +1684,8 @@ <h3>Methods</h3>
local_interactive = self.config.local_interactive
image_pull_secrets = self.config.image_pull_secrets
dispatch_priority = self.config.dispatch_priority
ingress_domain = self.config.ingress_domain
ingress_options = self.config.ingress_options
return generate_appwrapper(
name=name,
namespace=namespace,
Expand All @@ -1701,6 +1709,8 @@ <h3>Methods</h3>
dispatch_priority=dispatch_priority,
priority_val=priority_val,
openshift_oauth=self.config.openshift_oauth,
ingress_domain=ingress_domain,
ingress_options=ingress_options,
)</code></pre>
</details>
</dd>
Expand Down Expand Up @@ -1858,7 +1868,7 @@ <h3>Methods</h3>
timeout=5,
verify=self._client_verify_tls,
)
except requests.exceptions.SSLError:
except requests.exceptions.SSLError: # pragma no cover
# SSL exception occurs when oauth ingress has been created but cluster is not up
return False
if response.status_code == 200:
Expand Down Expand Up @@ -1926,8 +1936,8 @@ <h3>Methods</h3>
</summary>
<pre><code class="python">def local_client_url(self):
if self.config.local_interactive == True:
ingress_domain = _get_ingress_domain()
return f&#34;ray://rayclient-{self.config.name}-{self.config.namespace}.{ingress_domain}&#34;
ingress_domain = _get_ingress_domain(self)
return f&#34;ray://{ingress_domain}&#34;
else:
return &#34;None&#34;</code></pre>
</details>
Expand Down
Loading