Skip to content

Commit

Permalink
- add error handler for validator
Browse files Browse the repository at this point in the history
  • Loading branch information
Snedashkovsky committed Apr 24, 2024
1 parent b11f8b7 commit 2f0ace9
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions neurons/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,20 @@ async def forward(self):
if __name__ == "__main__":
with Validator() as validator:
while True:
validator.metagraph.sync(cwtensor=validator.cwtensor)
ct.logging.info(
f"Validator {'is up and running' if validator.thread and validator.thread.is_alive() else 'is running and not working'}\t"
f"step {validator.step if validator.step else '-'}\t"
f"block {validator.block if validator.block else None:>,}\t\t"
f"blocks until sync {validator.config.neuron.epoch_length - validator.block + validator.metagraph.last_update[validator.uid]}"
)
if validator.thread is None or not validator.thread.is_alive():
ct.logging.debug("Stopped")
validator.is_running = False
time.sleep(60)
validator.run_in_background_thread()
try:
validator.metagraph.sync(cwtensor=validator.cwtensor)
ct.logging.info(
f"Validator {'is up and running' if validator.thread and validator.thread.is_alive() else 'is running and not working'}\t"
f"step {validator.step if validator.step else '-'}\t"
f"block {validator.block if validator.block else None:>,}\t\t"
f"blocks until sync {validator.config.neuron.epoch_length - validator.block + validator.metagraph.last_update[validator.uid]}"
)
if validator.thread is None or not validator.thread.is_alive():
ct.logging.debug("Stopped")
validator.is_running = False
time.sleep(60)
validator.run_in_background_thread()
except Exception as e:
ct.logging.error(f"[red]Error:[/red] {e}\t[red]trace:[/red] {traceback.format_exc()}")

time.sleep(15)

0 comments on commit 2f0ace9

Please sign in to comment.