- Add pyproject.toml as single source of truth for version and metadata - Update config.py to read version from pyproject.toml using tomllib - FastAPI app now loads title and version dynamically from config - Health endpoint now includes version in response - Dockerfile updated to include pyproject.toml 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+22
-2
@@ -2,17 +2,37 @@
|
||||
Configuration management for The Scheduler.
|
||||
Uses Pydantic BaseSettings for type-safe environment variable loading.
|
||||
"""
|
||||
import tomllib
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
from pydantic_settings import BaseSettings
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
def _get_version_from_pyproject() -> tuple[str, str, str]:
|
||||
"""Read version info from pyproject.toml."""
|
||||
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
|
||||
if pyproject_path.exists():
|
||||
with open(pyproject_path, "rb") as f:
|
||||
data = tomllib.load(f)
|
||||
project = data.get("project", {})
|
||||
return (
|
||||
project.get("name", "the-scheduler"),
|
||||
project.get("version", "0.0.0"),
|
||||
project.get("description", ""),
|
||||
)
|
||||
return ("the-scheduler", "0.0.0", "")
|
||||
|
||||
|
||||
_PROJECT_NAME, _PROJECT_VERSION, _PROJECT_DESCRIPTION = _get_version_from_pyproject()
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings loaded from environment variables."""
|
||||
|
||||
# Application
|
||||
app_name: str = Field(default="The Scheduler", alias="APP_NAME")
|
||||
app_version: str = Field(default="1.0.0", alias="APP_VERSION")
|
||||
app_name: str = Field(default=_PROJECT_NAME, alias="APP_NAME")
|
||||
app_version: str = Field(default=_PROJECT_VERSION, alias="APP_VERSION")
|
||||
debug: bool = Field(default=False, alias="DEBUG")
|
||||
host: str = Field(default="0.0.0.0", alias="HOST")
|
||||
port: int = Field(default=8090, alias="PORT")
|
||||
|
||||
+4
-2
@@ -102,9 +102,10 @@ async def lifespan(app: FastAPI):
|
||||
|
||||
|
||||
# FastAPI app
|
||||
settings = get_settings()
|
||||
app = FastAPI(
|
||||
title="The Scheduler",
|
||||
version="1.0.0",
|
||||
title=settings.app_name,
|
||||
version=settings.app_version,
|
||||
description="System-wide maintenance orchestration - backups, doc mirroring, cleanup, task automation",
|
||||
lifespan=lifespan
|
||||
)
|
||||
@@ -134,6 +135,7 @@ async def health(
|
||||
"""Health check endpoint."""
|
||||
return {
|
||||
"status": "healthy",
|
||||
"version": settings.app_version,
|
||||
"scheduler_running": sched.running,
|
||||
"jobs_count": len(sched.get_jobs()),
|
||||
"database": settings.postgres_db
|
||||
|
||||
Reference in New Issue
Block a user