Add ipfs_playlist_cid to pending_runs and fail-fast on DB errors
Some checks are pending
GPU Worker CI/CD / test (push) Waiting to run
GPU Worker CI/CD / deploy (push) Blocked by required conditions

- Add ipfs_playlist_cid column to pending_runs schema with migration
- Add pool guards to critical database functions (RuntimeError if not initialized)
- Add update_pending_run_playlist() function for streaming
- Update streaming task to save playlist CID to DB for HLS redirect
- Change database error handling from warning to raising exception

Errors should fail fast and explicitly, not be silently swallowed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-04 00:02:18 +00:00
parent bbcb79cc1e
commit ed5ef2bf39
2 changed files with 72 additions and 6 deletions

View File

@@ -353,6 +353,24 @@ def run_stream(
segment_cids = getattr(interp.output, 'segment_cids', {})
logger.info(f"IPFS HLS: playlist={ipfs_playlist_cid}, segments={len(segment_cids)}")
# Update pending run with playlist CID for live HLS redirect
if ipfs_playlist_cid:
global _resolve_loop, _db_initialized
import asyncio
import database
try:
if _resolve_loop is None or _resolve_loop.is_closed():
_resolve_loop = asyncio.new_event_loop()
asyncio.set_event_loop(_resolve_loop)
if not _db_initialized:
_resolve_loop.run_until_complete(database.init_db())
_db_initialized = True
_resolve_loop.run_until_complete(database.update_pending_run_playlist(run_id, ipfs_playlist_cid))
logger.info(f"Updated pending run {run_id} with IPFS playlist CID: {ipfs_playlist_cid}")
except Exception as e:
logger.error(f"Failed to update pending run with playlist CID: {e}")
raise # Fail fast - database errors should not be silently ignored
# HLS output creates stream.m3u8 and segment_*.ts files in stream_dir
hls_playlist = stream_dir / "stream.m3u8"
@@ -439,7 +457,8 @@ def run_stream(
))
logger.info(f"Saved run {run_id} to database with actor_id={actor_id}")
except Exception as db_err:
logger.warning(f"Failed to save run to database: {db_err}")
logger.error(f"Failed to save run to database: {db_err}")
raise RuntimeError(f"Database error saving run {run_id}: {db_err}") from db_err
return {
"status": "completed",