fix: spawn main.py with sys.executable, not bare "python"

The job runner built its command as ["python", "-u", "main.py"], which
resolves against PATH. Inside the Docker image there is exactly one
interpreter so it works, but in the documented non-Docker install --
a venv -- PATH points at whatever Python came first, not the one running
the server. Every job then dies immediately:

    ModuleNotFoundError: No module named 'cv2'

The CLI works fine in the same checkout, so it presents as "the dashboard
is broken" rather than anything to do with interpreters.

_run_quality_probe five hundred lines up already uses sys.executable for
exactly this reason; this makes the two agree.

Verified: same job, same venv, failed before and completed after.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QiYkHKB7Tp7X6NdnEutda2
This commit is contained in:
Chaakh 2026-08-23 10:26:10 +02:00
parent 88a53b6f7e
commit 362fe661f9

6
app.py
View file

@ -1670,7 +1670,11 @@ async def process_endpoint(
os.makedirs(job_output_dir, exist_ok=True) os.makedirs(job_output_dir, exist_ok=True)
# Prepare Command # Prepare Command
cmd = ["python", "-u", "main.py"] # -u for unbuffered # sys.executable, not "python": bare "python" resolves against PATH, which
# outside Docker is whatever interpreter happens to be first — not the venv
# running this server. Every job then dies on `import cv2`. The quality
# probe above already gets this right.
cmd = [sys.executable, "-u", "main.py"] # -u for unbuffered
env = os.environ.copy() env = os.environ.copy()
env["GEMINI_API_KEY"] = api_key # Override with key from request env["GEMINI_API_KEY"] = api_key # Override with key from request