From 3e831a2dc78f78b192fc20a0aa9c56e2af272570 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Fri, 1 May 2026 09:50:23 +0900 Subject: [PATCH] =?UTF-8?q?fix(canonical):=20Phase=201D=20script=20sys.pat?= =?UTF-8?q?h=20=E2=80=94=20/app/scripts/..=20=EA=B0=80=20PYTHONPATH=20?= =?UTF-8?q?=EB=A3=A8=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fastapi 컨테이너는 WORKDIR=/app, 코드가 직접 풀려있고 app/ 디렉토리 없음. backfill_category.py 의 ../app 패턴은 컨테이너 안에서 /app/app (없음) 가 되어 ModuleNotFoundError. 스크립트 자기 디렉토리의 .. 를 sys.path 에 넣어 /app 루트 노출. Co-Authored-By: Claude Opus 4.7 (1M context) --- scripts/phase1d_pilot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/phase1d_pilot.py b/scripts/phase1d_pilot.py index c476e1c..71d7612 100644 --- a/scripts/phase1d_pilot.py +++ b/scripts/phase1d_pilot.py @@ -29,7 +29,9 @@ import sys from collections import Counter, defaultdict from pathlib import Path -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "app")) +# fastapi 컨테이너는 WORKDIR=/app 에 코드를 펼쳐놓음 (app/ 디렉토리 없음). +# /app/scripts/../app 이 아니라 /app 자체가 sys.path 에 있어야 `from models...` import 가능. +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine