8
8
from typing import List
9
9
10
10
from webgenie .base .neuron import BaseNeuron
11
+
11
12
from webgenie .challenges .challenge import Challenge , RESERVED_WEIGHTS
12
13
from webgenie .constants import CONSIDERING_SESSION_COUNTS , __STATE_VERSION__ , WORK_DIR
13
14
from webgenie .helpers .weights import save_file_to_wandb
@@ -133,13 +134,11 @@ def update_scores(self, rewards: np.ndarray, uids: List[int], challenge: Challen
133
134
self .total_scores [uids ] += rewards
134
135
self .solved_tasks [uids ] += 1
135
136
136
- avg_scores = np .zeros (self .neuron .metagraph .n , dtype = np .float32 )
137
- for uid in range (self .neuron .metagraph .n ):
138
- if self .solved_tasks [uid ] >= max (1 , self .number_of_tasks / 2 ):
139
- avg_scores [uid ] = self .total_scores [uid ] / self .solved_tasks [uid ]
140
- else :
141
- avg_scores [uid ] = 0
142
- winner = np .argmax (avg_scores ) if max (avg_scores ) > 0 else - 1
137
+ winner = self .get_winner (
138
+ self .total_scores ,
139
+ self .solved_tasks ,
140
+ self .number_of_tasks ,
141
+ )
143
142
144
143
current_session_results = {
145
144
"session" : session ,
@@ -160,13 +159,31 @@ def update_scores(self, rewards: np.ndarray, uids: List[int], challenge: Challen
160
159
161
160
console = Console ()
162
161
self .print_session_result (session , console )
162
+
163
+ def is_blacklisted (self , uid : int ):
164
+ blacklisted_coldkeys = ["5G9yTkkDd39chZiyvKwNsQvzqbbPgdiLtdb4sCR743f4MuRY" ]
165
+ return self .neuron .metagraph .axons [uid ].coldkey in blacklisted_coldkeys
166
+
167
+ def get_winner (self , total_scores : np .ndarray , solved_tasks : np .ndarray , number_of_tasks : int ):
168
+ avg_scores = np .zeros (self .neuron .metagraph .n , dtype = np .float32 )
169
+ for uid in range (self .neuron .metagraph .n ):
170
+ if self .is_blacklisted (uid ):
171
+ continue
172
+
173
+ if solved_tasks [uid ] >= max (1 , number_of_tasks - MAX_UNANSWERED_TASKS ):
174
+ avg_scores [uid ] = total_scores [uid ] / solved_tasks [uid ]
175
+ else :
176
+ avg_scores [uid ] = 0
177
+ winner = np .argmax (avg_scores ) if max (avg_scores ) > 0 else - 1
178
+ return winner
163
179
164
180
def get_scores (self , session_upto : int ):
165
181
scores = np .zeros (self .neuron .metagraph .n , dtype = np .float32 )
166
182
for session_number in self .session_results :
167
183
if (session_number <= session_upto - CONSIDERING_SESSION_COUNTS or
168
184
session_number > session_upto ):
169
185
continue
186
+
170
187
try :
171
188
winner = self .session_results [session_number ]["winner" ]
172
189
competition_type = self .session_results [session_number ]["competition_type" ]
@@ -175,6 +192,7 @@ def get_scores(self, session_upto: int):
175
192
scores [winner ] += RESERVED_WEIGHTS [competition_type ]
176
193
except Exception as e :
177
194
bt .logging .warning (f"Error getting scores: { e } " )
195
+
178
196
return scores
179
197
# scores = np.zeros(self.neuron.metagraph.n, dtype=np.float32)
180
198
# tiny_weight = 1 / 128
@@ -212,7 +230,7 @@ def print_session_result(self, session_upto: int, console: Console):
212
230
213
231
avg_scores = np .zeros (self .neuron .metagraph .n , dtype = np .float32 )
214
232
for uid in range (self .neuron .metagraph .n ):
215
- if solved_tasks [uid ] >= max (1 , number_of_tasks / 2 ):
233
+ if solved_tasks [uid ] >= max (1 , number_of_tasks - MAX_UNANSWERED_TASKS ):
216
234
avg_scores [uid ] = scores [uid ] / solved_tasks [uid ]
217
235
else :
218
236
avg_scores [uid ] = 0
0 commit comments