Commit graph

527 commits

Author SHA1 Message Date
f9643642b8
Use isna() and notna()
`isnull()` and `notnull()` are mere aliases,
so the stored outputs stay valid.
2026-12-03 11:33:10 +01:00
9c409b619e
Apply the safe ruff fixes
The fixes keep every value the same, so the stored outputs stay valid.
For example, `np.NaN` becomes `np.nan`, which `numpy` v2 requires.
2026-12-03 11:33:04 +01:00
50889df241
Skip the comment-only commits in git blame 2026-12-03 11:15:36 +01:00
c18fc2ba59
Refer to sources with "See:" in comments 2026-12-03 11:09:38 +01:00
f90f263dab
Explain the "why" in a few more comments
Comments that only repeated the code are removed.
2026-12-03 11:06:36 +01:00
51f68743e5
Reword the comments in the config files
Each comment is one sentence or two short ones
joined by "=>", without a final period.
2026-12-03 11:06:17 +01:00
bca4250b4d
Reword the comments in the test suite
Each comment is one sentence or two short ones
joined by "=>", without a final period.
2026-12-03 10:52:25 +01:00
0f69709226
Reword the comments in the rest of velofy
Each comment is one sentence or two short ones
joined by "=>", without a final period.
2026-12-03 10:46:42 +01:00
9b8fe8b8fd
Reword the comments in velofy.forecasts
Each comment is one sentence or two short ones
joined by "=>", without a final period.
2026-12-03 10:43:55 +01:00
1413d08ed9
Reword the comments in velofy.db
Each comment is one sentence or two short ones joined by "=>", without a final period.
2026-12-03 10:38:28 +01:00
ff7f705bc8
Put identifiers in comments into backticks 2026-12-03 10:17:12 +01:00
2f1afd459f
Break multi-line comments before conjunctions 2026-12-03 10:13:13 +01:00
049a5f6f62
Remove periods from one-sentence comments 2026-12-03 10:04:43 +01:00
454c2898a0
Remove the F401 ignore for __init__.py files
All re-exporting packages declare `__all__`;
so, unused imports are reported there, too.
2026-12-03 09:48:27 +01:00
732a74be1c
Declare __all__ in all re-exporting packages
Then, the linters know the imports are re-exports and not unused.
2026-12-03 09:44:07 +01:00
e5c7487515
Merge branch 'ci-and-infra' into develop
All checks were successful
CI / Tests (test-types) (push) Successful in 2m0s
CI / Tests (test) (push) Successful in 2m2s
CI / Tests (test-with-3.15) (push) Successful in 2m4s
CI / Tests (test-with-3.13) (push) Successful in 2m16s
CI / Lint (push) Successful in 2m16s
Reviewed-on: #21
2026-12-03 01:25:32 +01:00
8b5e66d70b
Install only nox and pre-commit in CI
All checks were successful
CI / Tests (test-types) (push) Successful in 2m3s
CI / Tests (test) (push) Successful in 2m6s
CI / Tests (test-with-3.15) (push) Successful in 2m10s
CI / Lint (push) Successful in 2m20s
CI / Tests (test-with-3.13) (push) Successful in 2m21s
The `nox` sessions install `velofy` and its dependencies themselves;
so, a full `uv sync` only duplicated that work.
2026-12-03 01:12:31 +01:00
53746966ac
Cache uv between CI runs
All jobs restore built wheels (e.g., `rpy2`) and the Python versions
instead of building or fetching them again.

Only the "lint" job saves the cache, pruned to what is expensive to rebuild,
and only when its key changed; so, five jobs do not compress the same archive
in parallel, and unchanged runs skip the 15s of packing.
2026-12-03 01:12:30 +01:00
e1cdac4cfa
Run the CI checks in parallel jobs
The test sessions run as a matrix, each with its own database.

This also adds the "test-with" sessions to CI;
so, the setup installs all `SUPPORTED_PYTHONS` via `uv`,
as `nox` would otherwise pick the system Python 3.13,
which lacks the headers to build `rpy2`.
2026-12-03 01:12:29 +01:00
49276bb9cf
Pull the CI setup into a composite action
The upcoming parallel jobs share it.
2026-12-03 01:12:28 +01:00
cc45b78e5d
Rename the CI job and add a timeout
The version in the name broke the required status check
when 3.14 became the `MAIN_PYTHON`.

The timeout ensures the CI server stays ready
even when something goes badly wrong.
2026-12-03 01:12:28 +01:00
9be63c3fef
Merge branch 'python-3.14' into develop
All checks were successful
CI / Checks (Python 3.14) (push) Successful in 2m43s
Reviewed-on: #20
2026-12-02 22:30:07 +01:00
2a64958a93
Make Python 3.14 the MAIN_VERSION
All checks were successful
CI / Checks (Python 3.14) (push) Successful in 2m46s
`requires-python` stays at ">=3.13"; so, `uv.lock` is unchanged
and 3.13 is tested with the "test-with" session.
2026-12-02 21:54:16 +01:00
df53ce7bc4
Pin MAIN_PYTHON in the "init-project" session
Otherwise, `uv` creates ".venv" with the newest installed Python.
2026-12-02 21:49:17 +01:00
67917ae3f6
Type check against the oldest Python version
Without a configured version, `mypy` and `pyright`
check against the Python that runs them.

With `MAIN_PYTHON` at 3.14, they would accept
`stdlib` APIs and `typing` features new in 3.14.

Yet, `requires-python` promises 3.13;
so, the type checkers must flag such code.

`black` and `ruff` already target 3.13 for the same reason.
2026-12-02 21:42:06 +01:00
b947337bd1
Remove flake8-return
It crashes on Python 3.14 (`ast.NameConstant` is gone) and is unmaintained.

`ruff` covers its rules.
2026-12-02 21:39:21 +01:00
80d2573f0d
Remove flake8-pie
It crashes on Python 3.14 (`ast.Str` is gone) and is unmaintained.

`ruff` covers its rules.
2026-12-02 21:27:27 +01:00
5609e8ec6e
Test with Python 3.14 and 3.15
The new "test-with" session runs the test suite with non-main Python versions;
yet, `MAIN_PYTHON` stays at 3.13
2026-12-02 17:43:05 +01:00
a85d426b6e
Merge branch 'alembic-api' into develop
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m47s
Reviewed-on: #19
2026-12-02 14:05:17 +01:00
35d0c7b409
Test reading the database revision
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m50s
In the "sequentially" variant of the test database,
`current_db_revision()` must return the head of the migrations;
in the "all_at_once" variant, there is no version table.
2026-12-02 13:56:04 +01:00
2add322a25
Test the revision lock of the CLI stages
The `@db_revision` decorator no longer skips its check under `TESTING`.

The tests replace `current_db_revision()` with the revision they need.
2026-12-02 13:42:04 +01:00
eb059c1ea5
Read the database revision with the Alembic API
The `@db_revision` decorator no longer runs `alembic current` in a subprocess,
which only worked from the project folder and reported any failure as a wrong revision.

Also, its docstring now explains that it locks completed stages of the data pipeline.
2026-12-02 13:35:37 +01:00
ef7b41e675
Merge branch 'directions-json' into develop
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m47s
Reviewed-on: #18
2026-12-02 11:43:02 +01:00
664dccee02
Store the directions of paths as JSON arrays
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m46s
The data migration converts the 42 existing rows
from a JSON-encoded string into a JSON array.
2026-12-02 11:23:01 +01:00
bbd7d6a279
Store Path._directions as a JSON array
The column is of type `JSON`,
but the code stored a JSON-encoded string in it;
so, the data was encoded twice.

A later data migration converts the existing rows.
2026-12-02 09:03:49 +01:00
2b1dd6af35
Merge branch 'sqlalchemy-select' into develop
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m46s
Reviewed-on: #17
2026-12-02 00:38:24 +01:00
fc185fa3c0
Create the engine and the session on first use
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m47s
The global `db.session` is now a `scoped_session`,
like, for example, in Flask-SQLAlchemy.

Importing the package no longer creates an engine;
so, the placeholder for the tests is obsolete.

The `db_session` fixture replaces `db.session` with `monkeypatch`
such that it is reset after each test.

Tests without the fixture get a placeholder that fails loudly
instead of opening a real session,
which would block the `DROP SCHEMA` at the end of the test run.
2026-12-02 00:23:41 +01:00
9d98021b11
Request the db_session fixture
The test queries the database but relied on the
global `db.session` that the previous test had left behind.
2026-12-02 00:19:51 +01:00
bc2e3f439d
Count with .scalar_one() in velofy.console.gridify
A `COUNT` always returns exactly one row; `.scalar_one()`
is typed as `int` and is used for all other counts as well.
2026-12-01 23:51:00 +01:00
185a37f7d4
Query with select() in the forecasting models
`Session.query()` is the legacy API in SQLAlchemy 2.x.

`.one_or_none()` expresses that the unique constraint
on the five filtered columns allows at most one cached `Forecast`.
2026-12-01 23:48:36 +01:00
2eb6b5769f
Query with select() in Pixel
`Session.query()` is the legacy API in SQLAlchemy 2.x.

The addresses with restaurants are now selected with a subquery in one statement.

The `_restaurants_mock` fixture mocks the new call chain.
2026-12-01 23:45:35 +01:00
0dc3e11a63
Query with select() in Customer
`Session.query()` is the legacy API in SQLAlchemy 2.x.

The delivery and pickup addresses are now selected with subqueries in one statement each.
2026-12-01 23:39:44 +01:00
54e21109e7
Query with select() in Restaurant
`Session.query()` is the legacy API in SQLAlchemy 2.x.

The delivery addresses are now selected with a subquery in one statement.
2026-12-01 23:37:57 +01:00
9d2a4139b7
Query with select() in City
`Session.query()` is the legacy API in SQLAlchemy 2.x.

The addresses with restaurants are now selected with a subquery in one statement.
2026-12-01 23:35:21 +01:00
53e1859ee8
Query with select() in Grid and Path
`Session.query()` is the legacy API in SQLAlchemy 2.x.

Unlike `Query`, `select()` does not deduplicate single entities from a `JOIN`;
so, `Grid.gridify()` calls `.unique()` explicitly.

The `addresses_mock` fixtures mock the new call chain.
2026-12-01 23:29:39 +01:00
1f5a39f83a
Query with select() in velofy.console
`Session.query()` is the legacy API in SQLAlchemy 2.x.
2026-12-01 23:21:00 +01:00
c1f04c65aa
Count rows with select() in the tests
`Session.query()` is the legacy API in SQLAlchemy 2.x.
2026-12-01 23:17:57 +01:00
455af6dfdb
Merge branch 'orm-review' into develop
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m46s
Reviewed-on: #16
2026-12-01 23:06:03 +01:00
248c1ae600
Ignore the foreign keys into the original data
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m47s
The migrations create foreign keys from the `CLEAN_SCHEMA`
into the `ORIGINAL_SCHEMA` to ensure the cleaned data still
refer to the original data.

The ORM models do not know the original tables.
Also, print the `diff` as indented JSON.
2026-12-01 22:58:01 +01:00
25ed8c744b
Recreate checks stored by an old PostgreSQL version
Before version 14, PostgreSQL stored `EXTRACT(...)` as `date_part(...)`,
and the rendering of `IN (...)` changed as well.

The checks created in 2021 express the same rules as the ORM models
but render differently. See the docstring of the migration for details.
2026-12-01 22:56:12 +01:00