fix: add missing database commit and remove unused agent service files
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (push) Has been cancelled
AITBC CI/CD Pipeline / test-cli (push) Has been cancelled
AITBC CI/CD Pipeline / test-services (push) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (push) Has been cancelled
AITBC CI/CD Pipeline / security-scan (push) Has been cancelled
AITBC CI/CD Pipeline / build (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (push) Has been cancelled
AITBC CI/CD Pipeline / performance-test (push) Has been cancelled
AITBC CI/CD Pipeline / docs (push) Has been cancelled
AITBC CI/CD Pipeline / release (push) Has been cancelled
AITBC CI/CD Pipeline / notify (push) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (push) Has been cancelled
Security Scanning / Dependency Security Scan (push) Has been cancelled
Security Scanning / Container Security Scan (push) Has been cancelled
Security Scanning / OSSF Scorecard (push) Has been cancelled
Security Scanning / Security Summary Report (push) Has been cancelled
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (push) Has been cancelled
AITBC CI/CD Pipeline / test-cli (push) Has been cancelled
AITBC CI/CD Pipeline / test-services (push) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (push) Has been cancelled
AITBC CI/CD Pipeline / security-scan (push) Has been cancelled
AITBC CI/CD Pipeline / build (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (push) Has been cancelled
AITBC CI/CD Pipeline / performance-test (push) Has been cancelled
AITBC CI/CD Pipeline / docs (push) Has been cancelled
AITBC CI/CD Pipeline / release (push) Has been cancelled
AITBC CI/CD Pipeline / notify (push) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (push) Has been cancelled
Security Scanning / Dependency Security Scan (push) Has been cancelled
Security Scanning / Container Security Scan (push) Has been cancelled
Security Scanning / OSSF Scorecard (push) Has been cancelled
Security Scanning / Security Summary Report (push) Has been cancelled
- Add conn.commit() to agent registration in agent-registry - Remove unused integration_layer.py and coordinator.py from agent-services - Fix blockchain RPC endpoint from /rpc/sync to /rpc/syncStatus - Replace Annotated[Session, Depends(get_session)] with Session = Depends(get_session) for cleaner dependency injection syntax across marketplace routers
This commit is contained in:
@@ -85,6 +85,7 @@ async def register_agent(agent: AgentRegistration):
|
||||
json.dumps(agent.capabilities), agent.chain_id,
|
||||
agent.endpoint, json.dumps(agent.metadata)
|
||||
))
|
||||
conn.commit()
|
||||
|
||||
return Agent(
|
||||
id=agent_id,
|
||||
|
||||
@@ -78,7 +78,7 @@ class AITBCServiceIntegration:
|
||||
"""Register agent with coordinator"""
|
||||
try:
|
||||
async with self.session.post(
|
||||
f"{self.service_endpoints['coordinator_api']}/api/v1/agents/register",
|
||||
f"{self.service_endpoints['agent_registry']}/api/agents/register",
|
||||
json=agent_data
|
||||
) as response:
|
||||
return await response.json()
|
||||
@@ -98,13 +98,15 @@ class AgentServiceBridge:
|
||||
# Register agent with coordinator
|
||||
async with self.integration as integration:
|
||||
registration_result = await integration.register_agent_with_coordinator({
|
||||
"agent_id": agent_id,
|
||||
"agent_type": agent_config.get("type", "generic"),
|
||||
"name": agent_id,
|
||||
"type": agent_config.get("type", "generic"),
|
||||
"capabilities": agent_config.get("capabilities", []),
|
||||
"chain_id": agent_config.get("chain_id", "ait-mainnet"),
|
||||
"endpoint": agent_config.get("endpoint", f"http://localhost:{8000 + len(self.active_agents) + 10}")
|
||||
})
|
||||
|
||||
if registration_result.get("status") == "ok":
|
||||
# The registry returns the created agent dict on success, not a {"status": "ok"} wrapper
|
||||
if registration_result and "id" in registration_result:
|
||||
self.active_agents[agent_id] = {
|
||||
"config": agent_config,
|
||||
"registration": registration_result,
|
||||
@@ -112,6 +114,7 @@ class AgentServiceBridge:
|
||||
}
|
||||
return True
|
||||
else:
|
||||
print(f"Registration failed: {registration_result}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"Failed to start agent {agent_id}: {e}")
|
||||
@@ -48,7 +48,7 @@ async def blockchain_sync_status():
|
||||
|
||||
rpc_url = settings.blockchain_rpc_url.rstrip('/')
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.get(f"{rpc_url}/rpc/sync", timeout=5.0)
|
||||
response = await client.get(f"{rpc_url}/rpc/syncStatus", timeout=5.0)
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
return {
|
||||
|
||||
@@ -20,7 +20,7 @@ limiter = Limiter(key_func=get_remote_address)
|
||||
router = APIRouter(tags=["marketplace"])
|
||||
|
||||
|
||||
def _get_service(session: Annotated[Session, Depends(get_session)]) -> MarketplaceService:
|
||||
def _get_service(session: Session = Depends(get_session)) -> MarketplaceService:
|
||||
return MarketplaceService(session)
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ def _get_service(session: Annotated[Session, Depends(get_session)]) -> Marketpla
|
||||
async def list_marketplace_offers(
|
||||
request: Request,
|
||||
*,
|
||||
session: Annotated[Session, Depends(get_session)],
|
||||
session: Session = Depends(get_session),
|
||||
status_filter: str | None = Query(default=None, alias="status", description="Filter by offer status"),
|
||||
limit: int = Query(default=100, ge=1, le=500),
|
||||
offset: int = Query(default=0, ge=0),
|
||||
@@ -60,7 +60,7 @@ async def list_marketplace_offers(
|
||||
async def get_marketplace_stats(
|
||||
request: Request,
|
||||
*,
|
||||
session: Annotated[Session, Depends(get_session)]
|
||||
session: Session = Depends(get_session)
|
||||
) -> MarketplaceStatsView:
|
||||
marketplace_requests_total.labels(endpoint="/marketplace/stats", method="GET").inc()
|
||||
service = _get_service(session)
|
||||
@@ -80,7 +80,7 @@ async def get_marketplace_stats(
|
||||
async def submit_marketplace_bid(
|
||||
request: Request,
|
||||
payload: MarketplaceBidRequest,
|
||||
session: Annotated[Session, Depends(get_session)],
|
||||
session: Session = Depends(get_session),
|
||||
) -> dict[str, str]:
|
||||
marketplace_requests_total.labels(endpoint="/marketplace/bids", method="POST").inc()
|
||||
service = _get_service(session)
|
||||
@@ -102,7 +102,7 @@ async def submit_marketplace_bid(
|
||||
)
|
||||
async def list_marketplace_bids(
|
||||
*,
|
||||
session: Annotated[Session, Depends(get_session)],
|
||||
session: Session = Depends(get_session),
|
||||
status_filter: str | None = Query(default=None, alias="status", description="Filter by bid status"),
|
||||
provider_filter: str | None = Query(default=None, alias="provider", description="Filter by provider ID"),
|
||||
limit: int = Query(default=100, ge=1, le=500),
|
||||
@@ -127,7 +127,7 @@ async def list_marketplace_bids(
|
||||
)
|
||||
async def get_marketplace_bid(
|
||||
bid_id: str,
|
||||
session: Annotated[Session, Depends(get_session)],
|
||||
session: Session = Depends(get_session),
|
||||
) -> MarketplaceBidView:
|
||||
marketplace_requests_total.labels(endpoint="/marketplace/bids/{bid_id}", method="GET").inc()
|
||||
service = _get_service(session)
|
||||
|
||||
@@ -50,7 +50,7 @@ class MarketplaceAnalyticsRequest(BaseModel):
|
||||
async def create_royalty_distribution(
|
||||
request: RoyaltyDistributionRequest,
|
||||
offer_id: str,
|
||||
session: Session = Depends(Annotated[Session, Depends(get_session)]),
|
||||
session: Session = Depends(get_session),
|
||||
current_user: str = Depends(require_admin_key())
|
||||
):
|
||||
"""Create royalty distribution for marketplace offer"""
|
||||
@@ -74,7 +74,7 @@ async def create_royalty_distribution(
|
||||
async def calculate_royalties(
|
||||
offer_id: str,
|
||||
sale_amount: float,
|
||||
session: Session = Depends(Annotated[Session, Depends(get_session)]),
|
||||
session: Session = Depends(get_session),
|
||||
current_user: str = Depends(require_admin_key())
|
||||
):
|
||||
"""Calculate royalties for a sale"""
|
||||
@@ -97,7 +97,7 @@ async def calculate_royalties(
|
||||
async def create_model_license(
|
||||
request: ModelLicenseRequest,
|
||||
offer_id: str,
|
||||
session: Session = Depends(Annotated[Session, Depends(get_session)]),
|
||||
session: Session = Depends(get_session),
|
||||
current_user: str = Depends(require_admin_key())
|
||||
):
|
||||
"""Create model license for marketplace offer"""
|
||||
@@ -123,7 +123,7 @@ async def create_model_license(
|
||||
async def verify_model(
|
||||
request: ModelVerificationRequest,
|
||||
offer_id: str,
|
||||
session: Session = Depends(Annotated[Session, Depends(get_session)]),
|
||||
session: Session = Depends(get_session),
|
||||
current_user: str = Depends(require_admin_key())
|
||||
):
|
||||
"""Verify model quality and performance"""
|
||||
@@ -145,7 +145,7 @@ async def verify_model(
|
||||
@router.post("/analytics")
|
||||
async def get_marketplace_analytics(
|
||||
request: MarketplaceAnalyticsRequest,
|
||||
session: Session = Depends(Annotated[Session, Depends(get_session)]),
|
||||
session: Session = Depends(get_session),
|
||||
current_user: str = Depends(require_admin_key())
|
||||
):
|
||||
"""Get marketplace analytics and insights"""
|
||||
|
||||
@@ -6,7 +6,7 @@ Basic marketplace enhancement features compatible with existing domain models
|
||||
import asyncio
|
||||
from aitbc.logging import get_logger
|
||||
from typing import Dict, List, Optional, Any
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from uuid import uuid4
|
||||
from enum import Enum
|
||||
|
||||
@@ -225,12 +225,12 @@ class EnhancedMarketplaceService:
|
||||
offers_query = select(MarketplaceOffer).where(
|
||||
MarketplaceOffer.created_at >= start_date
|
||||
)
|
||||
offers = self.session.execute(offers_query).all()
|
||||
offers = self.session.execute(offers_query).scalars().all()
|
||||
|
||||
bids_query = select(MarketplaceBid).where(
|
||||
MarketplaceBid.created_at >= start_date
|
||||
MarketplaceBid.submitted_at >= start_date
|
||||
)
|
||||
bids = self.session.execute(bids_query).all()
|
||||
bids = self.session.execute(bids_query).scalars().all()
|
||||
|
||||
# Calculate analytics
|
||||
analytics = {
|
||||
@@ -264,7 +264,7 @@ class EnhancedMarketplaceService:
|
||||
|
||||
if "revenue" in metrics:
|
||||
analytics["metrics"]["revenue"] = {
|
||||
"total_revenue": sum(bid.amount or 0 for bid in bids),
|
||||
"total_revenue": sum(bid.price or 0 for bid in bids),
|
||||
"average_price": sum(offer.price or 0 for offer in offers) / len(offers) if offers else 0,
|
||||
"revenue_growth": 0.12
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user