File size: 2,881 Bytes
98792d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""UI components for the Safe Scan competition dashboard."""
import streamlit as st
import pandas as pd
from typing import Dict, Any

def render_competition_header():
    """Render the main header of the competition dashboard."""
    st.markdown("<h2 style='text-align: center; font-size: 28px;'>Competitions</h2>", unsafe_allow_html=True)

def render_competition_list(competitions: list, leader_info: Dict[str, Any]):
    """Render the list of competitions with their details.
    
    Args:
        competitions: List of competition names
        leader_info: Dictionary containing leader information for each competition
    """
    cols = st.columns([1, 3, 2, 2, 3])
    headers = ["Index", "Competition Name", "Date", "Winning hotkey"]
    for col, header in zip(cols, headers):
        col.write(header)
    
    for index, competition in enumerate(competitions, start=1):
        leader_info_comp = leader_info.get(competition, {})
        cols = st.columns([1, 3, 2, 2, 3])
        cols[0].write(index)
        if cols[1].button(competition):
            st.session_state.selected_competition = competition
        cols[2].write(leader_info_comp.get("Date", "N/A"))
        cols[3].write(leader_info_comp.get("Miner hotkey", "N/A"))

def render_competition_details(
    competition_name: str,
    competition_summary_df: pd.DataFrame,
    models_evaluation_df: pd.DataFrame,
    highlight_score_column
):
    """Render detailed view for a selected competition.
    
    Args:
        competition_name: Name of the selected competition
        competition_summary_df: DataFrame containing competition summary
        models_evaluation_df: DataFrame containing model evaluations
        highlight_score_column: Function to highlight score column
    """
    st.subheader(f"Competition: {competition_name}")
    miner_hotkey_search = st.text_input("Search for Miner Hotkey", "")

    st.subheader("Competition Summary")
    if not competition_summary_df.empty:
        filtered_summary = competition_summary_df
        if miner_hotkey_search:
            filtered_summary = competition_summary_df[
                competition_summary_df["Winning Hotkey"].str.contains(miner_hotkey_search, na=False, case=False)
            ]
        st.dataframe(filtered_summary, height=500, hide_index=True)
    else:
        st.warning("No competition summary data available.")

    st.subheader("Models Evaluation")
    if not models_evaluation_df.empty:
        filtered_models = models_evaluation_df
        if miner_hotkey_search:
            filtered_models = models_evaluation_df[
                models_evaluation_df["Miner hotkey"].str.contains(miner_hotkey_search, na=False, case=False)
            ]
        st.dataframe(filtered_models.style.apply(highlight_score_column, axis=0), height=500, hide_index=True)
    else:
        st.warning("No models evaluation data available.")