- signal_v2/config.py: Settings dataclass loading web-ai/.env explicitly - signal_v2/state.py: PollState dataclass + module-level singleton - requirements.txt: httpx / fastapi / uvicorn / pytest-asyncio / respx - .gitignore: signal_v2/data/*.db (WAL/SHM) - empty tests/ marker Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
29 lines
872 B
Python
29 lines
872 B
Python
"""Signal V2 환경변수 로딩."""
|
|
import os
|
|
from dataclasses import dataclass, field
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
# web-ai/.env 명시 로드 (signal_v2/config.py 의 parent.parent = web-ai/)
|
|
load_dotenv(Path(__file__).parent.parent / ".env")
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Settings:
|
|
stock_api_url: str = field(
|
|
default_factory=lambda: os.getenv("STOCK_API_URL", "").rstrip("/")
|
|
)
|
|
webai_api_key: str = field(
|
|
default_factory=lambda: os.getenv("WEBAI_API_KEY", "").strip()
|
|
)
|
|
port: int = field(default_factory=lambda: int(os.getenv("SIGNAL_V2_PORT", "8001")))
|
|
db_path: Path = field(
|
|
default_factory=lambda: Path(__file__).parent / "data" / "signal_v2.db"
|
|
)
|
|
|
|
|
|
def get_settings() -> Settings:
|
|
"""매 호출 시 신선한 Settings (테스트 monkeypatch 호환)."""
|
|
return Settings()
|