Skip to content

Commit

Permalink
Log dash data generation time
Browse files Browse the repository at this point in the history
  • Loading branch information
jbonilla-tao committed Feb 24, 2025
1 parent fbcc2ee commit 7cff570
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions neurons/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def rc_priority_fn(synapse: template.protocol.ValidatorCheckpoint) -> float:
priority_fn=gp_priority_fn,
)
self.axon.attach(
forward_fn=self.get_data,
forward_fn=self.get_dash_data,
blacklist_fn=gd_blacklist_fn,
priority_fn=gd_priority_fn,
)
Expand Down Expand Up @@ -618,7 +618,7 @@ def should_fail_early(self, synapse: template.protocol.SendSignal | template.pro
elif method == SynapseMethod.CHECKPOINT:
allowed, wait_time = self.checkpoint_rate_limiter.is_allowed(sender_hotkey)
else:
msg = "Received synapse does not match one of expected methods for: receive_signal, get_positions, get_data, or receive_checkpoint"
msg = "Received synapse does not match one of expected methods for: receive_signal, get_positions, get_dash_data, or receive_checkpoint"
bt.logging.trace(msg)
synapse.successfully_processed = False
synapse.error_message = msg
Expand Down Expand Up @@ -805,11 +805,12 @@ def get_positions(self, synapse: template.protocol.GetPositions,
bt.logging.info(msg)
return synapse

def get_data(self, synapse: template.protocol.GetDashData,
def get_dash_data(self, synapse: template.protocol.GetDashData,
) -> template.protocol.GetDashData:
if self.should_fail_early(synapse, SynapseMethod.DASHBOARD):
return synapse

now_ms = TimeUtil.now_in_millis()
miner_hotkey = synapse.dendrite.hotkey
error_message = ""
try:
Expand All @@ -835,6 +836,10 @@ def get_data(self, synapse: template.protocol.GetDashData,
bt.logging.error(error_message)
synapse.successfully_processed = False
synapse.error_message = error_message
processing_time_s_3_decimals = round((TimeUtil.now_in_millis() - now_ms) / 1000.0, 3)
bt.logging.info(
f"Sending dash data back to miner [{miner_hotkey}]. Synapse Message: {synapse.error_message}. "
f"Process time {processing_time_s_3_decimals} seconds.")
return synapse

def receive_checkpoint(self, synapse: template.protocol.ValidatorCheckpoint) -> template.protocol.ValidatorCheckpoint:
Expand Down

0 comments on commit 7cff570

Please sign in to comment.