Skip to content

Commit

Permalink
Merge pull request #9 from cybercongress/update_availability_subnet
Browse files Browse the repository at this point in the history
Fix NameError in the validator
  • Loading branch information
Snedashkovsky authored May 15, 2024
2 parents 6a41379 + c2eb64c commit e22c040
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
15 changes: 13 additions & 2 deletions neurons/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
# DEALINGS IN THE SOFTWARE.

import time
import traceback
import typing

import cybertensor as ct
from grpc._channel import _InactiveRpcError

# import base miner class which takes care of most of the boilerplate
from template.base.miner import BaseMinerNeuron
Expand All @@ -44,7 +46,7 @@ def __init__(self, config=None):

def save_state(self):
# TODO(developer): State saving you can do here
ct.logging.trace('Miner.save_state function is not implemented')
pass

async def forward(
self, synapse: Dummy
Expand Down Expand Up @@ -160,5 +162,14 @@ async def priority(self, synapse: Dummy) -> float:
if __name__ == "__main__":
with Miner() as miner:
while True:
ct.logging.info("Miner running...", time.time())
try:
ct.logging.info(f"Miner running... block {miner.block if miner.block else None:>,}\t\t")
if miner.thread is None or not miner.thread.is_alive():
ct.logging.debug("Stopped")
miner.is_running = False
time.sleep(60)
miner.run_in_background_thread()
except _InactiveRpcError as e:
ct.logging.error(f"[red]Error:[/red] {e}\t[red]trace:[/red] {traceback.format_exc()}")

time.sleep(15)
6 changes: 4 additions & 2 deletions neurons/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.


import time
import traceback
from typing import Optional

import cybertensor as ct
from grpc._channel import _InactiveRpcError

# import base validator class which takes care of most of the boilerplate
from template.base.validator import BaseValidatorNeuron
from template.validator import forward

Expand Down Expand Up @@ -77,7 +79,7 @@ async def forward(self):
validator.is_running = False
time.sleep(60)
validator.run_in_background_thread()
except Exception as e:
except _InactiveRpcError as e:
ct.logging.error(f"[red]Error:[/red] {e}\t[red]trace:[/red] {traceback.format_exc()}")

time.sleep(15)
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
cybertensor>=0.2.2
torch
cybertensor>=0.2.2

0 comments on commit e22c040

Please sign in to comment.