Add SLA visibility toggle control with profile persistence and cache invalidation for drill-down plots with checkbox widget, config serialization, and parameter watching
Browse files
panel_app/kpi_health_check_panel.py
CHANGED
|
@@ -201,6 +201,7 @@ def _drilldown_cache_key(site_code: int, rat: str, kpi: str) -> tuple:
|
|
| 201 |
str(granularity_select.value or "Daily"),
|
| 202 |
compare_kpis_key,
|
| 203 |
norm_key,
|
|
|
|
| 204 |
ar_key,
|
| 205 |
int(_coerce_int(baseline_days.value) or 0),
|
| 206 |
int(_coerce_int(recent_days.value) or 0),
|
|
@@ -555,6 +556,7 @@ kpi_compare_select = pn.widgets.MultiChoice(name="Compare KPIs", options=[], val
|
|
| 555 |
kpi_compare_norm = pn.widgets.Select(
|
| 556 |
name="Normalization", options=["None", "Min-Max", "Z-score"], value="None"
|
| 557 |
)
|
|
|
|
| 558 |
|
| 559 |
corr_window_select = pn.widgets.Select(
|
| 560 |
name="Correlation window",
|
|
@@ -1844,7 +1846,7 @@ def _update_site_view(event=None) -> None:
|
|
| 1844 |
kpis=kpis_to_plot,
|
| 1845 |
rules_df=relevant_rules,
|
| 1846 |
highlight_bad_days=True,
|
| 1847 |
-
show_sla=
|
| 1848 |
site_code=code_int,
|
| 1849 |
rat=rat,
|
| 1850 |
main_kpi=str(kpi),
|
|
@@ -2745,6 +2747,7 @@ def _current_profile_config() -> dict:
|
|
| 2745 |
list(kpi_compare_select.value) if kpi_compare_select.value else []
|
| 2746 |
),
|
| 2747 |
"compare_norm": str(kpi_compare_norm.value or "None"),
|
|
|
|
| 2748 |
}
|
| 2749 |
return cfg
|
| 2750 |
|
|
@@ -2862,6 +2865,11 @@ def _apply_profile_config(cfg: dict) -> None:
|
|
| 2862 |
kpi_compare_norm.value = norm
|
| 2863 |
except Exception: # noqa: BLE001
|
| 2864 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2865 |
try:
|
| 2866 |
ck = drill.get("compare_kpis", [])
|
| 2867 |
if isinstance(ck, list):
|
|
@@ -3639,6 +3647,7 @@ site_select.param.watch(_on_drilldown_change, "value")
|
|
| 3639 |
kpi_select.param.watch(_on_drilldown_change, "value")
|
| 3640 |
kpi_compare_select.param.watch(_on_drilldown_change, "value")
|
| 3641 |
kpi_compare_norm.param.watch(_on_drilldown_change, "value")
|
|
|
|
| 3642 |
corr_window_select.param.watch(_on_drilldown_change, "value")
|
| 3643 |
|
| 3644 |
map_show_site_codes.param.watch(lambda e: _refresh_map_view(), "value")
|
|
@@ -4029,7 +4038,13 @@ _tab_drilldown = pn.Column(
|
|
| 4029 |
pn.pane.Markdown("## Drill-down"),
|
| 4030 |
pn.Row(site_select, rat_select),
|
| 4031 |
pn.Row(kpi_group_select, kpi_group_mode),
|
| 4032 |
-
pn.Row(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4033 |
pn.Column(trend_plot_pane, sizing_mode="stretch_both", min_height=500),
|
| 4034 |
pn.Column(site_kpi_table, sizing_mode="stretch_width"),
|
| 4035 |
pn.Column(heatmap_plot_pane, sizing_mode="stretch_both", min_height=400),
|
|
|
|
| 201 |
str(granularity_select.value or "Daily"),
|
| 202 |
compare_kpis_key,
|
| 203 |
norm_key,
|
| 204 |
+
bool(show_sla_toggle.value),
|
| 205 |
ar_key,
|
| 206 |
int(_coerce_int(baseline_days.value) or 0),
|
| 207 |
int(_coerce_int(recent_days.value) or 0),
|
|
|
|
| 556 |
kpi_compare_norm = pn.widgets.Select(
|
| 557 |
name="Normalization", options=["None", "Min-Max", "Z-score"], value="None"
|
| 558 |
)
|
| 559 |
+
show_sla_toggle = pn.widgets.Checkbox(name="Show SLA", value=True)
|
| 560 |
|
| 561 |
corr_window_select = pn.widgets.Select(
|
| 562 |
name="Correlation window",
|
|
|
|
| 1846 |
kpis=kpis_to_plot,
|
| 1847 |
rules_df=relevant_rules,
|
| 1848 |
highlight_bad_days=True,
|
| 1849 |
+
show_sla=bool(show_sla_toggle.value),
|
| 1850 |
site_code=code_int,
|
| 1851 |
rat=rat,
|
| 1852 |
main_kpi=str(kpi),
|
|
|
|
| 2747 |
list(kpi_compare_select.value) if kpi_compare_select.value else []
|
| 2748 |
),
|
| 2749 |
"compare_norm": str(kpi_compare_norm.value or "None"),
|
| 2750 |
+
"show_sla": bool(show_sla_toggle.value),
|
| 2751 |
}
|
| 2752 |
return cfg
|
| 2753 |
|
|
|
|
| 2865 |
kpi_compare_norm.value = norm
|
| 2866 |
except Exception: # noqa: BLE001
|
| 2867 |
pass
|
| 2868 |
+
try:
|
| 2869 |
+
if "show_sla" in drill and drill["show_sla"] is not None:
|
| 2870 |
+
show_sla_toggle.value = bool(drill["show_sla"])
|
| 2871 |
+
except Exception: # noqa: BLE001
|
| 2872 |
+
pass
|
| 2873 |
try:
|
| 2874 |
ck = drill.get("compare_kpis", [])
|
| 2875 |
if isinstance(ck, list):
|
|
|
|
| 3647 |
kpi_select.param.watch(_on_drilldown_change, "value")
|
| 3648 |
kpi_compare_select.param.watch(_on_drilldown_change, "value")
|
| 3649 |
kpi_compare_norm.param.watch(_on_drilldown_change, "value")
|
| 3650 |
+
show_sla_toggle.param.watch(_on_drilldown_change, "value")
|
| 3651 |
corr_window_select.param.watch(_on_drilldown_change, "value")
|
| 3652 |
|
| 3653 |
map_show_site_codes.param.watch(lambda e: _refresh_map_view(), "value")
|
|
|
|
| 4038 |
pn.pane.Markdown("## Drill-down"),
|
| 4039 |
pn.Row(site_select, rat_select),
|
| 4040 |
pn.Row(kpi_group_select, kpi_group_mode),
|
| 4041 |
+
pn.Row(
|
| 4042 |
+
kpi_select,
|
| 4043 |
+
kpi_compare_select,
|
| 4044 |
+
kpi_compare_norm,
|
| 4045 |
+
show_sla_toggle,
|
| 4046 |
+
drilldown_export_button,
|
| 4047 |
+
),
|
| 4048 |
pn.Column(trend_plot_pane, sizing_mode="stretch_both", min_height=500),
|
| 4049 |
pn.Column(site_kpi_table, sizing_mode="stretch_width"),
|
| 4050 |
pn.Column(heatmap_plot_pane, sizing_mode="stretch_both", min_height=400),
|
process_kpi/kpi_health_check/normalization.py
CHANGED
|
@@ -242,7 +242,7 @@ def build_period_kpi(
|
|
| 242 |
|
| 243 |
g = str(granularity or "Daily").strip().lower()
|
| 244 |
if g.startswith("hour") or g.startswith("h"):
|
| 245 |
-
df["period_start"] = df["date"].dt.floor("
|
| 246 |
else:
|
| 247 |
df["period_start"] = df["date"].dt.floor("D")
|
| 248 |
|
|
|
|
| 242 |
|
| 243 |
g = str(granularity or "Daily").strip().lower()
|
| 244 |
if g.startswith("hour") or g.startswith("h"):
|
| 245 |
+
df["period_start"] = df["date"].dt.floor("h")
|
| 246 |
else:
|
| 247 |
df["period_start"] = df["date"].dt.floor("D")
|
| 248 |
|