Update app.py
Browse files
app.py
CHANGED
@@ -8,12 +8,13 @@ import base64
|
|
8 |
import os
|
9 |
|
10 |
# Define the columns
|
11 |
-
MAIN_COLS = ['#P', 'Model', 'UGI π', 'W/10 π', 'NatInt π‘', 'Coding π»', 'Political Lean π', 'Ideology Name']
|
12 |
AXES_COLS_1 = ['govt', 'dipl', 'econ', 'scty']
|
13 |
AXES_COLS_2 = ['Federal-Unitary', 'Democratic-Autocratic', 'Security-Freedom', 'Nationalism-Internationalism',
|
14 |
'Militarist-Pacifist', 'Assimilationist-Multiculturalist', 'Collectivize-Privatize',
|
15 |
'Planned-LaissezFaire', 'Isolationism-Globalism', 'Irreligious-Religious',
|
16 |
'Progressive-Traditional', 'Acceleration-Bioconservative']
|
|
|
17 |
|
18 |
def load_leaderboard_data(csv_file_path):
|
19 |
try:
|
@@ -163,16 +164,17 @@ app.index_string = '''
|
|
163 |
color: var(--text-color) !important;
|
164 |
}
|
165 |
/* Filter Styles */
|
166 |
-
.model-type-filter
|
|
|
|
|
|
|
|
|
167 |
#model-type-filter label,
|
168 |
#na-model-filter label {
|
169 |
color: var(--text-color) !important;
|
170 |
margin-right: 10px;
|
171 |
font-weight: bold;
|
172 |
}
|
173 |
-
.filter-description {
|
174 |
-
color: var(--secondary-text) !important;
|
175 |
-
}
|
176 |
/* Grid Styles */
|
177 |
.ag-theme-alpine {
|
178 |
--ag-font-family: 'Segoe UI', Arial, sans-serif;
|
@@ -206,6 +208,7 @@ app.index_string = '''
|
|
206 |
white-space: normal !important;
|
207 |
line-height: 1.2em;
|
208 |
overflow: visible;
|
|
|
209 |
}
|
210 |
|
211 |
.ag-header-cell {
|
@@ -499,7 +502,14 @@ columnDefs = [
|
|
499 |
"cellClass": "ag-left-aligned-cell",
|
500 |
"wrapHeaderText": True,
|
501 |
"autoHeaderHeight": True
|
502 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
{
|
504 |
"headerName": "Ideology",
|
505 |
"field": "Ideology Name",
|
@@ -672,7 +682,16 @@ dashGridOptions = {
|
|
672 |
}
|
673 |
"""
|
674 |
},
|
675 |
-
"theme": "ag-theme-alpine-dark" if "prefers-color-scheme: dark" else "ag-theme-alpine"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
676 |
}
|
677 |
|
678 |
# Define the layout
|
@@ -721,14 +740,14 @@ app.layout = html.Div([
|
|
721 |
|
722 |
html.Div([
|
723 |
html.Div("To filter columns, click the β‘ next to a column's name. On mobile, hold the column name for the menu to appear.",
|
724 |
-
|
725 |
-
style={'marginBottom': '20px'}),
|
726 |
], style={'padding': '0 20px'}),
|
727 |
|
728 |
# Model Type Filter
|
729 |
html.Div([
|
730 |
html.Div([
|
731 |
-
html.Label("Display Models:",
|
|
|
732 |
dcc.Checklist(
|
733 |
id='model-type-filter',
|
734 |
options=[
|
@@ -737,21 +756,40 @@ app.layout = html.Div([
|
|
737 |
{'label': 'Merge', 'value': 'Is Merged'},
|
738 |
{'label': 'Proprietary', 'value': 'proprietary'}
|
739 |
],
|
740 |
-
value=['Is Foundation', 'Is Finetuned', 'Is Merged', 'proprietary'],
|
741 |
inline=True,
|
742 |
-
style={'display': 'inline-block'}
|
|
|
743 |
)
|
744 |
], style={'float': 'left'}),
|
745 |
html.Div([
|
746 |
dcc.Checklist(
|
747 |
id='na-model-filter',
|
748 |
options=[{'label': 'NA Models', 'value': 'show_na'}],
|
749 |
-
value=[],
|
750 |
inline=True,
|
751 |
-
style={'display': 'inline-block'}
|
|
|
752 |
)
|
753 |
], style={'float': 'right'})
|
754 |
-
], style={'marginBottom': '20px', 'padding': '0 20px', 'overflow': 'hidden'}),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
755 |
|
756 |
# Grid
|
757 |
html.Div([
|
@@ -927,6 +965,32 @@ def update_grid(selected_types, show_na, pinned_rows):
|
|
927 |
|
928 |
return records, selected_types, pinned_models
|
929 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
930 |
@app.callback(
|
931 |
Output('ideology-descriptions', 'children'),
|
932 |
[Input('leaderboard-grid', 'rowData')]
|
|
|
8 |
import os
|
9 |
|
10 |
# Define the columns
|
11 |
+
MAIN_COLS = ['#P', 'Model', 'UGI π', 'W/10 π', 'NatInt π‘', 'Coding π»', 'Unruly', 'Internet', 'Soc/Pol', 'Political Lean π', 'Ideology Name']
|
12 |
AXES_COLS_1 = ['govt', 'dipl', 'econ', 'scty']
|
13 |
AXES_COLS_2 = ['Federal-Unitary', 'Democratic-Autocratic', 'Security-Freedom', 'Nationalism-Internationalism',
|
14 |
'Militarist-Pacifist', 'Assimilationist-Multiculturalist', 'Collectivize-Privatize',
|
15 |
'Planned-LaissezFaire', 'Isolationism-Globalism', 'Irreligious-Religious',
|
16 |
'Progressive-Traditional', 'Acceleration-Bioconservative']
|
17 |
+
UGI_CATEGORY_COLS = ['Unruly', 'Internet', 'Soc/Pol']
|
18 |
|
19 |
def load_leaderboard_data(csv_file_path):
|
20 |
try:
|
|
|
164 |
color: var(--text-color) !important;
|
165 |
}
|
166 |
/* Filter Styles */
|
167 |
+
.model-type-filter {
|
168 |
+
color: var(--text-color) !important;
|
169 |
+
margin-right: 10px;
|
170 |
+
font-weight: bold;
|
171 |
+
},
|
172 |
#model-type-filter label,
|
173 |
#na-model-filter label {
|
174 |
color: var(--text-color) !important;
|
175 |
margin-right: 10px;
|
176 |
font-weight: bold;
|
177 |
}
|
|
|
|
|
|
|
178 |
/* Grid Styles */
|
179 |
.ag-theme-alpine {
|
180 |
--ag-font-family: 'Segoe UI', Arial, sans-serif;
|
|
|
208 |
white-space: normal !important;
|
209 |
line-height: 1.2em;
|
210 |
overflow: visible;
|
211 |
+
padding-bottom: 4px;
|
212 |
}
|
213 |
|
214 |
.ag-header-cell {
|
|
|
502 |
"cellClass": "ag-left-aligned-cell",
|
503 |
"wrapHeaderText": True,
|
504 |
"autoHeaderHeight": True
|
505 |
+
}
|
506 |
+
]
|
507 |
+
|
508 |
+
ugi_category_columns = [
|
509 |
+
create_numeric_column(col, width=120) for col in UGI_CATEGORY_COLS
|
510 |
+
]
|
511 |
+
|
512 |
+
political_columns = [
|
513 |
{
|
514 |
"headerName": "Ideology",
|
515 |
"field": "Ideology Name",
|
|
|
682 |
}
|
683 |
"""
|
684 |
},
|
685 |
+
"theme": "ag-theme-alpine-dark" if "prefers-color-scheme: dark" else "ag-theme-alpine",
|
686 |
+
"columnState": {
|
687 |
+
"function": """
|
688 |
+
function() {
|
689 |
+
return {
|
690 |
+
columnVisibility: {}
|
691 |
+
};
|
692 |
+
}
|
693 |
+
"""
|
694 |
+
}
|
695 |
}
|
696 |
|
697 |
# Define the layout
|
|
|
740 |
|
741 |
html.Div([
|
742 |
html.Div("To filter columns, click the β‘ next to a column's name. On mobile, hold the column name for the menu to appear.",
|
743 |
+
style={'marginBottom': '20px', 'color': 'var(--text-color)'}), # Use text-color variable
|
|
|
744 |
], style={'padding': '0 20px'}),
|
745 |
|
746 |
# Model Type Filter
|
747 |
html.Div([
|
748 |
html.Div([
|
749 |
+
html.Label("Display Models:",
|
750 |
+
className="model-type-filter"), # This will make it bold
|
751 |
dcc.Checklist(
|
752 |
id='model-type-filter',
|
753 |
options=[
|
|
|
756 |
{'label': 'Merge', 'value': 'Is Merged'},
|
757 |
{'label': 'Proprietary', 'value': 'proprietary'}
|
758 |
],
|
759 |
+
value=['Is Foundation', 'Is Finetuned', 'Is Merged', 'proprietary'],
|
760 |
inline=True,
|
761 |
+
style={'display': 'inline-block'},
|
762 |
+
labelStyle={'fontWeight': 'normal', 'marginRight': '15px'} # Add consistent spacing
|
763 |
)
|
764 |
], style={'float': 'left'}),
|
765 |
html.Div([
|
766 |
dcc.Checklist(
|
767 |
id='na-model-filter',
|
768 |
options=[{'label': 'NA Models', 'value': 'show_na'}],
|
769 |
+
value=[],
|
770 |
inline=True,
|
771 |
+
style={'display': 'inline-block'},
|
772 |
+
labelStyle={'fontWeight': 'normal'} # Make sure NA Models isn't bold
|
773 |
)
|
774 |
], style={'float': 'right'})
|
775 |
+
], style={'marginBottom': '20px', 'padding': '0 20px', 'overflow': 'hidden'}),
|
776 |
+
|
777 |
+
# Additional Columns Filter
|
778 |
+
html.Div([
|
779 |
+
html.Label("Show additional columns:",
|
780 |
+
className="model-type-filter"), # Use same class for consistent styling
|
781 |
+
dcc.Checklist(
|
782 |
+
id='additional-columns-filter',
|
783 |
+
options=[
|
784 |
+
{'label': 'UGI Categories', 'value': 'ugi_categories'},
|
785 |
+
{'label': 'Political Test Axes', 'value': 'political_axes'}
|
786 |
+
],
|
787 |
+
value=[],
|
788 |
+
inline=True,
|
789 |
+
style={'display': 'inline-block'},
|
790 |
+
labelStyle={'fontWeight': 'normal', 'marginRight': '15px'} # Add consistent spacing
|
791 |
+
)
|
792 |
+
], style={'marginBottom': '20px', 'padding': '0 20px', 'overflow': 'hidden'}),
|
793 |
|
794 |
# Grid
|
795 |
html.Div([
|
|
|
965 |
|
966 |
return records, selected_types, pinned_models
|
967 |
|
968 |
+
@app.callback(
|
969 |
+
Output('leaderboard-grid', 'columnDefs'),
|
970 |
+
[Input('additional-columns-filter', 'value')]
|
971 |
+
)
|
972 |
+
def update_columns(additional_columns):
|
973 |
+
# Start with base columns up to UGI
|
974 |
+
current_columns = columnDefs[:7] # Include up to UGI column
|
975 |
+
|
976 |
+
# Add UGI category columns if selected
|
977 |
+
if 'ugi_categories' in additional_columns:
|
978 |
+
current_columns.extend(ugi_category_columns)
|
979 |
+
|
980 |
+
# Add remaining base columns (W/10, NatInt, Coding, Political Lean)
|
981 |
+
current_columns.extend(columnDefs[7:11])
|
982 |
+
|
983 |
+
# Add political columns if selected
|
984 |
+
if 'political_axes' in additional_columns:
|
985 |
+
current_columns.extend(political_columns)
|
986 |
+
current_columns.extend([col for col in columnDefs if col['field'] in AXES_COLS_1])
|
987 |
+
current_columns.extend([col for col in columnDefs if col['field'] in AXES_COLS_2])
|
988 |
+
|
989 |
+
# Always add date columns at the end
|
990 |
+
current_columns.extend([col for col in columnDefs if col['field'] in ['Release Date', 'Test Date']])
|
991 |
+
|
992 |
+
return current_columns
|
993 |
+
|
994 |
@app.callback(
|
995 |
Output('ideology-descriptions', 'children'),
|
996 |
[Input('leaderboard-grid', 'rowData')]
|