From b064e18aa1e476777de0c21808da0cbd28c7860c Mon Sep 17 00:00:00 2001 From: Deeman Date: Thu, 5 Mar 2026 14:39:30 +0100 Subject: [PATCH] fix(admin): resolve workflows.toml path via CWD instead of __file__ In prod the package is installed in a venv, so __file__.parents[4] doesn't reach the repo root. Use CWD (repo root in both dev and prod via systemd WorkingDirectory) with REPO_ROOT env var override. Co-Authored-By: Claude Opus 4.6 --- web/src/padelnomics/admin/pipeline_routes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/src/padelnomics/admin/pipeline_routes.py b/web/src/padelnomics/admin/pipeline_routes.py index 2cee34e..cd687ea 100644 --- a/web/src/padelnomics/admin/pipeline_routes.py +++ b/web/src/padelnomics/admin/pipeline_routes.py @@ -51,8 +51,10 @@ bp = Blueprint( _LANDING_DIR = os.environ.get("LANDING_DIR", "data/landing") _SERVING_DUCKDB_PATH = os.environ.get("SERVING_DUCKDB_PATH", "data/analytics.duckdb") -# Repo root: web/src/padelnomics/admin/ → up 4 levels -_REPO_ROOT = Path(__file__).resolve().parents[4] +# In prod the package is installed in a venv so __file__.parents[4] won't +# reach the repo checkout. WorkingDirectory in the systemd unit is /opt/padelnomics, +# so CWD is reliable; REPO_ROOT env var overrides for non-standard setups. +_REPO_ROOT = Path(os.environ.get("REPO_ROOT", ".")).resolve() _WORKFLOWS_TOML = _REPO_ROOT / "infra" / "supervisor" / "workflows.toml" # A "running" row older than this is considered stale/crashed.