File size: 4,314 Bytes
6252f54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
"""Strategic Roadmap tab — Plotly Gantt chart + AI Prioritisation trace + AMD metrics."""

import streamlit as st
import plotly.express as px
import plotly.graph_objects as go
import pandas as pd

from frontend.utils.terminology import label, domain_label, subdomain_label


PHASE_COLORS = {1: "#00C5E3", 2: "#FF5733", 3: "#27AE60"}


def render_amd_metrics(metrics: dict) -> None:
    st.markdown("#### AMD MI300X Performance")
    col1, col2, col3, col4 = st.columns(4)
    with col1:
        st.metric(label("gpu_device"), metrics.get("gpu_device") or "CPU")
    with col2:
        rocm = metrics.get("rocm_version") or "N/A"
        st.metric(label("rocm_version"), rocm)
    with col3:
        st.metric(label("processing_time"), f"{metrics.get('processing_time_seconds', 0):.1f}s")
    with col4:
        st.metric(label("capabilities_retrieved"), metrics.get("capabilities_retrieved", 0))


def render_drl_trace(drl_trace: dict) -> None:
    if not drl_trace:
        return
    with st.expander(label("drl_trace"), expanded=False):
        drl_used = drl_trace.get("drl_used", False)
        mode_label = label("drl_used_true") if drl_used else label("drl_used_false")
        st.caption(f"Mode: {mode_label}")
        cap_scores = drl_trace.get("capability_scores") or []
        if cap_scores:
            df = pd.DataFrame(
                [{"Strategic Capability": c["capability_name"], "Priority Score": round(c["score"], 3)}
                 for c in cap_scores[:10]]
            )
            fig = px.bar(
                df,
                x="Priority Score",
                y="Strategic Capability",
                orientation="h",
                color="Priority Score",
                color_continuous_scale="blues",
                title="AI Capability Prioritisation Scores",
            )
            fig.update_layout(height=350, showlegend=False, coloraxis_showscale=False)
            st.plotly_chart(fig, width='stretch')


def render_gantt(phases: list[dict]) -> None:
    if not phases:
        st.info("No phases to display.")
        return

    rows: list[dict] = []
    start_month = 0
    for phase in phases:
        phase_num = phase.get("phase_number", 1)
        duration = phase.get("duration_months", 3)
        for epic in (phase.get("epics") or [])[:6]:
            rows.append({
                "Phase": f"Phase {phase_num}: {phase.get('phase_name', '')}",
                "Initiative": subdomain_label(epic.get("title") or "")[:45],
                "Start": start_month,
                "End": start_month + (epic.get("estimated_sprints", 4) * 2),
                "Capability Area": domain_label(epic.get("subdomain_group") or ""),
            })
        start_month += duration

    if not rows:
        return

    df = pd.DataFrame(rows)
    df["Start_Date"] = pd.to_datetime("2025-06-01") + pd.to_timedelta(df["Start"] * 30, unit="D")
    df["End_Date"] = pd.to_datetime("2025-06-01") + pd.to_timedelta(df["End"] * 30, unit="D")

    fig = px.timeline(
        df,
        x_start="Start_Date",
        x_end="End_Date",
        y="Initiative",
        color="Phase",
        hover_data=["Capability Area"],
        title="Strategic Roadmap Timeline",
    )
    fig.update_layout(height=max(400, len(rows) * 25), showlegend=True)
    fig.update_yaxes(autorange="reversed")
    st.plotly_chart(fig, width='stretch')


def render_roadmap_tab(result: dict) -> None:
    metrics = result.get("amd_metrics") or {}
    render_amd_metrics(metrics)

    st.divider()
    phases = result.get("phases") or []
    total_initiatives = sum(len(p.get("epics", [])) for p in phases)
    st.markdown(
        f"### Strategic Roadmap — {len(phases)} Phases · "
        f"{total_initiatives} {label('epics')}"
    )

    render_gantt(phases)

    compliance = result.get("compliance_summary") or {}
    if compliance:
        score = compliance.get("score", 0)
        color = "green" if score >= 70 else "orange" if score >= 50 else "red"
        st.markdown(f"**{label('compliance_score')}:** :{color}[{score} / 100]")
        if compliance.get("standards_covered"):
            st.caption(
                f"{label('standards_covered')}: "
                + ", ".join(compliance["standards_covered"][:5])
            )

    render_drl_trace(result.get("drl_trace") or {})