Skip to content

Commit

Permalink
adding in a call to parameter store
Browse files Browse the repository at this point in the history
  • Loading branch information
brifordwylie committed Dec 12, 2024
1 parent d762b20 commit 60e241f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion applications/aws_dashboard/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Set up the Theme Manager
tm = ThemeManager()
tm.set_theme("dark")
tm.set_theme("auto")
css_files = tm.css_files()
print(css_files)

Expand Down
23 changes: 14 additions & 9 deletions src/sageworks/utils/theme_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

# SageWorks Imports
from sageworks.utils.config_manager import ConfigManager
from sageworks.api import ParameterStore


class ThemeManager:
Expand All @@ -20,7 +21,6 @@ class ThemeManager:
_available_themes = {}
_current_theme_name = None
_current_template = None
_theme_set = False
_default_theme = "dark"

def __new__(cls):
Expand All @@ -46,8 +46,12 @@ def _initialize(cls):
if not cls._theme_path.exists():
cls._log.error(f"The themes path '{cls._theme_path}' does not exist.")

# Our parameter store
cls._ps = ParameterStore()

# Load the available themes and set the automatic theme
cls._load_themes()
cls.set_theme("default") # Default theme
cls.set_theme("auto")

@classmethod
def list_themes(cls) -> list[str]:
Expand All @@ -58,16 +62,17 @@ def list_themes(cls) -> list[str]:
def set_theme(cls, theme_name: str):
"""Set the current theme."""

# Use "default" theme
if theme_name == "default":
theme_name = cls._default_theme
else:
cls._theme_set = True
# For 'auto', we try to grab a theme from the Parameter Store
# if we can't find one, we'll set the theme to the default
if theme_name == "auto":
theme_name = cls._ps.get("/sageworks/dashboard/theme", warn=False) or cls._default_theme

# Check if the theme is in our available themes
if theme_name not in cls._available_themes:
cls._log.error(f"Theme '{theme_name}' is not available.")
return
cls._log.error(f"Theme '{theme_name}' is not available, using default theme.")
theme_name = cls._default_theme

# Grab the theme from the available themes
theme = cls._available_themes[theme_name]

# Update Plotly template
Expand Down

0 comments on commit 60e241f

Please sign in to comment.