From 455bea294b1835d17b2c0470a897ed2577c94389 Mon Sep 17 00:00:00 2001 From: ChristianZaccaria Date: Fri, 4 Oct 2024 12:43:09 +0100 Subject: [PATCH] Add comments to widgets class and functions --- src/codeflare_sdk/common/widgets/widgets.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/codeflare_sdk/common/widgets/widgets.py b/src/codeflare_sdk/common/widgets/widgets.py index cf7bccf9f..8a13a4d4d 100644 --- a/src/codeflare_sdk/common/widgets/widgets.py +++ b/src/codeflare_sdk/common/widgets/widgets.py @@ -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 @@ -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), @@ -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})