From 5046cf2777be46c571f1a38c948bae64b9eb7b95 Mon Sep 17 00:00:00 2001 From: t-kramer Date: Thu, 24 Sep 2026 14:11:33 -0700 Subject: [PATCH 1/2] fix: remove survey alert --- pages/lib/global_element_ids.py | 2 -- pages/lib/layout.py | 40 --------------------------------- 2 files changed, 42 deletions(-) diff --git a/pages/lib/global_element_ids.py b/pages/lib/global_element_ids.py index c7969b4..e9d4f39 100644 --- a/pages/lib/global_element_ids.py +++ b/pages/lib/global_element_ids.py @@ -162,8 +162,6 @@ class ElementIds(str, Enum): WIND_PROFILE_GRAPH = "wind-profile-graph" TDB_PROFILE_GRAPH = "tdb-profile-graph" RH_PROFILE_GRAPH = "rh-profile-graph" - ID_LAYOUT_ALERT_AUTO = "alert-auto" - ID_LAYOUT_INTERVAL_COMPONENT = "interval-component" FOOTER_CONTAINER = "footer-container" STORE = "store" BURGER_BUTTON = "burger-button" diff --git a/pages/lib/layout.py b/pages/lib/layout.py index d42801f..c9ad4bc 100644 --- a/pages/lib/layout.py +++ b/pages/lib/layout.py @@ -296,32 +296,6 @@ def create_header(): ), ], ), - dmc.Alert( - [ - "If you have a moment, help us improve Clima and take a ", - dmc.Anchor( - "quick user survey", - href="https://forms.gle/k289zP3R92jdu14M7", - target="_blank", - c="white", - underline="always", - ), - "! ☀️", - ], - id=ElementIds.ID_LAYOUT_ALERT_AUTO, - title="CBE Clima User Survey", - icon=dmc.ThemeIcon( - DashIconify(icon="tabler:info-circle", color="white"), - ), - color="blue", - variant="filled", - withCloseButton=True, - w=400, - pos="fixed", - top="1em", - right="1em", - style={"zIndex": 1002, "display": "none"}, - ), ], ) @@ -422,11 +396,6 @@ def create_stores(): data=get_default_global_filter_store_data(), storage_type="session", ), - dcc.Interval( - id=ElementIds.ID_LAYOUT_INTERVAL_COMPONENT, - interval=12 * 1000, - n_intervals=0, - ), ], ) @@ -522,15 +491,6 @@ def update_nav_active_state(pathname): ] -@callback( - Output(ElementIds.ID_LAYOUT_ALERT_AUTO, "style"), - Input(ElementIds.ID_LAYOUT_INTERVAL_COMPONENT, "n_intervals"), - prevent_initial_call=True, -) -def show_alert_after_delay(n_intervals): - return {"display": "block" if n_intervals == 1 else "none"} - - @callback( Output(ElementIds.TOOLS_GLOBAL_FILTER_STORE, "data"), [ From 6675d9100f69ea5a267b73a5d92c282b02cd07a1 Mon Sep 17 00:00:00 2001 From: t-kramer Date: Mon, 28 Sep 2026 18:55:34 -0700 Subject: [PATCH 2/2] fix: add Carto API key --- cloudbuild.yaml | 3 ++- config.py | 2 ++ pages/lib/charts_summary.py | 3 ++- pages/lib/utils.py | 20 +++++++++++++++++++- pages/select.py | 8 ++++++-- 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 8eb6ac4..848acac 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -12,4 +12,5 @@ steps: '--image', '$_GCR/$_PROJ_NAME/$_REPO_NAME/$_IMG_NAME', '--region', '$_REGION', '--memory', '$_MEMORY', - '--cpu', '$_CPU'] \ No newline at end of file + '--cpu', '$_CPU', + '--set-secrets', 'CARTO_API_KEY=carto-api-key:latest'] \ No newline at end of file diff --git a/config.py b/config.py index b53ce10..37be979 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,5 @@ from enum import Enum +import os import platform @@ -11,6 +12,7 @@ class AppConfig: PORT = 8080 PROCESSES = 1 THREADED = True + CARTO_API_KEY = os.environ.get("CARTO_API_KEY", "") class UnitSystem(str, Enum): diff --git a/pages/lib/charts_summary.py b/pages/lib/charts_summary.py index be3eb9b..8110013 100644 --- a/pages/lib/charts_summary.py +++ b/pages/lib/charts_summary.py @@ -1,6 +1,7 @@ import pandas as pd import plotly.express as px from pages.lib.global_variables import Variables +from pages.lib.utils import apply_carto_basemap def world_map(meta): @@ -32,6 +33,6 @@ def world_map(meta): height=300, size="Size", ) - fig.update_layout(mapbox_style="carto-positron") + apply_carto_basemap(fig) fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0}) return fig diff --git a/pages/lib/utils.py b/pages/lib/utils.py index 2fe512a..2140fc6 100644 --- a/pages/lib/utils.py +++ b/pages/lib/utils.py @@ -8,11 +8,29 @@ from dash import html, dcc import dash_mantine_components as dmc -from config import UnitSystem +from config import AppConfig, UnitSystem from pages.lib.global_scheme import fig_config, month_lst from pages.lib.global_variables import Variables, VariableInfo +def apply_carto_basemap(fig): + """Apply the Carto Positron basemap, authenticated with our API key.""" + fig.update_layout( + mapbox_style="white-bg", + mapbox_layers=[ + { + "below": "traces", + "sourcetype": "raster", + "sourceattribution": "© CARTO", + "source": [ + f"https://basemaps.cartocdn.com/rastertiles/light_all/{{z}}/{{x}}/{{y}}.png?key={AppConfig.CARTO_API_KEY}" + ], + } + ], + ) + return fig + + def code_timer(func): """Print the runtime of the decorated function""" diff --git a/pages/select.py b/pages/select.py index 71ab90b..baf198d 100644 --- a/pages/select.py +++ b/pages/select.py @@ -16,7 +16,11 @@ from pages.lib.global_element_ids import ElementIds from pages.lib.global_tab_names import TabNames from config import PageUrls, PageInfo -from pages.lib.utils import generate_chart_name, get_default_global_filter_store_data +from pages.lib.utils import ( + apply_carto_basemap, + generate_chart_name, + get_default_global_filter_store_data, +) dash.register_page( __name__, @@ -367,7 +371,7 @@ def plot_location_epw_files(pathname): height=500, ) fig.add_trace(fig2.data[0]) - fig.update_layout(mapbox_style="carto-positron") + apply_carto_basemap(fig) fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0}) return dcc.Graph(