Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/coverage-badge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Coverage Badge

on:
push:
branches: [ main ]
branches: [ main, ray-jobs-feature ]

jobs:
report:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
branches:
- main
- 'release-*'
- ray-jobs-feature
paths-ignore:
- 'docs/**'
- '**.adoc'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Python Tests

on:
pull_request:
branches: [ main ]
branches: [ main, ray-jobs-feature ]
push:
branches: [ main ]
branches: [ main, ray-jobs-feature ]

jobs:
unit-tests:
Expand Down
4 changes: 2 additions & 2 deletions coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion demo-notebooks/additional-demos/hf_interactive.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"metadata": {},
"outputs": [],
"source": [
"cluster.up()"
"cluster.apply()"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion demo-notebooks/additional-demos/local_interactive.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
},
"outputs": [],
"source": [
"cluster.up()"
"cluster.apply()"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion demo-notebooks/additional-demos/ray_job_client.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"outputs": [],
"source": [
"# Bring up the cluster\n",
"cluster.up()\n",
"cluster.apply()\n",
"cluster.wait_ready()"
]
},
Expand Down
2 changes: 1 addition & 1 deletion demo-notebooks/guided-demos/0_basic_ray.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"outputs": [],
"source": [
"# Bring up the cluster\n",
"cluster.up()"
"cluster.apply()"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion demo-notebooks/guided-demos/1_cluster_job_client.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"outputs": [],
"source": [
"# Bring up the cluster\n",
"cluster.up()\n",
"cluster.apply()\n",
"cluster.wait_ready()"
]
},
Expand Down
2 changes: 1 addition & 1 deletion demo-notebooks/guided-demos/2_basic_interactive.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"outputs": [],
"source": [
"# Bring up the cluster\n",
"cluster.up()\n",
"cluster.apply()\n",
"cluster.wait_ready()"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"outputs": [],
"source": [
"# Bring up the cluster\n",
"cluster.up()"
"cluster.apply()"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"outputs": [],
"source": [
"# Bring up the cluster\n",
"cluster.up()\n",
"cluster.apply()\n",
"cluster.wait_ready()"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"outputs": [],
"source": [
"# Bring up the cluster\n",
"cluster.up()\n",
"cluster.apply()\n",
"cluster.wait_ready()"
]
},
Expand Down
2 changes: 1 addition & 1 deletion demo-notebooks/guided-demos/preview_nbs/0_basic_ray.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"outputs": [],
"source": [
"# Bring up the cluster\n",
"cluster.up()"
"cluster.apply()"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"outputs": [],
"source": [
"# Bring up the cluster\n",
"cluster.up()\n",
"cluster.apply()\n",
"cluster.wait_ready()"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"outputs": [],
"source": [
"# Bring up the cluster\n",
"cluster.up()\n",
"cluster.apply()\n",
"cluster.wait_ready()"
]
},
Expand Down
1,362 changes: 701 additions & 661 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ cryptography = "43.0.3"
executing = "1.2.0"
pydantic = "< 2"
ipywidgets = "8.1.2"
odh-kuberay-client = {version = "0.0.0.dev40", source = "testpypi"}

[[tool.poetry.source]]
name = "pypi"

[[tool.poetry.source]]
name = "testpypi"
url = "https://test.pypi.org/simple/"

[tool.poetry.group.docs]
optional = true
Expand Down
1 change: 1 addition & 0 deletions src/codeflare_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
AWManager,
AppWrapperStatus,
RayJobClient,
RayJob,
)

from .common.widgets import view_clusters
Expand Down
20 changes: 11 additions & 9 deletions src/codeflare_sdk/common/widgets/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@patch.dict(
"os.environ", {"JPY_SESSION_NAME": "example-test"}
) # Mock Jupyter environment variable
def test_cluster_up_down_buttons(mocker):
def test_cluster_apply_down_buttons(mocker):
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
mocker.patch(
"kubernetes.client.CustomObjectsApi.get_cluster_custom_object",
Expand All @@ -45,36 +45,38 @@ def test_cluster_up_down_buttons(mocker):
) as MockCheckbox, patch("ipywidgets.Output"), patch("ipywidgets.HBox"), patch(
"ipywidgets.VBox"
), patch.object(
cluster, "up"
) as mock_up, patch.object(
cluster, "apply"
) as mock_apply, patch.object(
cluster, "down"
) as mock_down, patch.object(
cluster, "wait_ready"
) as mock_wait_ready:
# Create mock button & CheckBox instances
mock_up_button = MagicMock()
mock_apply_button = MagicMock()
mock_down_button = MagicMock()
mock_wait_ready_check_box = MagicMock()

# Ensure the mock Button class returns the mock button instances in sequence
MockCheckbox.side_effect = [mock_wait_ready_check_box]
MockButton.side_effect = [mock_up_button, mock_down_button]
MockButton.side_effect = [mock_apply_button, mock_down_button]

# Call the method under test
cf_widgets.cluster_up_down_buttons(cluster)
cf_widgets.cluster_apply_down_buttons(cluster)

# Simulate checkbox being checked or unchecked
mock_wait_ready_check_box.value = True # Simulate checkbox being checked

# Simulate the button clicks by calling the mock on_click handlers
mock_up_button.on_click.call_args[0][0](None) # Simulate clicking "Cluster Up"
mock_apply_button.on_click.call_args[0][0](
None
) # Simulate clicking "Cluster Apply"
mock_down_button.on_click.call_args[0][0](
None
) # Simulate clicking "Cluster Down"

# Check if the `up` and `down` methods were called
# Check if the `apply` and `down` methods were called
mock_wait_ready.assert_called_once()
mock_up.assert_called_once()
mock_apply.assert_called_once()
mock_down.assert_called_once()


Expand Down
16 changes: 8 additions & 8 deletions src/codeflare_sdk/common/widgets/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,19 @@ def display_widgets(self):
)


def cluster_up_down_buttons(
def cluster_apply_down_buttons(
cluster: "codeflare_sdk.ray.cluster.cluster.Cluster",
) -> widgets.Button:
"""
The cluster_up_down_buttons function returns two button widgets for a create and delete button.
The cluster_apply_down_buttons function returns two button widgets for a create and delete button.
The function uses the appwrapper bool to distinguish between resource type for the tool tip.
"""
resource = "Ray Cluster"
if cluster.config.appwrapper:
resource = "AppWrapper"

up_button = widgets.Button(
description="Cluster Up",
apply_button = widgets.Button(
description="Cluster Apply",
tooltip=f"Create the {resource}",
icon="play",
)
Expand All @@ -298,13 +298,13 @@ def cluster_up_down_buttons(
output = widgets.Output()

# Display the buttons in an HBox wrapped in a VBox which includes the wait_ready Checkbox
button_display = widgets.HBox([up_button, delete_button])
button_display = widgets.HBox([apply_button, delete_button])
display(widgets.VBox([button_display, wait_ready_check]), output)

def on_up_button_clicked(b): # Handle the up button click event
def on_apply_button_clicked(b): # Handle the apply button click event
with output:
output.clear_output()
cluster.up()
cluster.apply()

# If the wait_ready Checkbox is clicked(value == True) trigger the wait_ready function
if wait_ready_check.value:
Expand All @@ -315,7 +315,7 @@ def on_down_button_clicked(b): # Handle the down button click event
output.clear_output()
cluster.down()

up_button.on_click(on_up_button_clicked)
apply_button.on_click(on_apply_button_clicked)
delete_button.on_click(on_down_button_clicked)


Expand Down
7 changes: 7 additions & 0 deletions src/codeflare_sdk/ray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
RayJobClient,
)

from .rayjobs import (
RayJob,
RayJobDeploymentStatus,
CodeflareRayJobStatus,
RayJobInfo,
)

from .cluster import (
Cluster,
ClusterConfiguration,
Expand Down
2 changes: 2 additions & 0 deletions src/codeflare_sdk/ray/cluster/build_ray_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def build_ray_cluster(cluster: "codeflare_sdk.ray.cluster.Cluster"):
"enableIngress": False,
"rayStartParams": {
"dashboard-host": "0.0.0.0",
"dashboard-port": "8265",
"block": "true",
"num-gpus": str(head_gpu_count),
"resources": head_resources,
Expand Down Expand Up @@ -245,6 +246,7 @@ def get_labels(cluster: "codeflare_sdk.ray.cluster.Cluster"):
"""
labels = {
"controller-tools.k8s.io": "1.0",
"ray.io/cluster": cluster.config.name, # Enforced label always present
}
if cluster.config.labels != {}:
labels.update(cluster.config.labels)
Expand Down
12 changes: 8 additions & 4 deletions src/codeflare_sdk/ray/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@

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

from ray.job_submission import JobSubmissionClient
from ray.job_submission import JobSubmissionClient, JobStatus
import time
import uuid
import warnings

from ...common.kubernetes_cluster.auth import (
config_check,
Expand All @@ -43,7 +47,7 @@
AppWrapperStatus,
)
from ...common.widgets.widgets import (
cluster_up_down_buttons,
cluster_apply_down_buttons,
is_notebook,
)
from kubernetes import client
Expand All @@ -57,7 +61,6 @@
from kubernetes.client.rest import ApiException

from kubernetes.client.rest import ApiException
import warnings

CF_SDK_FIELD_MANAGER = "codeflare-sdk"

Expand Down Expand Up @@ -88,7 +91,7 @@ def __init__(self, config: ClusterConfiguration):
self.resource_yaml = self.create_resource()

if is_notebook():
cluster_up_down_buttons(self)
cluster_apply_down_buttons(self)

def get_dynamic_client(self): # pragma: no cover
return DynamicClient(get_api_client())
Expand Down Expand Up @@ -760,6 +763,7 @@ def get_cluster(
head_extended_resource_requests=head_extended_resources,
worker_extended_resource_requests=worker_extended_resources,
)

# Ignore the warning here for the lack of a ClusterConfiguration
with warnings.catch_warnings():
warnings.filterwarnings(
Expand Down
10 changes: 8 additions & 2 deletions src/codeflare_sdk/ray/cluster/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,5 +758,11 @@ def custom_side_effect(group, version, namespace, plural, **kwargs):

# Make sure to always keep this function last
def test_cleanup():
os.remove(f"{aw_dir}test-all-params.yaml")
os.remove(f"{aw_dir}aw-all-params.yaml")
# Remove files only if they exist
test_file = f"{aw_dir}test-all-params.yaml"
if os.path.exists(test_file):
os.remove(test_file)

aw_file = f"{aw_dir}aw-all-params.yaml"
if os.path.exists(aw_file):
os.remove(aw_file)
2 changes: 2 additions & 0 deletions src/codeflare_sdk/ray/rayjobs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .rayjob import RayJob
from .status import RayJobDeploymentStatus, CodeflareRayJobStatus, RayJobInfo
Loading