Files
palladium/app/views/_helpers.py
Robert Helewka 253ff38118 refactor: rename pages directory to views
Renames the `app/pages` module to `app/views` to better reflect the
purpose of the directory, aligning with conventional MVC naming
conventions where view-related logic is housed under `views`.
2026-06-10 09:29:02 -04:00

29 lines
803 B
Python

"""Common helpers shared by the page modules."""
from __future__ import annotations
import streamlit as st
from core.tei_client import AthenaAPIError, TEIClient
def report_meta(client: TEIClient, tool: dict) -> dict:
"""Fetch the linked report (handles both nested-object and id-only forms)."""
report_obj = tool.get("report")
if isinstance(report_obj, dict):
return report_obj
if isinstance(report_obj, str):
try:
return client.get_report(report_obj)
except AthenaAPIError as e:
st.error(f"Failed to load report template: {e}")
return {}
def safe(fn, *args, **kwargs):
try:
return fn(*args, **kwargs)
except AthenaAPIError as e:
st.error(f"Athena API error {e.status_code}: {e.detail}")
return None