Skip to content

Commit

Permalink
Merge pull request #250 from thomas-chu123/feature/CSN-409-api-detect…
Browse files Browse the repository at this point in the history
…-miner-version

feature/CSN-409-api-detect-miner-version
  • Loading branch information
mo0haned authored Jan 21, 2025
2 parents 407c508 + 45c71b2 commit 9204d98
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions neurons/register_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,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 = {
Expand All @@ -818,16 +818,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}"
Expand Down

0 comments on commit 9204d98

Please sign in to comment.