chore: pydantic-settings config, logging, CI workflow

Config (src/config.py):
- pydantic-settings Settings class: OLLAMA_URL, OLLAMA_MODEL, DEBUG
- Reads from .env (gitignored) with sane defaults
- settings singleton imported by health.py and agent.py

Removes two hardcodes:
- health.py: OLLAMA_URL="http://localhost:11434" → settings.ollama_url
- agent.py:  Ollama(id="llama3.2")              → settings.ollama_model

app.py:
- logging.basicConfig at INFO — requests/errors now visible in terminal
- docs_url/redoc_url gated on settings.debug (off by default)

pyproject.toml:
- pydantic-settings>=2.0.0 added to main dependencies
- hatch wheel config updated to include src/config.py

.env.example: documents all three env vars with inline comments
.gitignore: add !.env.example negation so the template gets committed

.github/workflows/tests.yml: runs pytest --cov on every push/PR
(ubuntu-latest, Python 3.11, pip cache)

All 27 tests pass.

https://claude.ai/code/session_01M4L3R98N5fgXFZRvV8X9b6
This commit is contained in:
Claude
2026-02-19 19:31:48 +00:00
parent 46b848a2d7
commit c1d47eb883
8 changed files with 85 additions and 7 deletions

View File

@@ -1,3 +1,4 @@
import logging
from pathlib import Path
from fastapi import FastAPI, Request
@@ -5,13 +6,27 @@ from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from config import settings
from dashboard.routes.agents import router as agents_router
from dashboard.routes.health import router as health_router
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)-8s %(name)s%(message)s",
datefmt="%H:%M:%S",
)
logger = logging.getLogger(__name__)
BASE_DIR = Path(__file__).parent
PROJECT_ROOT = BASE_DIR.parent.parent
app = FastAPI(title="Timmy Time — Mission Control", version="1.0.0")
app = FastAPI(
title="Timmy Time — Mission Control",
version="1.0.0",
# Docs disabled unless DEBUG=true in env / .env
docs_url="/docs" if settings.debug else None,
redoc_url="/redoc" if settings.debug else None,
)
templates = Jinja2Templates(directory=str(BASE_DIR / "templates"))
app.mount("/static", StaticFiles(directory=str(PROJECT_ROOT / "static")), name="static")