Skip to content

Commit

Permalink
set block update to before weight setting code in set_weights loop
Browse files Browse the repository at this point in the history
  • Loading branch information
hscott-yuma committed Dec 5, 2024
1 parent db6e44d commit 3b08678
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion precog/utils/bittensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def setup_bittensor_objects(self):
# if chain endpoint is set, overwrite network arg
self.config.subtensor.network = self.config.subtensor.chain_endpoint
# Initialize subtensor.
self.subtensor = bt.subtensor(config=self.config, chain_endpoint=self.config.subtensor.chain_endpoint)
self.subtensor = bt.subtensor(config=self.config, network=self.config.subtensor.chain_endpoint)
self.metagraph = self.subtensor.metagraph(self.config.netuid)
self.wallet = bt.wallet(config=self.config)
self.dendrite = bt.dendrite(wallet=self.wallet)
Expand Down
14 changes: 7 additions & 7 deletions precog/validators/weight_setter.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ def node_query(self, module, method, params):
return result

async def set_weights(self):
try:
self.current_block = self.subtensor.get_current_block()
self.blocks_since_last_update = (
self.current_block - self.node_query("SubtensorModule", "LastUpdate", [self.config.netuid])[self.my_uid]
)
except Exception:
bt.logging.error("Failed to get current block, skipping block update")
if self.blocks_since_last_update >= self.set_weights_rate:
uids = array(self.available_uids)
weights = [self.moving_average_scores[uid] for uid in self.available_uids]
Expand Down Expand Up @@ -144,13 +151,6 @@ async def set_weights(self):
"Failed to set weights this iteration with message:",
msg,
)
try:
self.current_block = self.subtensor.get_current_block()
self.blocks_since_last_update = (
self.current_block - self.node_query("SubtensorModule", "LastUpdate", [self.config.netuid])[self.my_uid]
)
except Exception:
bt.logging.error("Failed to get current block, skipping block update")

async def scheduled_prediction_request(self):
if not hasattr(self, "timestamp"):
Expand Down

0 comments on commit 3b08678

Please sign in to comment.