Fix import errors in handlers - use absolute imports instead of relative imports
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 13s
CLI Tests / test-cli (push) Failing after 2s
Security Scanning / security-scan (push) Has been cancelled
Integration Tests / test-service-integration (push) Successful in 2m57s
Python Tests / test-python (push) Successful in 11s

This commit is contained in:
aitbc
2026-04-28 18:21:48 +02:00
parent 31df4d538f
commit 36b1937fcb
3 changed files with 13 additions and 7 deletions

View File

@@ -299,7 +299,7 @@ async def sell_gpu(
session: Annotated[Session, Depends(get_session)],
) -> dict[str, Any]:
"""List GPU for sale on marketplace with specified price."""
gpu = _get_gpu_or_404(session, request.gpu_id)
gpu = _get_gpu_or_404(session, gpu_id)
# Update GPU listing
gpu.price_per_hour = request.listing_price
@@ -309,7 +309,7 @@ async def sell_gpu(
session.refresh(gpu)
return {
"gpu_id": request.gpu_id,
"gpu_id": gpu_id,
"seller_id": request.seller_id,
"listing_price": request.listing_price,
"status": "listed",

View File

@@ -286,8 +286,10 @@ def handle_market_gpu_list(args, default_coordinator_url, output_format):
def handle_market_buy(args, default_coordinator_url, read_password, render_mapping):
"""Handle marketplace buy command via coordinator API using dual-mode wallet adapter."""
from ..utils.dual_mode_wallet_adapter import DualModeWalletAdapter
from ..config import Config
import sys
sys.path.insert(0, "/opt/aitbc/cli")
from utils.dual_mode_wallet_adapter import DualModeWalletAdapter
from config import Config
coordinator_url = getattr(args, 'rpc_url', default_coordinator_url) or default_coordinator_url
@@ -314,14 +316,13 @@ def handle_market_buy(args, default_coordinator_url, read_password, render_mappi
# Submit purchase to coordinator API
purchase_data = {
"buyer_id": args.wallet,
"gpu_id": args.item,
"duration_hours": 1.0,
"payment_method": "blockchain"
}
print(f"Submitting purchase to {coordinator_url}...")
try:
response = requests.post(f"{coordinator_url}/v1/marketplace/gpu/purchase", json=purchase_data, timeout=30)
response = requests.post(f"{coordinator_url}/v1/marketplace/gpu/{args.item}/buy", json=purchase_data, timeout=30)
if response.status_code in (200, 201):
result = response.json()
print("Purchase submitted successfully")

View File

@@ -73,6 +73,11 @@ def handle_wallet_transactions(args, get_transactions, output_format, first):
def handle_wallet_send(args, send_transaction, read_password, first):
"""Handle wallet send command."""
import sys
sys.path.insert(0, "/opt/aitbc/cli")
from utils.dual_mode_wallet_adapter import DualModeWalletAdapter
from config import Config
from_wallet = first(getattr(args, "from_wallet_arg", None), getattr(args, "from_wallet", None))
to_address = first(getattr(args, "to_address_arg", None), getattr(args, "to_address", None))
amount_value = first(getattr(args, "amount_arg", None), getattr(args, "amount", None))
@@ -104,7 +109,7 @@ def handle_wallet_send(args, send_transaction, read_password, first):
if result.get('success'):
print("Transaction sent successfully")
render_mapping("Transaction:", result)
print(f"Transaction hash: {result.get('transaction_hash')}")
else:
print(f"Transaction failed: {result.get('error', 'Unknown error')}")
sys.exit(1)