Skip to content

Commit

Permalink
Merge pull request #8 from cybercongress/update_availability_subnet
Browse files Browse the repository at this point in the history
Handle FileNotFoundError for a first launch
  • Loading branch information
Snedashkovsky authored May 3, 2024
2 parents 5988341 + a16f649 commit 6a41379
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
17 changes: 11 additions & 6 deletions docs/running_availability_subnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ Your incentive mechanisms running on the mainnet are open to anyone. They emit r

## Infrastructure requirements

Network: Static ip address, open ports 9000 and 10000
CPU: 2 cores
RAM: 4 GB
HDD: < 1 TB
Connection: 30+Mbps, Stable and low-latency connection
Software: Ubuntu 20.04 LTS / 22.04 LTS
- Network
- recommended static ip address
- open ports for miner (default: 10000) and validator (default: 9000)
- 10+Mbps connection, Stable and low-latency connection
- Hardware
- CPU: 2 cores
- RAM: 4 GB
- HDD: < 1 TB
- Software
- OS: Ubuntu 20.04 LTS / 22.04 LTS
- Python: >=3.9.6, <3.12

## Steps

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cybertensor>=0.2.1
cybertensor>=0.2.2
torch
2 changes: 1 addition & 1 deletion template/base/neuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def sync(self):
"""
# Ensure miner or validator hotkey is still registered on the network.
self.check_registered()
self.metagraph.sync(cwtensor=self.cwtensor)

if self.should_sync_metagraph():
self.resync_metagraph()
Expand All @@ -155,6 +154,7 @@ def should_sync_metagraph(self):
"""
Check if enough epoch blocks have elapsed since the last checkpoint to sync.
"""
self.metagraph.sync(cwtensor=self.cwtensor)
return (
self.block - self.metagraph.last_update[self.uid]
) > self.config.neuron.epoch_length
Expand Down
14 changes: 9 additions & 5 deletions template/base/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,12 @@ def load_state(self):
ct.logging.debug(f"Loading validator state from the {self.config.neuron.full_path + '/state.pt'}.")

# Load the state of the validator from file.
state = torch.load(self.config.neuron.full_path + "/state.pt")
self.step = state["step"]
self.scores = state["scores"]
self.hotkeys = state["hotkeys"]
ct.logging.debug(f"Loaded validator state\t step: {self.step}\t scores: {self.scores}")
try:
state = torch.load(self.config.neuron.full_path + "/state.pt")
self.step = state["step"]
self.scores = state["scores"]
self.hotkeys = state["hotkeys"]
ct.logging.debug(f"Loaded validator state\t step: {self.step}\t scores: {self.scores}")
except FileNotFoundError:
self.step = 1
ct.logging.debug(f"Instantiated validator state\t step: {self.step}\t")

0 comments on commit 6a41379

Please sign in to comment.