Spaces:
Running
Running
Parse validated progress reported by generation workers
Browse files
app/generation/providers/worker_client.py
CHANGED
|
@@ -473,16 +473,24 @@ class RemoteWorkerClient:
|
|
| 473 |
raw_output = payload.get("output")
|
| 474 |
try:
|
| 475 |
output = self._worker_output(raw_output) if isinstance(raw_output, dict) else None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 476 |
return WorkerJob(
|
| 477 |
external_job_id=job_id,
|
| 478 |
status=statuses[raw_status],
|
|
|
|
| 479 |
output=output,
|
| 480 |
error_category=self._worker_error_category(payload, statuses[raw_status]),
|
| 481 |
error_code=self._worker_error_code(payload),
|
| 482 |
error_message=None,
|
| 483 |
metadata=self._metadata(
|
| 484 |
payload,
|
| 485 |
-
known={"job_id", "external_job_id", "status", "output", "error"},
|
| 486 |
),
|
| 487 |
)
|
| 488 |
except (TypeError, ValueError) as exc:
|
|
|
|
| 473 |
raw_output = payload.get("output")
|
| 474 |
try:
|
| 475 |
output = self._worker_output(raw_output) if isinstance(raw_output, dict) else None
|
| 476 |
+
raw_progress = payload.get("progress_percent")
|
| 477 |
+
if raw_progress is not None and (
|
| 478 |
+
not isinstance(raw_progress, int)
|
| 479 |
+
or isinstance(raw_progress, bool)
|
| 480 |
+
or not 0 <= raw_progress <= 100
|
| 481 |
+
):
|
| 482 |
+
raise ValueError("worker progress_percent must be an integer from 0 to 100")
|
| 483 |
return WorkerJob(
|
| 484 |
external_job_id=job_id,
|
| 485 |
status=statuses[raw_status],
|
| 486 |
+
progress_percent=raw_progress,
|
| 487 |
output=output,
|
| 488 |
error_category=self._worker_error_category(payload, statuses[raw_status]),
|
| 489 |
error_code=self._worker_error_code(payload),
|
| 490 |
error_message=None,
|
| 491 |
metadata=self._metadata(
|
| 492 |
payload,
|
| 493 |
+
known={"job_id", "external_job_id", "status", "progress_percent", "output", "error"},
|
| 494 |
),
|
| 495 |
)
|
| 496 |
except (TypeError, ValueError) as exc:
|