Spaces:
Runtime error
Runtime error
Update app.py
Browse files5 unmodified lines678910111219 unmodified lines3233343435363738393940414210 unmodified lines5354555656575859 unmodified lines11811912012212312412112212312412812512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120273 unmodified lines2762772782132792152805 unmodified linesimport datasetsfrom huggingface_hub import snapshot_downloadfrom gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumnsimport plotly.graph_objects as go
from src.display.about import ( CITATION_BUTTON_LABEL,19 unmodified lines HF_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_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 lines
return 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 lines
return 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.# 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_df
def 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 metric for metric in metrics: # Get the model names for this metric model_names = df[f"{metric}_model"].tolist() # Create masks for Open-Orca and non-Open-Orca models is_open_orca = ["Open-Orca" in str(model) for model in model_names] # Add trace for non-Open-Orca models fig.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 markers if 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 layout fig.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 fig
def 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()demo.queue(default_concurrency_limit=40).launch()app.py+74-9