File size: 2,006 Bytes
e60235b
 
 
 
 
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
58
59
60

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

def clean_data(df):
    return df.dropna(subset=df.filter(regex='completions|rewards').columns, how='all')

@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()

@st.cache_data
def weights(df, index='_timestamp'):
    # Create a column for each UID and show most recent rows
    scores = df['moving_averaged_scores'].apply(pd.Series).fillna(method='ffill')
    if index in df.columns:
        scores.index = df[index]

    # rename columns
    scores.rename({i: f'UID-{i}' for i in range(scores.shape[1])}, axis=1, inplace=True)
    return scores

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)