Skip to content

Commit 0157cab

Browse files
committed
chore: return if all score is 0
1 parent 86baff3 commit 0157cab

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

neurons/validators/validator.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,16 @@ def print_weights(self, raw_weights: np.ndarray):
124124
console.print(weights_table)
125125

126126
def set_weights(self):
127-
# with self.lock:
128-
# current_session = self.session
129-
# last_set_weights_session = self.score_manager.last_set_weights_session
130-
# if last_set_weights_session == current_session - 1:
131-
# return
132-
current_session = self.session
127+
with self.lock:
128+
current_session = self.session
129+
last_set_weights_session = self.score_manager.last_set_weights_session
130+
if last_set_weights_session == current_session - 1:
131+
return
132+
133133
scores = self.score_manager.get_scores(current_session - 1)
134+
if np.all(scores == 0):
135+
bt.logging.info(f"All scores are 0, skipping set_weights")
136+
return
134137
# Calculate the average reward for each uid across non-zero values.
135138
# Replace any NaN values with 0.
136139
# Compute the norm of the scores
@@ -289,12 +292,12 @@ def query_miners_loop(self):
289292
# )
290293
# )
291294
FORWARD_TIMEOUT = 60 * 60 * 2 # 2 hours
292-
# self.query_miners_event_loop.run_until_complete(
293-
# asyncio.wait_for(
294-
# self.genie_validator.forward(),
295-
# timeout=FORWARD_TIMEOUT
296-
# )
297-
# )
295+
self.query_miners_event_loop.run_until_complete(
296+
asyncio.wait_for(
297+
self.genie_validator.forward(),
298+
timeout=FORWARD_TIMEOUT
299+
)
300+
)
298301
except Exception as e:
299302
bt.logging.error(f"Error during query miners loop: {str(e)}")
300303
if self.should_exit:

0 commit comments

Comments
 (0)