systemd's environment-file parser is stricter than python-dotenv: it does not
accept spaces around '=' and handles quoting differently. A real .env with
'LLM_MODEL =' produces a key with a trailing space, which then reads as unset — the
service starts and fails later on a missing model rather than at startup.
The app already loads .env itself via python-dotenv, resolved against
WorkingDirectory, so the directive was redundant as well as harmful. Found while
cutting rixdagen.se over; the predecessor's unit carried a comment warning about
exactly this, which the generated example had dropped.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
EOF
The project could only run from /home/lasse/riksdagen: 22 files hardcoded that
path, mostly as an `os.chdir(...)` + `sys.path.append(...)` prelude. Those now
derive the root from the file's own location via bootstrap.py, and bulk data
resolves against PLENUM_DATA_DIR.
requirements.txt was from March 2023 and listed Streamlit, altair and pydeck while
omitting fastapi, uvicorn, psycopg2 and pgvector. Replaced with a pyproject.toml
derived from the actual import graph, plus ruff and pytest config.
Postgres opened its connection pool in __init__, so `import backend.app` failed
outright without a reachable database — breaking test collection and any tooling
that merely imports the app. The pool is now opened on first use behind a lock.
systemd units and an nginx site move to deploy/examples/ with __PROJECT_ROOT__ and
__DOMAIN__ placeholders. Real values belong in the deployment's own deploy/prod/,
which is a path upstream never writes to, so the two cannot conflict on merge.
Removed: scripts/migrate_keys.py (an already-executed Arango migration referenced
nowhere) and a dead `import talks2db` in download_talks.py that pointed at a file
excluded from this repo.
Verified: `import backend.app` now succeeds with neither a database nor any network,
and all rewritten scripts import from a foreign working directory with their module
docstrings intact.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>