File size: 1,836 Bytes
e60235b
 
 
 
 
969e123
41cd888
 
 
 
 
 
 
55af4cc
969e123
e60235b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
969e123
e60235b
969e123
e60235b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97fcb64
969e123
97fcb64
 
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

import streamlit as st
import pandas as pd
import opendashboards.utils.utils as utils

def clean_data(df):
    task_map = {
        'question-answering': 'QA',
        'summarization': 'Summarization',
        'date-based question answering': 'Date QA',
        'math': 'Math'
    }
    df['task'] = df.task.map(task_map)
    return df.dropna(subset=df.filter(regex='completions|rewards').columns, how='any')

@st.cache_data
def explode_data(df):
    list_cols = utils.get_list_col_lengths(df)
    try:
        return utils.explode_data(df, list(list_cols.keys())).apply(pd.to_numeric, errors='ignore')
    except Exception as e:
        st.error(f'Error exploding data with columns')
        st.write(list_cols)
        st.exception(e)
        st.dataframe(df)
        st.stop()

@st.cache_data
def completions(df_long, col):
    return df_long[col].value_counts()


def run_event_data(df_runs, df, selected_runs):

    st.markdown('#')

    show_col1, show_col2 = st.columns(2)
    show_runs = show_col1.checkbox('Show runs', value=True)
    show_events = show_col2.checkbox('Show events', value=False)
    if show_runs:
        st.markdown(f'Wandb info for **{len(selected_runs)} selected runs**:')
        st.dataframe(df_runs.loc[df_runs.id.isin(selected_runs)],
                    column_config={
                        "url": st.column_config.LinkColumn("URL"),
                    }
        )

    if show_events:
        st.markdown(f'Raw events for **{len(selected_runs)} selected runs**:')
        st.dataframe(df.head(50),
                    column_config={
                        "url": st.column_config.LinkColumn("URL"),
                    }
        )

def highlight_row(row, expr, color='lightgrey', bg_color='white'):
    return [f'background-color:{color}' if expr else f'background-color:{bg_color}'] * len(row)