Skip to content

Commit 849cfda

Browse files
committed
feat: add wait_ready checkbox for cluster up button
Signed-off-by: Bobbins228 <mcampbel@redhat.com>
1 parent 4542dd4 commit 849cfda

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/codeflare_sdk/cluster/cluster.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242
RayCluster,
4343
RayClusterStatus,
4444
)
45-
from .widgets import cluster_up_down_buttons, is_notebook
45+
from .widgets import (
46+
cluster_up_down_buttons,
47+
is_notebook,
48+
wait_ready_check_box,
49+
)
4650
from kubernetes import client, config
4751
from kubernetes.utils import parse_quantity
4852
import yaml
@@ -173,16 +177,23 @@ def up(self):
173177

174178
def _cluster_up_down_buttons(self):
175179
up_button, delete_button = cluster_up_down_buttons(self.config.appwrapper)
180+
wait_ready_check = wait_ready_check_box()
176181
output = widgets.Output()
177-
# Display the buttons in an HBox
178-
display(widgets.HBox([up_button, delete_button]), output)
179182

180-
def on_up_button_clicked(b):
183+
# Display the buttons in an HBox wrapped in a VBox which includes the wait_ready Checkbox
184+
button_display = widgets.HBox([up_button, delete_button])
185+
display(widgets.VBox([button_display, wait_ready_check]), output)
186+
187+
def on_up_button_clicked(b): # Handle the up button click event
181188
with output:
182189
output.clear_output()
183190
self.up()
184191

185-
def on_down_button_clicked(b):
192+
# If the wait_ready Checkbox is clicked(value == True) trigger the wait_ready function
193+
if wait_ready_check.value:
194+
self.wait_ready()
195+
196+
def on_down_button_clicked(b): # Handle the down button click event
186197
with output:
187198
output.clear_output()
188199
self.down()

src/codeflare_sdk/cluster/widgets.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ def cluster_up_down_buttons(appwrapper: bool) -> widgets.Button:
4343
return up_button, delete_button
4444

4545

46+
def wait_ready_check_box():
47+
"""
48+
The wait_ready_check_box function will return a checkbox widget used for waiting for the resource to be in the state READY.
49+
"""
50+
wait_ready_check_box = widgets.Checkbox(
51+
False,
52+
description="Wait for Cluster?",
53+
)
54+
return wait_ready_check_box
55+
56+
4657
def is_notebook() -> bool:
4758
"""
4859
The is_notebook function checks if Jupyter Notebook environment variables exist in the given environment and return True/False based on that.

0 commit comments

Comments
 (0)