-
Notifications
You must be signed in to change notification settings - Fork 2
chore: sync workflow templates #855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,8 @@ | |
|
|
||
| import logging | ||
| from collections.abc import Callable, Mapping | ||
| from contextlib import contextmanager | ||
| from html import escape | ||
| from typing import Any | ||
|
|
||
| logger = logging.getLogger("ds") | ||
|
|
@@ -88,9 +90,12 @@ def empty_state( | |
| clicked. NEVER pass an internal filename/path as `desc`.""" | ||
| import streamlit as st | ||
|
|
||
| safe_icon = escape(str(icon)) | ||
| safe_title = escape(str(title)) | ||
| safe_desc = escape(str(desc)) | ||
| st.markdown( | ||
| f"<div class='ds-empty'><div style='font-size:22px;opacity:.6'>{icon}</div>" | ||
| f"<div class='t'>{title}</div><div class='d'>{desc}</div></div>", | ||
| f"<div class='ds-empty'><div style='font-size:22px;opacity:.6'>{safe_icon}</div>" | ||
| f"<div class='t'>{safe_title}</div><div class='d'>{safe_desc}</div></div>", | ||
| unsafe_allow_html=True, | ||
| ) | ||
| if cta_label: | ||
|
|
@@ -107,12 +112,13 @@ def notice(kind: str, title: str = "", body: str = "", action: str | None = None | |
| import streamlit as st | ||
|
|
||
| color, bg, ic = _NOTICE_STYLE.get(kind, _NOTICE_STYLE["info"]) | ||
| head = f"<strong>{title}</strong><br>" if title else "" | ||
| act = f"<div style='margin-top:6px'>{action}</div>" if action else "" | ||
| head = f"<strong>{escape(str(title))}</strong><br>" if title else "" | ||
| act = f"<div style='margin-top:6px'>{escape(str(action))}</div>" if action else "" | ||
| safe_body = escape(str(body)) | ||
| st.markdown( | ||
| f"<div class='ds-notice' style='background:{bg};border-color:{color}33'>" | ||
| f"<span class='ic' style='color:{color}'>{ic}</span>" | ||
| f"<div>{head}{body}{act}</div></div>", | ||
| f"<div>{head}{safe_body}{act}</div></div>", | ||
| unsafe_allow_html=True, | ||
| ) | ||
|
|
||
|
|
@@ -128,18 +134,19 @@ def translate_error(exc: Exception) -> tuple[str, str | None]: | |
| Falls back to a generic message; the raw text is logged, not shown.""" | ||
| logger.warning("ds.translate_error: %s", exc, exc_info=True) | ||
| text = str(exc) | ||
| text_lower = text.lower() | ||
| # Known field-required cases (extend per app as needed). | ||
| if "financing_mode" in text: | ||
| if "financing_mode" in text_lower: | ||
| return ( | ||
| "Financing mode isn't set for this run.", | ||
| "Choose a financing mode (e.g. per-path) and run again.", | ||
| ) | ||
| if "exceeds total capital" in text or "capital buffer" in text: | ||
| if "exceeds total capital" in text_lower or "capital buffer" in text_lower: | ||
| return ( | ||
| "The capital allocation isn't feasible.", | ||
| "Reduce the internal allocation or volatility multiple to leave margin headroom.", | ||
| ) | ||
| if "No investable funds" in text or "NO_FUNDS" in text: | ||
| if "no investable funds" in text_lower or "no_funds" in text_lower: | ||
| return ( | ||
| "No funds matched the selection filters.", | ||
| "Try another preset or relax the selection settings.", | ||
|
|
@@ -155,16 +162,25 @@ def dev_note(msg: str) -> None: | |
| logger.info("ds.dev_note: %s", msg) | ||
|
|
||
|
|
||
| @contextmanager | ||
| def diagnostics_expander(label: str = "Diagnostics", *, expanded: bool = False): | ||
| """P4 — explicit opt-in container for diagnostics that must be visible.""" | ||
| import streamlit as st | ||
|
|
||
| with st.expander(label, expanded=expanded): | ||
| yield | ||
|
|
||
|
|
||
| def availability_badge(label: str) -> str: | ||
| """P5 — markup for a small availability marker (use in a tab title/caption), | ||
| """P5 — plain Streamlit-safe availability marker for tab titles/captions, | ||
| e.g. tab label f"Export {availability_badge('multi-period only')}".""" | ||
| return f"<span class='ds-badge'>{label}</span>" | ||
| return f" · {str(label).strip()}" | ||
|
|
||
|
|
||
| def humanize_id(raw: str, mapping: Mapping[str, str] | None = None) -> str: | ||
| """P6 — decode an internal id to a human label; never show raw keys.""" | ||
| if mapping and raw in mapping: | ||
| return mapping[raw] | ||
| # Best-effort: take a trailing human-ish segment, strip hashes. | ||
| tail = str(raw).replace("_", " ").split(":")[0].strip() | ||
| tail = str(raw).replace("_", " ").split(":")[-1].strip() | ||
|
Comment on lines
174
to
+185
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Preserve backward compatibility for exported helper behavior.
Proposed compatibility-oriented patch def availability_badge(label: str) -> str:
- """P5 — plain Streamlit-safe availability marker for tab titles/captions,
- e.g. tab label f"Export {availability_badge('multi-period only')}"."""
- return f" · {str(label).strip()}"
+ """P5 — availability marker.
+ Backward-compatible default returns styled HTML; plain text is opt-in."""
+ normalized = str(label).strip()
+ return f"<span class='ds-badge'>{escape(normalized)}</span>"
-def humanize_id(raw: str, mapping: Mapping[str, str] | None = None) -> str:
+def humanize_id(
+ raw: str,
+ mapping: Mapping[str, str] | None = None,
+ *,
+ use_trailing_segment: bool = False,
+) -> str:
"""P6 — decode an internal id to a human label; never show raw keys."""
if mapping and raw in mapping:
return mapping[raw]
- # Best-effort: take a trailing human-ish segment, strip hashes.
- tail = str(raw).replace("_", " ").split(":")[-1].strip()
+ # Backward-compatible default keeps first segment unless explicitly overridden.
+ parts = str(raw).replace("_", " ").split(":")
+ tail = (parts[-1] if use_trailing_segment else parts[0]).strip()
return tail or "item"🤖 Prompt for AI AgentsSource: Linked repositories |
||
| return tail or "item" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Update both fallback action pins to the synced SHA.
Both fallback steps still reference
44965d8d784573c119fb63828c05c89256c5f3e1, but this sync is expected to usedfe0854ae9b1ba1c616e4b57fb498f283ea3216f. As written, the workflow does not apply the intended action bump in either event path.Suggested patch
Also applies to: 183-183
🤖 Prompt for AI Agents
Source: Linked repositories