From bc5ed74d4df33c5c192cbf7c10bdcaa760afade0 Mon Sep 17 00:00:00 2001 From: Harmon Date: Thu, 16 Apr 2026 23:16:47 +0800 Subject: [PATCH] Isolate ENVI temp files from repo root --- .gitignore | 1 + backend/app/services/job_handlers.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index fbfa594..24566e0 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ backend/result_products/ nginx/temp/ experiments/**/scratch/ backend/quality_model.pkl +/_par_win_*.xls # Large local datasets / installers Data/ diff --git a/backend/app/services/job_handlers.py b/backend/app/services/job_handlers.py index 535e508..1728cdf 100644 --- a/backend/app/services/job_handlers.py +++ b/backend/app/services/job_handlers.py @@ -873,6 +873,12 @@ def _get_envi_progress_file(job_id: str) -> str: return os.path.join(runtime_dir, f"job_{job_id}_progress.json") +def _get_envi_runtime_cwd() -> str: + runtime_dir = os.path.normpath(os.path.abspath(settings.IDL_WORKER_RUNTIME_DIR)) + os.makedirs(runtime_dir, exist_ok=True) + return runtime_dir + + # Stale threshold: no progress file update AND no output file activity # for this many seconds -> consider the subprocess dead. _ENVI_FILE_STALE_SECONDS = int(settings.ENVI_FILE_STALE_SECONDS) @@ -1057,7 +1063,7 @@ async def _run_envi_runner_command( runner_cmd, stdout=stdout_fd, stderr=stderr_fd, - cwd=type(settings).PROJECT_ROOT, + cwd=_get_envi_runtime_cwd(), ) proc_state["pid"] = proc.pid loop.call_soon_threadsafe(pid_ready.set) @@ -1296,7 +1302,7 @@ async def _run_envi_workflow_job( runner_cmd, stdout=stdout_fd, stderr=stderr_fd, - cwd=type(settings).PROJECT_ROOT, + cwd=_get_envi_runtime_cwd(), ) # Close our copy of the fds; the child process has its own. os.close(stdout_fd)