Skip to content

Commit

Permalink
Add comments to widgets class and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianZaccaria authored and openshift-merge-bot[bot] committed Oct 4, 2024
1 parent 693a019 commit 455bea2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/codeflare_sdk/common/widgets/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@


class RayClusterManagerWidgets:
"""
The RayClusterManagerWidgets class is responsible for initialising the ToggleButtons, Button, and Output widgets.
It also handles the user interactions and displays the cluster details.
Used when calling the view_clusters function.
"""

def __init__(self, ray_clusters_df: pd.DataFrame, namespace: str = None):
from ...ray.cluster.cluster import get_current_namespace

Expand Down Expand Up @@ -74,6 +80,10 @@ def __init__(self, ray_clusters_df: pd.DataFrame, namespace: str = None):
self._trigger_initial_display()

def _initialize_callbacks(self):
"""
Called upon RayClusterManagerWidgets initialisation.
Sets up event handlers and callbacks for UI interactions.
"""
# Observe cluster selection
self.classification_widget.observe(
lambda selection_change: self._on_cluster_click(selection_change),
Expand All @@ -87,6 +97,10 @@ def _initialize_callbacks(self):
)

def _trigger_initial_display(self):
"""
Called upon RayClusterManagerWidgets initialisation.
Triggers an initial display update with the current cluster value.
"""
# Trigger display with initial cluster value
initial_value = self.classification_widget.value
self._on_cluster_click({"new": initial_value})
Expand Down

0 comments on commit 455bea2

Please sign in to comment.