refactor: restructure repo into core/app modules with per-study folders
Reorganize Palladium codebase into a modular architecture with `core/` shared logic and `app/` Streamlit UI, separating per-study assets into `studies/YYYYMM_<Vendor>/` folders containing notebooks, seed data, and configuration. Update README to reflect new structure, add `.gitignore` entries for `.env` and study exports, and refresh component documentation.
This commit is contained in:
28
app/pages/_helpers.py
Normal file
28
app/pages/_helpers.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""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
|
||||
Reference in New Issue
Block a user