GridWorks JournalKeeper is responsible for long-term storage and management of GridWorks time-series and message data, beyond the initial persistence layer.
This repository is a work in progress. Current focus is on importing and managing the 2023–2024 Millinocket S3 data in a PostgreSQL database, with Alembic-managed schema migrations.
- Python 3.12
uvmake- Docker / Docker Compose
- PostgreSQL client (
psql) recommended - pre-commit (see below)
This project uses pre-commit for local quality checks. The pre-commit runner
must be installed once on your system (outside the project environment).
We recommend installing it with pipx:
# macOS / Linux
brew install pipx # or see https://pipx.pypa.io/installation/
pipx ensurepath
pipx install pre-commitVerify installation:
pre-commit --version
Note: pre-commit manages its own hook environments and does not rely on the project virtual environment. Once hooks are installed and cached, commits work offline.
This project uses uv for dependency management and a Makefile for workflow orchestration.
From the repository root:
make venv
make dev
pre-commit install
source .venv/bin/activateAfter changing dependencies:
make lock
make devCommon commands:
make lint
make test
make pre-commit
To run the test suite:
make test
JournalKeeper expects:
- a running RabbitMQ broker
- a PostgreSQL database
We run both locally using Docker.
Follow the RabbitMQ setup instructions in gridworks-base
From the repository root:
docker compose upYou should see logs ending with:
database system is ready to accept connections
[Note: docker compose up -d will run in the background if you prefer that]
The dev database is exposed on:
- Host
localhost - Port
5433 - Database
journaldb_dev - User:
journaldb - Password:
journaldb
Port 5433 is used to avoid conflicts with a local PostgreSQL instance on 5432.
Test connectivity:
psql -h localhost -p 5433 -U journaldb journaldb_dev
Alembic is used to manage database schema migrations.
With your dev environment active:
alembic currentExpected output:
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
<revision_id>(head)
alembic upgrade head
This will:
-
- Connect to
journaldb_dev
- Connect to
-
- Create the
alembic_versiontable if needed
- Create the
-
- Apply all migrations in
alembic/versions
- Apply all migrations in
-
- Mark the database as being at
head
- Mark the database as being at
JournalKeeper uses tag-driven releases. The version in pyproject.toml is the single source of truth and must match the Git tag exactly.
-
Update the version
Edit
pyproject.toml:[project] version = "0.1.0"
-
Commit and merge to
main
do this through standard branch -> dev -> main PRs
- Add matching tag on main
git checkout main
git pull origin main
This ensures:
- tag points to the correct commit
- the release guard
tag is on mainwill pass
- ** Create and push the tag**
Now tag locally on main:
git tag v0.1.0
git push origin v0.1.0
This triggers the Release workflow.
JournalKeeper currently runs on an EC2-hosted PostgreSQL instance.
ssh ubuntu@journaldb.electricity.works
psql -U journaldb
Credentials are stored in 1Password
Remote access:
psql -h journaldb.electricity.works -U journaldb -d journaldbThis repository uses:
rufffor linting and formattingmypyfor type checkingpytestfor testspre-commitfor enforcement
Before committing:
make pre-commitMIT -- see LICENSE