|
17 | 17 | MAX_UNANSWERED_TASKS
|
18 | 18 | )
|
19 | 19 | from webgenie.helpers.weights import save_file_to_wandb
|
20 |
| - |
| 20 | +from webgenie.storage import submit_results |
21 | 21 | class ScoreManager:
|
22 | 22 | def __init__(self, neuron: BaseNeuron):
|
23 | 23 | self.neuron = neuron
|
@@ -282,3 +282,38 @@ def save_session_result_to_file(self, session_upto: int):
|
282 | 282 | bt.logging.error(f"Error saving session result to file: {e}")
|
283 | 283 | raise e
|
284 | 284 |
|
| 285 | + def submit_results_to_dashboard(self, session_upto: int): |
| 286 | + try: |
| 287 | + session_result = self.session_results[session_upto] |
| 288 | + |
| 289 | + number_of_tasks = session_result["number_of_tasks"] |
| 290 | + session = session_result["session"] |
| 291 | + competition_type = session_result["competition_type"] |
| 292 | + scores = session_result["scores"] |
| 293 | + solved_tasks = session_result["solved_tasks"] |
| 294 | + competition = { |
| 295 | + "session_number": int(session), |
| 296 | + "competition_type": competition_type, |
| 297 | + } |
| 298 | + |
| 299 | + submissions = [] |
| 300 | + avg_scores = np.zeros(self.neuron.metagraph.n, dtype=np.float32) |
| 301 | + for uid in range(self.neuron.metagraph.n): |
| 302 | + if solved_tasks[uid] >= max(1, number_of_tasks - MAX_UNANSWERED_TASKS): |
| 303 | + avg_scores[uid] = scores[uid] / solved_tasks[uid] |
| 304 | + else: |
| 305 | + avg_scores[uid] = 0 |
| 306 | + submissions.append({ |
| 307 | + "neuron": { |
| 308 | + "hotkey": self.neuron.metagraph.hotkeys[uid], |
| 309 | + }, |
| 310 | + "score": float(avg_scores[uid]), |
| 311 | + }) |
| 312 | + |
| 313 | + submit_results({ |
| 314 | + "competition": competition, |
| 315 | + "submissions": submissions, |
| 316 | + }) |
| 317 | + except Exception as e: |
| 318 | + bt.logging.error(f"Error submitting results to dashboard: {e}") |
| 319 | + raise e |
0 commit comments