From 45c71b28f1e74362eb7ad4eea3e91b4042c80d5d Mon Sep 17 00:00:00 2001 From: skynet Date: Tue, 24 Dec 2024 12:47:57 +0800 Subject: [PATCH] feat(register_api): add query miner version add the function in check_miner_status endpoint --- neurons/register_api.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/neurons/register_api.py b/neurons/register_api.py index 0daff4e7..bd099e25 100644 --- a/neurons/register_api.py +++ b/neurons/register_api.py @@ -783,7 +783,7 @@ async def deallocate(hotkey: str, uuid_key: str, request: Request, notify_flag: }, } ) - async def check_miner_status(hotkey_list: List[str]) -> JSONResponse: + async def check_miner_status(hotkey_list: List[str], query_version: bool = False) -> JSONResponse: checking_list = [] for hotkey in hotkey_list: checking_result = { @@ -793,16 +793,20 @@ async def check_miner_status(hotkey_list: List[str]) -> JSONResponse: for axon in self.metagraph.axons: if axon.hotkey == hotkey: try: - register_response = await run_in_threadpool(self.dendrite.query, - axon, Allocate(timeline=1, checking=True, ), - timeout=60) - if register_response: - if register_response["status"] is True: - checking_result = {"hotkey": hotkey, "status": "Docker OFFLINE"} - else: - checking_result = {"hotkey": hotkey, "status": "Docker ONLINE"} + if query_version: + checking_result = {"hotkey": hotkey, "version": axon.version} else: - checking_result = {"hotkey": hotkey, "status": "Miner NO_RESPONSE"} + register_response = await run_in_threadpool(self.dendrite.query, + axon, Allocate(timeline=1, checking=True, ), + timeout=10) + await asyncio.sleep(0.1) + if register_response: + if register_response["status"] is True: + checking_result = {"hotkey": hotkey, "status": "Docker OFFLINE"} + else: + checking_result = {"hotkey": hotkey, "status": "Docker ONLINE"} + else: + checking_result = {"hotkey": hotkey, "status": "Miner NO_RESPONSE"} except Exception as e: bt.logging.error( f"API: An error occur during the : {e}"