fix: auto-populate all CFG paths from environment variables
CFG.forge_dir, precon_dir, forge_decks_dir, forge_jar, and lab_jar were only set via CLI args. When the server starts via uvicorn directly (no CLI), all paths stayed empty and forge_card_loader could not find the cardsfolder, causing 0 lands in every deck. Fix: read FORGE_DIR, FORGE_JAR, PRECON_DIR, PRECON_DECKS_DIR, FORGE_DECKS_DIR, and LAB_JAR from environment at import time, mirroring the existing ANTHROPIC_API_KEY / XIMILAR_API_KEY pattern.
This commit is contained in:
1 parent
1fc99a5d4a
commit
d6863b6d7e
1 file changed
+11
-3
+11
-3
@@ -30,8 +30,18 @@ class Config:
|
||||
|
||||
|
||||
CFG = Config()
|
||||
# Pre-populate from env so ASGI mode (uvicorn lab_api:app) works without main()
|
||||
|
||||
# Pre-populate from environment so uvicorn/ASGI mode works without CLI args.
|
||||
# CLI args (lab_api.py main()) will override these if provided.
|
||||
CFG.anthropic_api_key = os.environ.get("ANTHROPIC_API_KEY", "")
|
||||
CFG.ximilar_api_key = os.environ.get("XIMILAR_API_KEY", "")
|
||||
CFG.pplx_api_key = os.environ.get("PPLX_API_KEY", "")
|
||||
CFG.forge_jar = os.environ.get("FORGE_JAR", "")
|
||||
CFG.forge_dir = os.environ.get("FORGE_DIR", "")
|
||||
CFG.lab_jar = os.environ.get("LAB_JAR", "")
|
||||
# PRECON_DIR / PRECON_DECKS_DIR are aliases -- prefer PRECON_DIR
|
||||
CFG.precon_dir = os.environ.get("PRECON_DIR") or os.environ.get("PRECON_DECKS_DIR", "")
|
||||
CFG.forge_decks_dir = os.environ.get("FORGE_DECKS_DIR", "")
|
||||
|
||||
|
||||
def validate_forge_config() -> None:
|
||||
@@ -53,8 +63,6 @@ def validate_forge_config() -> None:
|
||||
else:
|
||||
resolved = a if a.is_dir() else b
|
||||
log.info("Forge cardsfolder confirmed at %s", resolved)
|
||||
CFG.ximilar_api_key = os.environ.get("XIMILAR_API_KEY", "")
|
||||
CFG.pplx_api_key = os.environ.get("PPLX_API_KEY", "")
|
||||
|
||||
|
||||
# ══════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in new issue
Block a user