feat(stock-lab): /nodes + /settings 라우터 + main.py include

- screener/router.py: APIRouter prefix=/api/stock/screener
  - GET /nodes: NODE_REGISTRY + GATE_REGISTRY 메타 노출 (7 score + 1 gate)
  - GET /settings: screener_settings 싱글톤 row 조회
  - PUT /settings: 가중치/노드/게이트 파라미터 round-trip
- main.py: screener_router include (FastAPI 생성 직후)
- db.py: STOCK_DB_PATH 환경변수 지원 (테스트 격리, 기본값 /app/data/stock.db 유지)
- test_screener_router.py: 3 tests (nodes list, settings GET, PUT round-trip)
This commit is contained in:
2026-05-12 13:41:24 +09:00
parent 070f2de3f1
commit 5f0fed7f13
4 changed files with 159 additions and 3 deletions

View File

@@ -5,11 +5,14 @@ from typing import List, Dict, Any, Optional
from app.screener.schema import ensure_screener_schema
DB_PATH = "/app/data/stock.db"
DB_PATH = os.environ.get("STOCK_DB_PATH", "/app/data/stock.db")
def _conn() -> sqlite3.Connection:
os.makedirs(os.path.dirname(DB_PATH), exist_ok=True)
conn = sqlite3.connect(DB_PATH)
db_path = os.environ.get("STOCK_DB_PATH", DB_PATH)
parent = os.path.dirname(db_path)
if parent:
os.makedirs(parent, exist_ok=True)
conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row
return conn