From 639434503234b5d0332be9db4de6219e7120eb49 Mon Sep 17 00:00:00 2001 From: Serge Nedashkovsky Date: Thu, 9 May 2024 11:39:42 +1000 Subject: [PATCH 1/2] - remove tensor from requirements, it's already included in the cybertensor package - fix NameError in the validator --- neurons/validator.py | 2 +- requirements.txt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/neurons/validator.py b/neurons/validator.py index 06fd090..94b77ab 100644 --- a/neurons/validator.py +++ b/neurons/validator.py @@ -18,7 +18,7 @@ # 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 traceback import time from typing import Optional diff --git a/requirements.txt b/requirements.txt index 1dccad3..819fc59 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ -cybertensor>=0.2.2 -torch \ No newline at end of file +cybertensor>=0.2.2 \ No newline at end of file From c2eb64c74b15d29c74c9f6980060a089fbdf92dd Mon Sep 17 00:00:00 2001 From: Serge Nedashkovsky Date: Wed, 15 May 2024 22:17:54 +1000 Subject: [PATCH 2/2] - fix miner stopping in Availability subnet --- neurons/miner.py | 15 +++++++++++++-- neurons/validator.py | 6 ++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/neurons/miner.py b/neurons/miner.py index dc1e950..3861752 100644 --- a/neurons/miner.py +++ b/neurons/miner.py @@ -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 @@ -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 @@ -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) diff --git a/neurons/validator.py b/neurons/validator.py index 94b77ab..8497430 100644 --- a/neurons/validator.py +++ b/neurons/validator.py @@ -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 traceback 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 @@ -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)