KSvend Claude Happy commited on
Commit ·
a20be0b
1
Parent(s): 6844e35
chore: add batch job debug logging to worker
Browse filesTemporary: logs batch job errors and surfaces harvest failures in
result limitations field for remote debugging.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
- app/worker.py +16 -1
app/worker.py
CHANGED
|
@@ -98,6 +98,14 @@ async def process_job(job_id: str, db: Database, registry: IndicatorRegistry) ->
|
|
| 98 |
del pending[indicator_id]
|
| 99 |
elif any(s in ("error", "canceled") for s in statuses):
|
| 100 |
logger.warning("Batch job failed for %s: %s", indicator_id, statuses)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
del pending[indicator_id]
|
| 102 |
|
| 103 |
if not pending:
|
|
@@ -124,12 +132,18 @@ async def process_job(job_id: str, db: Database, registry: IndicatorRegistry) ->
|
|
| 124 |
)
|
| 125 |
elif indicator_id in batch_submissions:
|
| 126 |
await db.update_job_progress(job_id, indicator_id, "downloading")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
try:
|
| 128 |
result = await indicator.harvest(
|
| 129 |
job.request.aoi,
|
| 130 |
job.request.time_range,
|
| 131 |
season_months=job.request.season_months(),
|
| 132 |
-
batch_jobs=
|
| 133 |
)
|
| 134 |
except Exception as exc:
|
| 135 |
logger.warning("Harvest failed for %s, using fallback: %s", indicator_id, exc)
|
|
@@ -138,6 +152,7 @@ async def process_job(job_id: str, db: Database, registry: IndicatorRegistry) ->
|
|
| 138 |
job.request.time_range,
|
| 139 |
season_months=job.request.season_months(),
|
| 140 |
)
|
|
|
|
| 141 |
else:
|
| 142 |
await db.update_job_progress(job_id, indicator_id, "processing")
|
| 143 |
result = await indicator.process(
|
|
|
|
| 98 |
del pending[indicator_id]
|
| 99 |
elif any(s in ("error", "canceled") for s in statuses):
|
| 100 |
logger.warning("Batch job failed for %s: %s", indicator_id, statuses)
|
| 101 |
+
# Log batch job errors for debugging
|
| 102 |
+
for j in jobs:
|
| 103 |
+
if j.status() == "error":
|
| 104 |
+
try:
|
| 105 |
+
logs = j.logs()
|
| 106 |
+
logger.warning("Batch job %s logs: %s", j.job_id, logs)
|
| 107 |
+
except Exception:
|
| 108 |
+
pass
|
| 109 |
del pending[indicator_id]
|
| 110 |
|
| 111 |
if not pending:
|
|
|
|
| 132 |
)
|
| 133 |
elif indicator_id in batch_submissions:
|
| 134 |
await db.update_job_progress(job_id, indicator_id, "downloading")
|
| 135 |
+
batch_jobs = batch_submissions[indicator_id]
|
| 136 |
+
batch_statuses = [j.status() for j in batch_jobs]
|
| 137 |
+
await db.update_job_progress(
|
| 138 |
+
job_id, indicator_id,
|
| 139 |
+
f"downloading (batch statuses: {batch_statuses})",
|
| 140 |
+
)
|
| 141 |
try:
|
| 142 |
result = await indicator.harvest(
|
| 143 |
job.request.aoi,
|
| 144 |
job.request.time_range,
|
| 145 |
season_months=job.request.season_months(),
|
| 146 |
+
batch_jobs=batch_jobs,
|
| 147 |
)
|
| 148 |
except Exception as exc:
|
| 149 |
logger.warning("Harvest failed for %s, using fallback: %s", indicator_id, exc)
|
|
|
|
| 152 |
job.request.time_range,
|
| 153 |
season_months=job.request.season_months(),
|
| 154 |
)
|
| 155 |
+
result.limitations.append(f"Debug: harvest failed: {type(exc).__name__}: {exc}")
|
| 156 |
else:
|
| 157 |
await db.update_job_progress(job_id, indicator_id, "processing")
|
| 158 |
result = await indicator.process(
|