Spaces:
Runtime error
Runtime error
Update app.py
Browse files5 unmodified lines6789101119 unmodified lines31323334353637383940414210 unmodified lines5354555657585959 unmodified lines11912012112212312412512612712812913013113213313413513673 unmodified lines2102112122132142155 unmodified linesimport datasetsfrom huggingface_hub import snapshot_downloadfrom gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumnsfrom src.display.about import (CITATION_BUTTON_LABEL,19 unmodified linesHF_HOME,)from src.populate import get_evaluation_queue_df, get_leaderboard_dffrom src.tools.plots import create_metric_plot_obj, create_plot_df, create_scores_df# Configure logginglogging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")# Convert the environment variable "LEADERBOARD_FULL_INIT" to a boolean value, defaulting to True if the variable is not set.# This controls whether a full initialization should be performed.DO_FULL_INIT = os.getenv("LEADERBOARD_FULL_INIT", "True") == "True"10 unmodified linesreturn wrapper@time_diff_wrapperdef download_dataset(repo_id, local_dir, repo_type="dataset", max_attempts=3, backoff_factor=1.5):"""Download dataset with exponential backoff retries."""59 unmodified linesreturn leaderboard_df, eval_queue_dfs# Calls the init_space function with the `full_init` parameter determined by the `do_full_init` variable.# This initializes various DataFrames used throughout the application, with the level of initialization detail controlled by the `do_full_init` flag.leaderboard_df, eval_queue_dfs = init_space()finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df = eval_queue_dfs# Data processing for plots now only on demand in the respective Gradio tabdef load_and_create_plots():plot_df = create_plot_df(create_scores_df(leaderboard_df))return plot_dfdef init_leaderboard(dataframe):return Leaderboard(value = dataframe,73 unmodified lines)demo.load(fn=get_latest_data_leaderboard, inputs=[leaderboard], outputs=[leaderboard])demo.queue(default_concurrency_limit=40).launch()5 unmodified lines678910111219 unmodified lines323334353637383940414210 unmodified lines53545556575859 unmodified lines11811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120273 unmodified lines2762772782792805 unmodified linesimport datasetsfrom huggingface_hub import snapshot_downloadfrom gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumnsimport plotly.graph_objects as gofrom src.display.about import (CITATION_BUTTON_LABEL,19 unmodified linesHF_HOME,)from src.populate import get_evaluation_queue_df, get_leaderboard_dffrom src.tools.plots import create_plot_df, create_scores_df# Configure logginglogging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")# Convert the environment variable "LEADERBOARD_FULL_INIT" to a boolean value, defaulting to True if the variable is not set.# This controls whether a full initialization should be performed.DO_FULL_INIT = os.getenv("LEADERBOARD_FULL_INIT", "True") == "True"10 unmodified linesreturn wrapper@time_diff_wrapperdef download_dataset(repo_id, local_dir, repo_type="dataset", max_attempts=3, backoff_factor=1.5):"""Download dataset with exponential backoff retries."""59 unmodified linesreturn leaderboard_df, eval_queue_dfs# Initialize the spaceleaderboard_df, eval_queue_dfs = init_space()finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df = eval_queue_dfs# Data processing for plots now only on demand in the respective Gradio tabdef load_and_create_plots():plot_df = create_plot_df(create_scores_df(leaderboard_df))return plot_dfdef create_metric_plot_obj(df, metrics, title="Metrics Over Time"):"""Create plot with Open-Orca models highlighted in purple"""fig = go.Figure()# Add traces for each metricfor metric in metrics:# Get the model names for this metricmodel_names = df[f"{metric}_model"].tolist()# Create masks for Open-Orca and non-Open-Orca modelsis_open_orca = ["Open-Orca" in str(model) for model in model_names]# Add trace for non-Open-Orca modelsfig.add_trace(go.Scatter(x=df[df.index[~is_open_orca]],y=df[metric][~is_open_orca],name=metric,mode='lines+markers',line=dict(width=2),marker=dict(size=8),hovertemplate=("Date: %{x}<br>""Score: %{y:.2f}<br>""Model: %{text}<br>"),text=[model_names[i] for i, flag in enumerate(is_open_orca) if not flag]))# Add trace for Open-Orca models with purple color and larger markersif any(is_open_orca):fig.add_trace(go.Scatter(x=df[df.index[is_open_orca]],y=df[metric][is_open_orca],name=f"{metric} (Open-Orca)",mode='lines+markers',line=dict(color='purple', width=3),marker=dict(color='purple',size=12,symbol='star'),hovertemplate=("Date: %{x}<br>""Score: %{y:.2f}<br>""Model: %{text}<br>"),text=[model_names[i] for i, flag in enumerate(is_open_orca) if flag]))# Update layoutfig.update_layout(title=title,xaxis_title="Date",yaxis_title="Score",hovermode='x unified',showlegend=True,legend=dict(yanchor="top",y=0.99,xanchor="left",x=0.01))return figdef init_leaderboard(dataframe):return Leaderboard(value = dataframe,73 unmodified lines)demo.load(fn=get_latest_data_leaderboard, inputs=[leaderboard], outputs=[leaderboard])demo.queue(default_concurrency_limit=40).launch()
app.py+74-9