feat(01-01): add Pydantic Settings class to config.py and update requirements.txt
- Add Settings(BaseSettings) class reading DATABASE_URL, DATABASE_MIGRATE_URL, MINIO_ENDPOINT, MINIO_ACCESS_KEY, MINIO_SECRET_KEY, MINIO_BUCKET, REDIS_URL, SECRET_KEY from environment via SettingsConfigDict (pydantic-settings v2 API) - Instantiate settings = Settings() at module level for all callers - Preserve legacy DATA_DIR, UPLOADS_DIR, METADATA_DIR, TOPICS_FILE, SETTINGS_FILE, DEFAULT_SYSTEM_PROMPT, DEFAULT_SETTINGS, ensure_data_dirs() for Wave 4 compat - Remove filelock>=3.14 (replaced by PostgreSQL transactions per STORE-07) - Add sqlalchemy[asyncio]>=2.0.49, psycopg[binary]>=3.3.4, alembic>=1.18.4, minio>=7.2.20, celery[redis]>=5.6.3, redis>=7.4.0, aiosqlite>=0.20.0 - Bump pytest-asyncio to >=1.3.0 for asyncio_mode auto support
This commit is contained in:
@@ -2,6 +2,47 @@ import json
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
|
||||||
|
class Settings(BaseSettings):
|
||||||
|
"""Phase 1 Pydantic Settings — reads all Phase 1 env vars from environment or .env file."""
|
||||||
|
|
||||||
|
model_config = SettingsConfigDict(
|
||||||
|
env_file=".env",
|
||||||
|
env_file_encoding="utf-8",
|
||||||
|
extra="ignore",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Data directory (legacy flat-file path — kept until Plan 05 removes it)
|
||||||
|
data_dir: str = "/app/data"
|
||||||
|
|
||||||
|
# PostgreSQL
|
||||||
|
database_url: str = "postgresql+psycopg://docuvault_app:changeme_app@postgres:5432/docuvault"
|
||||||
|
database_migrate_url: str = "postgresql+psycopg://docuvault_migrate:changeme_migrate@postgres:5432/docuvault"
|
||||||
|
|
||||||
|
# MinIO
|
||||||
|
minio_endpoint: str = "minio:9000"
|
||||||
|
minio_access_key: str = "docuvault_app"
|
||||||
|
minio_secret_key: str = "changeme_minio_app"
|
||||||
|
minio_bucket: str = "docuvault"
|
||||||
|
|
||||||
|
# Redis / Celery
|
||||||
|
redis_url: str = "redis://:changeme_redis@redis:6379/0"
|
||||||
|
|
||||||
|
# Security (Phase 2 — documented now, not read by Phase 1 code paths)
|
||||||
|
secret_key: str = "CHANGEME"
|
||||||
|
|
||||||
|
|
||||||
|
settings = Settings()
|
||||||
|
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
|
# Legacy flat-file constants — kept for backward compatibility through Wave 4.
|
||||||
|
# These are consumed by services/storage.py, services/classifier.py, and
|
||||||
|
# api/settings.py until Plan 05 rewrites those modules.
|
||||||
|
# DO NOT DELETE until Plan 05 completes the storage service cutover.
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
DATA_DIR = Path(os.environ.get("DATA_DIR", "/app/data"))
|
DATA_DIR = Path(os.environ.get("DATA_DIR", "/app/data"))
|
||||||
UPLOADS_DIR = DATA_DIR / "uploads"
|
UPLOADS_DIR = DATA_DIR / "uploads"
|
||||||
METADATA_DIR = DATA_DIR / "metadata"
|
METADATA_DIR = DATA_DIR / "metadata"
|
||||||
|
|||||||
@@ -8,8 +8,14 @@ PyMuPDF>=1.24
|
|||||||
python-docx>=1.1
|
python-docx>=1.1
|
||||||
pytesseract>=0.3
|
pytesseract>=0.3
|
||||||
Pillow>=10.3
|
Pillow>=10.3
|
||||||
filelock>=3.14
|
|
||||||
aiofiles>=23.2
|
aiofiles>=23.2
|
||||||
httpx>=0.27
|
httpx>=0.27
|
||||||
pytest>=8.2
|
pytest>=8.2
|
||||||
pytest-asyncio>=0.23
|
pytest-asyncio>=1.3.0
|
||||||
|
sqlalchemy[asyncio]>=2.0.49
|
||||||
|
psycopg[binary]>=3.3.4
|
||||||
|
alembic>=1.18.4
|
||||||
|
minio>=7.2.20
|
||||||
|
celery[redis]>=5.6.3
|
||||||
|
redis>=7.4.0
|
||||||
|
aiosqlite>=0.20.0
|
||||||
|
|||||||
Reference in New Issue
Block a user