Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Successful in 4s
Deploy to Testnet / deploy-testnet (push) Successful in 1m45s
Documentation Validation / validate-docs (push) Failing after 13s
Documentation Validation / validate-policies-strict (push) Successful in 5s
Integration Tests / test-service-integration (push) Failing after 5s
Multi-Node Stress Testing / stress-test (push) Successful in 2s
Python Tests / test-python (push) Failing after 32s
Security Scanning / security-scan (push) Failing after 31s
Build Debian Miner Binary / build-miner (push) Failing after 5m50s
- Renamed ai-service to aitbc-ai-service - Renamed edge-api to aitbc-edge-api - Updated pyproject.toml files with new package names - Renamed directories and package modules - Updated references in documentation and scripts - All internal packages now follow aitbc- naming convention
51 lines
2.0 KiB
Python
51 lines
2.0 KiB
Python
"""GPU service client for Edge API Service"""
|
|
|
|
import httpx
|
|
from typing import Dict, Optional, Any, List
|
|
|
|
from ..config import settings
|
|
|
|
|
|
class GPUServiceClient:
|
|
"""Client for GPU service communication"""
|
|
|
|
def __init__(self):
|
|
self.base_url = f"http://{settings.gpu_service_host}:{settings.gpu_service_port}"
|
|
self.client = httpx.AsyncClient(timeout=30.0)
|
|
|
|
async def close(self):
|
|
"""Close the HTTP client"""
|
|
await self.client.aclose()
|
|
|
|
async def scan_gpus(self, miner_id: str) -> Dict[str, Any]:
|
|
"""Scan GPUs via GPU service"""
|
|
response = await self.client.post(f"{self.base_url}/v1/marketplace/edge-gpu/scan/{miner_id}")
|
|
response.raise_for_status()
|
|
return response.json()
|
|
|
|
async def get_gpu_profiles(self, architecture: str = None, edge_optimized: bool = None, min_memory_gb: int = None) -> List[Dict[str, Any]]:
|
|
"""Get GPU profiles via GPU service"""
|
|
params = {}
|
|
if architecture:
|
|
params["architecture"] = architecture
|
|
if edge_optimized is not None:
|
|
params["edge_optimized"] = edge_optimized
|
|
if min_memory_gb is not None:
|
|
params["min_memory_gb"] = min_memory_gb
|
|
|
|
response = await self.client.get(f"{self.base_url}/v1/marketplace/edge-gpu/profiles", params=params)
|
|
response.raise_for_status()
|
|
return response.json()
|
|
|
|
async def get_gpu_metrics(self, gpu_id: str, limit: int = 100) -> List[Dict[str, Any]]:
|
|
"""Get GPU metrics via GPU service"""
|
|
response = await self.client.get(f"{self.base_url}/v1/marketplace/edge-gpu/metrics/{gpu_id}", params={"limit": limit})
|
|
response.raise_for_status()
|
|
return response.json()
|
|
|
|
async def get_miner_gpus(self, miner_id: str) -> List[Dict[str, Any]]:
|
|
"""Get GPUs registered by a miner"""
|
|
response = await self.client.get(f"{self.base_url}/v1/miners/{miner_id}/gpus")
|
|
response.raise_for_status()
|
|
return response.json()
|