feat: switch marketplace to production mode with real GPU offer
Coordinator API: - Fix MarketplaceService.list_offers() to query DB instead of mock data - Remove duplicate mock /marketplace/offers endpoint from marketplace_offers.py - Handle status as string or enum in _to_offer_view() - Deploy updated domain model with GPU columns to container - Add GPU columns to marketplaceoffer table in production DB - Register RTX 4060 Ti 16GB (at1-localhost) as marketplace offer Marketplace Web: - Create .env.production (VITE_MARKETPLACE_DATA_MODE=live, API=/api) - Create vite.config.ts with base: '/marketplace/' - Rebuild and deploy to server
This commit is contained in:
@@ -63,43 +63,6 @@ async def sync_offers(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@router.get("/marketplace/offers", summary="List all marketplace offers")
|
|
||||||
async def list_offers() -> list[dict]:
|
|
||||||
"""List all marketplace offers"""
|
|
||||||
|
|
||||||
# Return simple mock data
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
"id": "mock-offer-1",
|
|
||||||
"provider_id": "miner_001",
|
|
||||||
"provider_name": "GPU Miner Alpha",
|
|
||||||
"capacity": 4,
|
|
||||||
"price": 0.50,
|
|
||||||
"gpu_model": "RTX 4090",
|
|
||||||
"gpu_memory_gb": 24,
|
|
||||||
"cuda_version": "12.0",
|
|
||||||
"supported_models": ["llama2-7b", "stable-diffusion-xl"],
|
|
||||||
"region": "us-west",
|
|
||||||
"status": "OPEN",
|
|
||||||
"created_at": "2025-12-28T10:00:00Z",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "mock-offer-2",
|
|
||||||
"provider_id": "miner_002",
|
|
||||||
"provider_name": "GPU Miner Beta",
|
|
||||||
"capacity": 2,
|
|
||||||
"price": 0.35,
|
|
||||||
"gpu_model": "RTX 3080",
|
|
||||||
"gpu_memory_gb": 16,
|
|
||||||
"cuda_version": "11.8",
|
|
||||||
"supported_models": ["llama2-13b", "gpt-j"],
|
|
||||||
"region": "us-east",
|
|
||||||
"status": "OPEN",
|
|
||||||
"created_at": "2025-12-28T09:30:00Z",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/marketplace/miner-offers", summary="List all miner offers", response_model=list[MarketplaceOfferView])
|
@router.get("/marketplace/miner-offers", summary="List all miner offers", response_model=list[MarketplaceOfferView])
|
||||||
async def list_miner_offers(session: SessionDep) -> list[MarketplaceOfferView]:
|
async def list_miner_offers(session: SessionDep) -> list[MarketplaceOfferView]:
|
||||||
"""List all offers created from miners"""
|
"""List all offers created from miners"""
|
||||||
|
|||||||
@@ -26,39 +26,19 @@ class MarketplaceService:
|
|||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
) -> list[MarketplaceOfferView]:
|
) -> list[MarketplaceOfferView]:
|
||||||
# Return simple mock data as dicts to avoid schema issues
|
stmt = select(MarketplaceOffer).order_by(MarketplaceOffer.created_at.desc())
|
||||||
return [
|
|
||||||
{
|
if status is not None:
|
||||||
"id": "mock-offer-1",
|
normalised = status.strip().lower()
|
||||||
"provider": "miner_001",
|
valid = {s.value for s in MarketplaceOffer.status.type.__class__.__mro__} # type: ignore[union-attr]
|
||||||
"provider_name": "GPU Miner Alpha",
|
# Simple validation – accept any non-empty string that matches a known value
|
||||||
"capacity": 4,
|
if normalised not in ("open", "reserved", "closed", "booked"):
|
||||||
"price": 0.50,
|
raise ValueError(f"invalid status: {status}")
|
||||||
"sla": "Standard SLA",
|
stmt = stmt.where(MarketplaceOffer.status == normalised)
|
||||||
"gpu_model": "RTX 4090",
|
|
||||||
"gpu_memory_gb": 24,
|
stmt = stmt.offset(offset).limit(limit)
|
||||||
"cuda_version": "12.0",
|
offers = self.session.exec(stmt).all()
|
||||||
"supported_models": ["llama2-7b", "stable-diffusion-xl"],
|
return [self._to_offer_view(o) for o in offers]
|
||||||
"region": "us-west",
|
|
||||||
"status": "OPEN",
|
|
||||||
"created_at": "2025-12-28T10:00:00Z",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "mock-offer-2",
|
|
||||||
"provider": "miner_002",
|
|
||||||
"provider_name": "GPU Miner Beta",
|
|
||||||
"capacity": 2,
|
|
||||||
"price": 0.35,
|
|
||||||
"sla": "Standard SLA",
|
|
||||||
"gpu_model": "RTX 3080",
|
|
||||||
"gpu_memory_gb": 16,
|
|
||||||
"cuda_version": "11.8",
|
|
||||||
"supported_models": ["llama2-13b", "gpt-j"],
|
|
||||||
"region": "us-east",
|
|
||||||
"status": "OPEN",
|
|
||||||
"created_at": "2025-12-28T09:30:00Z",
|
|
||||||
},
|
|
||||||
][:limit]
|
|
||||||
|
|
||||||
def get_stats(self) -> MarketplaceStatsView:
|
def get_stats(self) -> MarketplaceStatsView:
|
||||||
offers = self.session.exec(select(MarketplaceOffer)).all()
|
offers = self.session.exec(select(MarketplaceOffer)).all()
|
||||||
@@ -92,13 +72,14 @@ class MarketplaceService:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _to_offer_view(offer: MarketplaceOffer) -> MarketplaceOfferView:
|
def _to_offer_view(offer: MarketplaceOffer) -> MarketplaceOfferView:
|
||||||
|
status_val = offer.status.value if hasattr(offer.status, "value") else offer.status
|
||||||
return MarketplaceOfferView(
|
return MarketplaceOfferView(
|
||||||
id=offer.id,
|
id=offer.id,
|
||||||
provider=offer.provider,
|
provider=offer.provider,
|
||||||
capacity=offer.capacity,
|
capacity=offer.capacity,
|
||||||
price=offer.price,
|
price=offer.price,
|
||||||
sla=offer.sla,
|
sla=offer.sla,
|
||||||
status=offer.status.value,
|
status=status_val,
|
||||||
created_at=offer.created_at,
|
created_at=offer.created_at,
|
||||||
gpu_model=offer.gpu_model,
|
gpu_model=offer.gpu_model,
|
||||||
gpu_memory_gb=offer.gpu_memory_gb,
|
gpu_memory_gb=offer.gpu_memory_gb,
|
||||||
|
|||||||
Reference in New Issue
Block a user