Revert to using main session for job creation to debug persistence issue
All checks were successful
API Endpoint Tests / test-api-endpoints (push) Successful in 1m14s
Integration Tests / test-service-integration (push) Successful in 2m57s
Python Tests / test-python (push) Successful in 10s
Security Scanning / security-scan (push) Successful in 29s

This commit is contained in:
aitbc
2026-04-28 21:01:16 +02:00
parent 5a64f5ba24
commit 6b7702426b

View File

@@ -311,13 +311,9 @@ async def buy_gpu(
from ..schemas import JobCreate, JobPaymentCreate
from ..services.jobs import JobService
from ..services.payments import PaymentService
from sqlmodel import Session as SQLModelSession
# Create a new session for job creation to avoid rollback issues
job_session = SQLModelSession(bind=session.bind)
# Create AI job for GPU compute
job_service = JobService(job_session)
# Create AI job for GPU compute using the main session
job_service = JobService(session)
job_create = JobCreate(
payload={
"type": "gpu_compute",
@@ -337,14 +333,12 @@ async def buy_gpu(
)
job = job_service.create_job(client_id=request.buyer_id, req=job_create)
job_id = job.id
job_session.close()
logger.info(f"Created job {job.id} for GPU purchase {booking_id}")
# Create payment for the job (separate transaction)
try:
payment_session = SQLModelSession(bind=session.bind)
payment_service = PaymentService(payment_session)
payment_service = PaymentService(session)
payment_create = JobPaymentCreate(
job_id=job.id,
amount=total_cost,
@@ -355,7 +349,6 @@ async def buy_gpu(
payment = await payment_service.create_payment(job_id=job.id, payment_data=payment_create)
payment_id = payment.id
payment_status = payment.status
payment_session.close()
logger.info(f"Created payment {payment.id} for job {job.id}")
except Exception as e: