Skip to content

Commit

Permalink
added try block for when node-query fails
Browse files Browse the repository at this point in the history
  • Loading branch information
hscott-yuma committed Dec 5, 2024
1 parent 6aa5ed1 commit 64c486a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions precog/utils/bittensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ 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, network=self.config.subtensor.network)
self.subtensor = bt.subtensor(config=self.config)
self.metagraph = self.subtensor.metagraph(self.config.netuid)
self.wallet = bt.wallet(name=self.config.wallet.name, hotkey=self.config.wallet.hotkey)
self.wallet = bt.wallet(config=self.config)
self.dendrite = bt.dendrite(wallet=self.wallet)
self.axon = bt.axon(wallet=self.wallet, config=self.config, port=self.config.axon.port)
# Connect the validator to the network.
Expand Down
11 changes: 7 additions & 4 deletions precog/validators/weight_setter.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,13 @@ async def set_weights(self):
"Failed to set weights this iteration with message:",
msg,
)
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]
)
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 64c486a

Please sign in to comment.