idolezal commited on
Commit
52f1ee8
1 Parent(s): 00e4942

New model title

Browse files
Files changed (1) hide show
  1. server.py +20 -1
server.py CHANGED
@@ -105,7 +105,10 @@ class LeaderboardServer:
105
  if metric_value is not None:
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
@@ -173,6 +176,22 @@ class LeaderboardServer:
173
  }
174
  return new_tournament
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  @staticmethod
177
  def create_submission_id(metadata):
178
  # Délka ID musí být omezena, protože se používá v názvu souboru
 
105
  if metric_value is not None:
106
  local_results[task + "_" + metric] = metric_value
107
 
108
+ model_link = data["metadata"]["link_to_model"]
109
+ model_title = data["metadata"]["model_name"] + "/" + data["metadata"]["model_type"]
110
+ model_title_abbr = self.abbreviate(data["metadata"]["model_name"], 14) + "/" + self.abbreviate(data["metadata"]["model_type"], 14)
111
+ local_results["model"] = f'<a href="{model_link}" title="{model_title}">{model_title_abbr}</a>'
112
  release = data["metadata"].get("submission_timestamp")
113
  release = time.strftime("%Y-%m-%d", time.gmtime(release)) if release else "N/A"
114
  local_results["release"] = release
 
176
  }
177
  return new_tournament
178
 
179
+ @staticmethod
180
+ def abbreviate(s, max_length, dots_place="center"):
181
+ if len(s) <= max_length:
182
+ return s
183
+ else:
184
+ if max_length <= 1:
185
+ return "…"
186
+ elif dots_place == "begin":
187
+ return "…" + s[-max_length + 1:]
188
+ elif dots_place == "center" and max_length >= 3:
189
+ max_length_begin = max_length / 2
190
+ max_length_end = max_length - max_length_begin - 1
191
+ return s[:max_length_begin] + "…" + s[-max_length_end:]
192
+ else: # dots_place == "end"
193
+ return s[:max_length - 1] + "…"
194
+
195
  @staticmethod
196
  def create_submission_id(metadata):
197
  # Délka ID musí být omezena, protože se používá v názvu souboru