Spaces:
Running
Running
Sync from GitHub (tests passed)
Browse files- worker/tasks.py +18 -14
worker/tasks.py
CHANGED
|
@@ -487,21 +487,25 @@ async def _execute_pipeline_stages_v2(
|
|
| 487 |
session.rollback()
|
| 488 |
|
| 489 |
# -------------------------------------------------------------------------
|
| 490 |
-
# Stage 6: Generate commentary
|
| 491 |
# -------------------------------------------------------------------------
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 505 |
result["commentary_generated"] = False
|
| 506 |
|
| 507 |
return result
|
|
|
|
| 487 |
session.rollback()
|
| 488 |
|
| 489 |
# -------------------------------------------------------------------------
|
| 490 |
+
# Stage 6: Generate commentary (only if snapshot was generated)
|
| 491 |
# -------------------------------------------------------------------------
|
| 492 |
+
if result.get("snapshot_generated"):
|
| 493 |
+
logger.info(f"[run_id={run_id}] Stage 6: Generate commentary")
|
| 494 |
+
try:
|
| 495 |
+
from app.commentary import generate_and_save_commentary
|
| 496 |
+
|
| 497 |
+
generate_and_save_commentary(session, "HG=F")
|
| 498 |
+
session.commit()
|
| 499 |
+
|
| 500 |
+
result["commentary_generated"] = True
|
| 501 |
+
update_run_metrics(session, run_id, commentary_generated=True)
|
| 502 |
+
session.commit()
|
| 503 |
+
|
| 504 |
+
except Exception as e:
|
| 505 |
+
logger.warning(f"[run_id={run_id}] Stage 6 failed: {e}")
|
| 506 |
+
result["commentary_generated"] = False
|
| 507 |
+
else:
|
| 508 |
+
logger.warning(f"[run_id={run_id}] Stage 6 skipped: no snapshot generated")
|
| 509 |
result["commentary_generated"] = False
|
| 510 |
|
| 511 |
return result
|