move to postgresql
This commit is contained in:
@@ -24,13 +24,14 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _has_db() -> bool:
|
||||
"""Check if the DB layer is available (Django + models generated by modelgen)."""
|
||||
"""Check if Postgres is reachable."""
|
||||
try:
|
||||
from core.db.detect import get_stage_checkpoint as _
|
||||
# Quick check that the model exists (modelgen may not have run yet)
|
||||
from admin.mpr.media_assets.models import StageCheckpoint as _
|
||||
from core.db.connection import get_session
|
||||
from sqlmodel import text
|
||||
with get_session() as session:
|
||||
session.exec(text("SELECT 1"))
|
||||
return True
|
||||
except (ImportError, Exception):
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
@@ -69,17 +70,13 @@ def save_checkpoint(
|
||||
|
||||
|
||||
def _save_to_db(job_id: str, stage: str, stage_index: int, data: dict) -> str:
|
||||
"""Save checkpoint structured data to Postgres via core/db."""
|
||||
import uuid
|
||||
"""Save checkpoint structured data to Postgres."""
|
||||
from core.db.detect import save_stage_checkpoint
|
||||
|
||||
job_uuid = uuid.UUID(job_id) if isinstance(job_id, str) else job_id
|
||||
checkpoint_id = uuid.uuid4()
|
||||
frames_prefix = f"{CHECKPOINT_PREFIX}/{job_id}/frames/"
|
||||
|
||||
checkpoint = save_stage_checkpoint(
|
||||
id=checkpoint_id,
|
||||
job_id=job_uuid,
|
||||
job_id=job_id,
|
||||
stage=stage,
|
||||
stage_index=stage_index,
|
||||
frames_prefix=frames_prefix,
|
||||
|
||||
Reference in New Issue
Block a user