feat: organizer Android app and token-gated upload API
CI / lint-and-test (push) Failing after 1m18s
CI / lint-and-test (push) Failing after 1m18s
Replace Syncthing as the product upload path with a share-target app and POST /api/jobs. Web UI live-polls job progress. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+33
-4
@@ -396,6 +396,8 @@ def read_status(job_id: str) -> dict[str, Any] | None:
|
||||
return None
|
||||
return {
|
||||
"status": data.get("status", "unknown"),
|
||||
"stage": data.get("stage"),
|
||||
"progress": data.get("progress"),
|
||||
"created_at": data.get("created_at"),
|
||||
"updated_at": data.get("updated_at"),
|
||||
"error": data.get("error"),
|
||||
@@ -628,7 +630,15 @@ def process_job(
|
||||
paths.intermediates.mkdir(parents=True, exist_ok=True)
|
||||
paths.meta.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
write_status(paths, "processing", source_file=str(source_path.name), source_stem=stem)
|
||||
write_status(
|
||||
paths,
|
||||
"processing",
|
||||
source_file=str(source_path.name),
|
||||
source_stem=stem,
|
||||
stage="preprocess",
|
||||
progress={"current": 0, "total": config.OUTPUT_COUNT},
|
||||
error=None,
|
||||
)
|
||||
|
||||
try:
|
||||
paths = preprocess_original(paths)
|
||||
@@ -643,6 +653,12 @@ def process_job(
|
||||
}
|
||||
write_manifest(paths, manifest)
|
||||
|
||||
write_status(
|
||||
paths,
|
||||
"processing",
|
||||
stage="rembg",
|
||||
progress={"current": 0, "total": config.OUTPUT_COUNT},
|
||||
)
|
||||
ok, err = run_rembg(paths.original, paths.rembg)
|
||||
if not ok:
|
||||
raise PipelineError(f"rembg fehlgeschlagen: {err}")
|
||||
@@ -654,6 +670,12 @@ def process_job(
|
||||
|
||||
for i in range(1, config.OUTPUT_COUNT + 1):
|
||||
variant_id = f"v{i}"
|
||||
write_status(
|
||||
paths,
|
||||
"processing",
|
||||
stage="variant",
|
||||
progress={"current": i, "total": config.OUTPUT_COUNT},
|
||||
)
|
||||
try:
|
||||
entry = compose_variant(
|
||||
paths,
|
||||
@@ -700,10 +722,17 @@ def process_job(
|
||||
if not manifest["variants"]:
|
||||
raise PipelineError("Keine Variante erfolgreich erzeugt: " + "; ".join(variant_errors))
|
||||
|
||||
write_status(paths, "done", variant_errors=variant_errors)
|
||||
done_count = len(manifest["variants"])
|
||||
write_status(
|
||||
paths,
|
||||
"done",
|
||||
stage="done",
|
||||
progress={"current": done_count, "total": config.OUTPUT_COUNT},
|
||||
variant_errors=variant_errors,
|
||||
)
|
||||
except PipelineError as exc:
|
||||
logger.error("[%s] job failed: %s", stem, exc)
|
||||
write_status(paths, "error", error=str(exc))
|
||||
write_status(paths, "error", stage="error", error=str(exc))
|
||||
except Exception as exc: # noqa: BLE001 - keep the worker loop alive
|
||||
logger.exception("[%s] unexpected error", stem)
|
||||
write_status(paths, "error", error=f"Unerwarteter Fehler: {exc}")
|
||||
write_status(paths, "error", stage="error", error=f"Unerwarteter Fehler: {exc}")
|
||||
|
||||
Reference in New Issue
Block a user