# Isolated functions to reload the leaderboard data and plot the results from src.leaderboard_utils import filter_search, get_github_data from src.plot_utils import split_models, compare_plots #COMPONENTS TO RELOAD EVERY TIME # leaderboard_table, dummy_leaderboard_table, # open_models_selection, closed_models_selection, show_all, show_names, show_legend #version_select, prev_table, dummy_prev_table class ReloadData(): ''' A class containing methods to reload the leaderboard data and plot the results The methods return individual component values directly to use 'every' arg in the component ''' def __init__(self): print("Initializing Reload...........") self.primary_leaderboard_df, self.version_dfs, self.version_names = get_github_data() self.plot_df = self.primary_leaderboard_df[0] self.models = list(self.plot_df[list(self.plot_df.columns)[0]].unique()) print("Reload completed ....... Here's a reloaded dataframe for latest version") print(self.primary_leaderboard_df) def get_primary_leaderboard(self): ''' Returns self.primary_leaderboard_df[0]: Dataframe containing the primary leaderboard (laterst version of the benchmark results) ''' return self.primary_leaderboard_df[0] def get_open_models(self): ''' Returns open_models: Checkbox group containing the open models ''' self.open_models, _ = split_models(self.models) return self.open_models def get_closed_models(self): ''' Returns closed_models: Checkbox group containing the closed models ''' _, self.closed_models = split_models(self.models) return self.closed_models def get_plot_df(self): ''' Returns plot_df: Dataframe containing the results of latest version for plotting ''' return self.plot_df def get_version_names(self): ''' Returns version_names: List containing the versions of the benchmark results for dropdown selection ''' return self.version_names def get_version_df(self): ''' Returns version_dfs: Dataframe containing the benchmark results for all versions ''' return self.version_dfs def get_prev_df(self, name='initial'): ''' Returns prev_df: Dataframe containing the benchmark results for the previous versions (default = latest version) ''' if name == 'initial': name = self.version_names[0] ind = self.version_names.index(name) self.prev_df = self.version_dfs[ind] return self.prev_df