Skip to content

Commit 0ac44ed

Browse files
LilyLinhopenshift-merge-bot[bot]
authored andcommitted
Change widget fromt cluster.up() to cluster.apply()
1 parent 89c47c3 commit 0ac44ed

File tree

4 files changed

+30
-28
lines changed

4 files changed

+30
-28
lines changed

src/codeflare_sdk/common/widgets/test_widgets.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@patch.dict(
2929
"os.environ", {"JPY_SESSION_NAME": "example-test"}
3030
) # Mock Jupyter environment variable
31-
def test_cluster_up_down_buttons(mocker):
31+
def test_cluster_apply_down_buttons(mocker):
3232
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
3333
mocker.patch(
3434
"kubernetes.client.CustomObjectsApi.get_cluster_custom_object",
@@ -45,36 +45,38 @@ def test_cluster_up_down_buttons(mocker):
4545
) as MockCheckbox, patch("ipywidgets.Output"), patch("ipywidgets.HBox"), patch(
4646
"ipywidgets.VBox"
4747
), patch.object(
48-
cluster, "up"
49-
) as mock_up, patch.object(
48+
cluster, "apply"
49+
) as mock_apply, patch.object(
5050
cluster, "down"
5151
) as mock_down, patch.object(
5252
cluster, "wait_ready"
5353
) as mock_wait_ready:
5454
# Create mock button & CheckBox instances
55-
mock_up_button = MagicMock()
55+
mock_apply_button = MagicMock()
5656
mock_down_button = MagicMock()
5757
mock_wait_ready_check_box = MagicMock()
5858

5959
# Ensure the mock Button class returns the mock button instances in sequence
6060
MockCheckbox.side_effect = [mock_wait_ready_check_box]
61-
MockButton.side_effect = [mock_up_button, mock_down_button]
61+
MockButton.side_effect = [mock_apply_button, mock_down_button]
6262

6363
# Call the method under test
64-
cf_widgets.cluster_up_down_buttons(cluster)
64+
cf_widgets.cluster_apply_down_buttons(cluster)
6565

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

6969
# Simulate the button clicks by calling the mock on_click handlers
70-
mock_up_button.on_click.call_args[0][0](None) # Simulate clicking "Cluster Up"
70+
mock_apply_button.on_click.call_args[0][0](
71+
None
72+
) # Simulate clicking "Cluster Apply"
7173
mock_down_button.on_click.call_args[0][0](
7274
None
7375
) # Simulate clicking "Cluster Down"
7476

75-
# Check if the `up` and `down` methods were called
77+
# Check if the `apply` and `down` methods were called
7678
mock_wait_ready.assert_called_once()
77-
mock_up.assert_called_once()
79+
mock_apply.assert_called_once()
7880
mock_down.assert_called_once()
7981

8082

src/codeflare_sdk/common/widgets/widgets.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,19 +271,19 @@ def display_widgets(self):
271271
)
272272

273273

274-
def cluster_up_down_buttons(
274+
def cluster_apply_down_buttons(
275275
cluster: "codeflare_sdk.ray.cluster.cluster.Cluster",
276276
) -> widgets.Button:
277277
"""
278-
The cluster_up_down_buttons function returns two button widgets for a create and delete button.
278+
The cluster_apply_down_buttons function returns two button widgets for a create and delete button.
279279
The function uses the appwrapper bool to distinguish between resource type for the tool tip.
280280
"""
281281
resource = "Ray Cluster"
282282
if cluster.config.appwrapper:
283283
resource = "AppWrapper"
284284

285-
up_button = widgets.Button(
286-
description="Cluster Up",
285+
apply_button = widgets.Button(
286+
description="Cluster Apply",
287287
tooltip=f"Create the {resource}",
288288
icon="play",
289289
)
@@ -298,13 +298,13 @@ def cluster_up_down_buttons(
298298
output = widgets.Output()
299299

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

304-
def on_up_button_clicked(b): # Handle the up button click event
304+
def on_apply_button_clicked(b): # Handle the apply button click event
305305
with output:
306306
output.clear_output()
307-
cluster.up()
307+
cluster.apply()
308308

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

318-
up_button.on_click(on_up_button_clicked)
318+
apply_button.on_click(on_apply_button_clicked)
319319
delete_button.on_click(on_down_button_clicked)
320320

321321

src/codeflare_sdk/ray/cluster/cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
AppWrapperStatus,
4444
)
4545
from ...common.widgets.widgets import (
46-
cluster_up_down_buttons,
46+
cluster_apply_down_buttons,
4747
is_notebook,
4848
)
4949
from kubernetes import client
@@ -88,7 +88,7 @@ def __init__(self, config: ClusterConfiguration):
8888
self.resource_yaml = self.create_resource()
8989

9090
if is_notebook():
91-
cluster_up_down_buttons(self)
91+
cluster_apply_down_buttons(self)
9292

9393
def get_dynamic_client(self): # pragma: no cover
9494
return DynamicClient(get_api_client())

ui-tests/tests/widget_notebook_example.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,25 @@ test.describe("Visual Regression", () => {
6767

6868
// At this point, all cells have been ran, and their screenshots have been captured.
6969
// We now interact with the widgets in the notebook.
70-
const upDownWidgetCellIndex = 3; // 4 on OpenShift
70+
const applyDownWidgetCellIndex = 3; // 4 on OpenShift
7171

72-
await waitForWidget(page, upDownWidgetCellIndex, 'input[type="checkbox"]');
73-
await waitForWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Down")');
74-
await waitForWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Up")');
72+
await waitForWidget(page, applyDownWidgetCellIndex, 'input[type="checkbox"]');
73+
await waitForWidget(page, applyDownWidgetCellIndex, 'button:has-text("Cluster Down")');
74+
await waitForWidget(page, applyDownWidgetCellIndex, 'button:has-text("Cluster Apply")');
7575

76-
await interactWithWidget(page, upDownWidgetCellIndex, 'input[type="checkbox"]', async (checkbox) => {
76+
await interactWithWidget(page, applyDownWidgetCellIndex, 'input[type="checkbox"]', async (checkbox) => {
7777
await checkbox.click();
7878
const isChecked = await checkbox.isChecked();
7979
expect(isChecked).toBe(true);
8080
});
8181

82-
await interactWithWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Down")', async (button) => {
82+
await interactWithWidget(page, applyDownWidgetCellIndex, 'button:has-text("Cluster Down")', async (button) => {
8383
await button.click();
8484
const clusterDownMessage = await page.waitForSelector('text=The requested resource could not be located.', { timeout: 5000 });
8585
expect(await clusterDownMessage.innerText()).toContain('The requested resource could not be located.');
8686
});
8787

88-
await interactWithWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Up")', async (button) => {
88+
await interactWithWidget(page, applyDownWidgetCellIndex, 'button:has-text("Cluster Apply")', async (button) => {
8989
await button.click();
9090

9191
const successMessage = await page.waitForSelector('text=Ray Cluster: \'widgettest\' has successfully been created', { timeout: 10000 });
@@ -103,7 +103,7 @@ test.describe("Visual Regression", () => {
103103

104104
await runPreviousCell(page, cellCount, '(<CodeFlareClusterStatus.READY: 1>, True)');
105105

106-
await interactWithWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Down")', async (button) => {
106+
await interactWithWidget(page, applyDownWidgetCellIndex, 'button:has-text("Cluster Down")', async (button) => {
107107
await button.click();
108108
const clusterDownMessage = await page.waitForSelector('text=Ray Cluster: \'widgettest\' has successfully been deleted', { timeout: 5000 });
109109
expect(clusterDownMessage).not.toBeNull();
@@ -116,7 +116,7 @@ test.describe("Visual Regression", () => {
116116
await cell.fill('"widgettest-1"');
117117
await page.notebook.runCell(cellCount - 3, true); // Run ClusterConfiguration cell
118118

119-
await interactWithWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Up")', async (button) => {
119+
await interactWithWidget(page, applyDownWidgetCellIndex, 'button:has-text("Cluster Apply")', async (button) => {
120120
await button.click();
121121
const successMessage = await page.waitForSelector('text=Ray Cluster: \'widgettest-1\' has successfully been created', { timeout: 10000 });
122122
expect(successMessage).not.toBeNull();

0 commit comments

Comments
 (0)