Skip to content

Commit

Permalink
adding health icons to data sources and feature sets
Browse files Browse the repository at this point in the history
  • Loading branch information
brifordwylie committed Dec 9, 2024
1 parent c9902e7 commit bfffe4b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/sageworks/core/cloud_platform/aws/aws_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import awswrangler as wr
from collections import defaultdict


# SageWorks Imports
from sageworks.core.cloud_platform.aws.aws_account_clamp import AWSAccountClamp
from sageworks.utils.config_manager import ConfigManager
Expand Down Expand Up @@ -127,7 +126,15 @@ def data_sources(self) -> pd.DataFrame:
Returns:
pd.DataFrame: A summary of the Data Sources deployed in the AWS Platform
"""
return self._list_catalog_tables("sageworks")
data_sources_df = self._list_catalog_tables("sageworks")
data_sources_df["Health"] = ""

# Make the Health column the second column
cols = data_sources_df.columns.tolist()
cols.remove("Health")
cols.insert(1, "Health")
data_sources_df = data_sources_df[cols]
return data_sources_df

def views(self, database: str = "sageworks") -> pd.DataFrame:
"""Get a summary of the all the Views, for the given database, in AWS
Expand Down Expand Up @@ -169,6 +176,7 @@ def feature_sets(self, details: bool = False) -> pd.DataFrame:
aws_tags = self.get_aws_tags(fg["FeatureGroupArn"])
summary = {
"Feature Group": name,
"Health": "",
"Owner": aws_tags.get("sageworks_owner", "-"),
"Created": datetime_string(feature_set_details.get("CreationTime")),
"Num Columns": len(feature_set_details.get("FeatureDefinitions", [])),
Expand Down
22 changes: 22 additions & 0 deletions src/sageworks/utils/theme_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ def colorscale(cls, scale_type: str = "sequential") -> list[list[float | str]]:
cls._log.error(f"No color scales found for template '{cls._current_theme_name}'.")
return []

@staticmethod
def adjust_colorscale_alpha(colorscale, alpha=0.5):
"""
Adjust the alpha value of the first color in the colorscale.
Args:
colorscale (list): The colorscale list with format [[value, color], ...].
alpha (float): The new alpha value for the first color (0 to 1).
Returns:
list: The updated colorscale.
"""
updated_colorscale = colorscale.copy()

if updated_colorscale and "rgba" in updated_colorscale[0][1]:
# Parse the existing RGBA value and modify alpha
rgba_values = updated_colorscale[0][1].strip("rgba()").split(",")
rgba_values[-1] = str(alpha) # Update the alpha channel
updated_colorscale[0][1] = f"rgba({','.join(rgba_values)})"

return updated_colorscale

@classmethod
def css_files(cls) -> list[str]:
"""Get the list of CSS files for the current theme."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ def update_properties(self, model: CachedModel, **kwargs) -> list:
y_labels = [f"{c}:{i}" for i, c in enumerate(df.index)]

# Create the heatmap figure
colorscale = self.theme_manager.colorscale()
colorscale = self.theme_manager.adjust_colorscale_alpha(colorscale, alpha=0.25)
fig = go.Figure(
data=go.Heatmap(
z=df,
x=x_labels,
y=y_labels,
xgap=3, # Add space between cells
ygap=3,
colorscale=self.theme_manager.colorscale(), # Use the current theme's colorscale
colorscale=colorscale, # Use the current theme's colorscale
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sageworks.web_interface.page_views.page_view import PageView
from sageworks.cached.cached_meta import CachedMeta
from sageworks.cached.cached_data_source import CachedDataSource
from sageworks.utils.symbols import tag_symbols


class DataSourcesPageView(PageView):
Expand All @@ -26,6 +27,10 @@ def refresh(self):
self.log.important("Calling refresh()..")
self.data_sources_df = self.meta.data_sources()

# Add Health Symbols to the Model Group Name
if "Health" in self.data_sources_df.columns:
self.data_sources_df["Health"] = self.data_sources_df["Health"].map(lambda x: tag_symbols(x))

def data_sources(self) -> pd.DataFrame:
"""Get a list of all the DataSources
Expand Down

0 comments on commit bfffe4b

Please sign in to comment.