Spaces:
Runtime error
Runtime error
File size: 2,786 Bytes
f5ad77e |
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# 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
|