TrialPath / streamlit_app.py
yakilee's picture
fix(logging): configure stdlib logging and structlog integration
9edb6c6
"""TrialPath — AI-powered clinical trial matching for NSCLC patients.
Entrypoint: multipage Streamlit app with st.navigation.
"""
import logging # noqa: E402
import sys # noqa: E402
from dotenv import load_dotenv
load_dotenv()
# Configure stdlib logging FIRST so all loggers (pipeline, services) are captured
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
stream=sys.stderr,
force=True,
)
import structlog # noqa: E402
structlog.configure(
processors=[
structlog.stdlib.add_log_level,
structlog.stdlib.add_logger_name,
structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.StackInfoRenderer(),
structlog.processors.format_exc_info,
structlog.processors.JSONRenderer(),
],
wrapper_class=structlog.stdlib.BoundLogger,
context_class=dict,
logger_factory=structlog.stdlib.LoggerFactory(),
cache_logger_on_first_use=True,
)
import streamlit as st # noqa: E402
from app.components.disclaimer_banner import DISCLAIMER_TEXT # noqa: E402
from app.components.progress_tracker import render_progress_tracker # noqa: E402
from app.services.state_manager import get_current_journey_state, init_session_state # noqa: E402
st.set_page_config(
page_title="TrialPath",
page_icon=":material/medical_services:",
layout="wide",
)
init_session_state()
pages = {
"Patient Journey": [
st.Page("app/pages/1_upload.py", title="Upload Documents", icon=":material/upload_file:"),
st.Page("app/pages/2_profile_review.py", title="Review Profile", icon=":material/person:"),
st.Page("app/pages/3_trial_matching.py", title="Trial Matching", icon=":material/search:"),
st.Page("app/pages/4_gap_analysis.py", title="Gap Analysis", icon=":material/analytics:"),
st.Page("app/pages/5_summary.py", title="Summary & Export", icon=":material/summarize:"),
]
}
nav = st.navigation(pages)
# Shared sidebar
with st.sidebar:
st.info(DISCLAIMER_TEXT)
st.markdown("### Journey Progress")
state = get_current_journey_state()
tracker = render_progress_tracker(state)
for step in tracker["steps"]:
if step["status"] == "completed":
st.markdown(f"~~{step['label']}~~")
elif step["status"] == "current":
st.markdown(f"**> {step['label']}**")
else:
st.markdown(f" {step['label']}")
nav.run()