idolezal commited on
Commit
e576387
1 Parent(s): 522baf4

Added `submission_timestamp` and more attributes to table

Browse files
Files changed (1) hide show
  1. server.py +37 -10
server.py CHANGED
@@ -3,6 +3,7 @@ import glob
3
  import json
4
  import os
5
  import hashlib
 
6
  from collections import namedtuple
7
 
8
  import gradio as gr
@@ -105,24 +106,49 @@ class LeaderboardServer:
105
  local_results[task + "_" + metric] = metric_value
106
 
107
  local_results["model"] = f'<a href="{data["metadata"]["link_to_model"]}">{submission_id}</a>'
 
 
 
 
 
 
108
 
109
  if self.pre_submit and submission_id == self.pre_submit.submission_id:
110
  processed_results.insert(0, local_results)
111
  else:
112
  processed_results.append(local_results)
113
  dataframe = pd.DataFrame.from_records(processed_results)
114
- df_order = (
115
- ["model"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  + list(self.tasks_metadata.keys())
117
- + [
118
- col
119
- for col in dataframe.columns
120
- if col != "model" and col not in self.tasks_metadata.keys()
121
- ]
122
- )
123
  dataframe = dataframe[df_order]
 
 
124
  dataframe = dataframe.rename(
125
- columns={key: value["abbreviation"] for key, value in self.tasks_metadata.items()}
126
  )
127
  return dataframe
128
 
@@ -177,10 +203,11 @@ class LeaderboardServer:
177
  metadata["model_predictions_sha256"] = self.get_sha256_hexdigest(data["predictions"])
178
  metadata["model_results_sha256"] = self.get_sha256_hexdigest(data["results"])
179
 
180
- # Délka ID můsí být omezena, protože se používá v názvu souboru
181
  submission_id = self.create_submission_id(metadata)
182
  metadata["submission_id"] = submission_id
183
 
 
 
184
  with open(file, "w") as f:
185
  json.dump(data, f, separators=(',', ':')) # compact JSON
186
 
 
3
  import json
4
  import os
5
  import hashlib
6
+ import time
7
  from collections import namedtuple
8
 
9
  import gradio as gr
 
106
  local_results[task + "_" + metric] = metric_value
107
 
108
  local_results["model"] = f'<a href="{data["metadata"]["link_to_model"]}">{submission_id}</a>'
109
+ release = data["metadata"].get("submission_timestamp")
110
+ release = time.strftime("%Y-%m-%d", time.gmtime(release)) if release else "N/A"
111
+ local_results["release"] = release
112
+ local_results["model_type"] = data["metadata"]["model_type"]
113
+ local_results["parameters"] = data["metadata"]["parameters"]
114
+ local_results["win_score"] = "TBD" # TODO: Implementovat výpočet WinScore
115
 
116
  if self.pre_submit and submission_id == self.pre_submit.submission_id:
117
  processed_results.insert(0, local_results)
118
  else:
119
  processed_results.append(local_results)
120
  dataframe = pd.DataFrame.from_records(processed_results)
121
+
122
+ extra_attributes_map_word_to_header = {
123
+ "model": "Model",
124
+ "release": "Release",
125
+ "win_score": "Win score",
126
+ "team_name": "Team name",
127
+ "model_name": "Model name",
128
+ "model_type": "Type",
129
+ "parameters": "Parameters",
130
+ "precision": "Precision",
131
+ "description": "Description",
132
+ "link_to_model": "Link to model"
133
+ }
134
+ first_attributes = [
135
+ "model",
136
+ "release",
137
+ "model_type",
138
+ "parameters",
139
+ "win_score",
140
+ ]
141
+ df_order = list(dict.fromkeys(
142
+ first_attributes
143
  + list(self.tasks_metadata.keys())
144
+ + list(dataframe.columns)
145
+ + list(extra_attributes_map_word_to_header.keys())
146
+ ).keys())
 
 
 
147
  dataframe = dataframe[df_order]
148
+ attributes_map_word_to_header = {key: value["abbreviation"] for key, value in self.tasks_metadata.items()}
149
+ attributes_map_word_to_header.update(extra_attributes_map_word_to_header)
150
  dataframe = dataframe.rename(
151
+ columns=attributes_map_word_to_header
152
  )
153
  return dataframe
154
 
 
203
  metadata["model_predictions_sha256"] = self.get_sha256_hexdigest(data["predictions"])
204
  metadata["model_results_sha256"] = self.get_sha256_hexdigest(data["results"])
205
 
 
206
  submission_id = self.create_submission_id(metadata)
207
  metadata["submission_id"] = submission_id
208
 
209
+ metadata["submission_timestamp"] = time.time() # timestamp
210
+
211
  with open(file, "w") as f:
212
  json.dump(data, f, separators=(',', ':')) # compact JSON
213