You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4977b25
Browse filesBrowse the repository at this point in the historyBrowse files
Merge chart-type-registry into 2802-chart-data-on-registry, bringing in main
Move this PR's API changelog entries along into main's open section, v3.0-38.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
# Commits from this session also land in repositories that do not use pre-commit at all, such as ones relying on their own git hooks.
35
+
# Running `pre-commit run --all-files` there fails with "InvalidConfigError: .pre-commit-config.yaml is not a file", which says nothing about the commit.
36
+
# Same fail-open rule as below: when the target has no config, there is nothing for this hook to check.
37
+
[ -f"$target/.pre-commit-config.yaml" ] ||exit 0
38
+
34
39
# Pick a runner for the target checkout.
35
40
# `uv run` only works where the target is a uv project whose dependencies resolve,
36
41
# which is not a given: commits from this session also land in worktrees of other repositories,
## Never run the CLI or the app against a shared configuration
7
+
8
+
A development configuration may point at a database or a Redis server that others use too:
9
+
a shared Redis means queued jobs reach workers running other (possibly older) FlexMeasures code,
10
+
and a shared database may hold real data.
11
+
Commands such as `flexmeasures add forecasts --as-job` or `flexmeasures jobs run-automations` queue jobs there.
12
+
13
+
To try a change, use the test suite (it has its own database and Redis database), or isolated local services:
14
+
15
+
- Postgres and Redis of your own (e.g. Docker containers on non-standard ports),
16
+
- a configuration file of your own, naming them,
17
+
- and a separate `HOME`, because FlexMeasures also picks up `~/.flexmeasures.cfg` (see `find_flexmeasures_cfg` in `flexmeasures/utils/config_utils.py`).
18
+
19
+
If you queued something on a shared Redis by accident, delete those jobs, including any deferred jobs that wait for them.
20
+
21
+
Two test runs at once need a database and a Redis database each: see `testing.instructions.md`.
22
+
23
+
## Checking a change against plugins
24
+
25
+
Before changing or removing a function, a model attribute or a CLI option that plugins may use, search the plugins for it.
26
+
Local clones are not enough: they can be on an old branch, and several plugin repositories may not be cloned at all.
27
+
28
+
-`git fetch` each local plugin clone and `git grep` its remote branch, not the working tree.
29
+
- Search the organisations' repositories as well, e.g. `gh search code "<symbol>" --owner FlexMeasures`,
30
+
and read the actual call sites, since substring hits are common (`asset_attributes` matches `set_attribute`).
Copy file name to clipboardExpand all lines: .github/instructions/testing.instructions.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,43 @@ Intermediate full test runs are encouraged when appropriate (e.g., after a signi
17
17
During active development, targeted runs (`pytest path/to/test_module.py`) are acceptable for quick iteration,
18
18
but must not substitute for the full suite at session close.
19
19
20
+
## Run the doctests too
21
+
22
+
CI runs `pytest --doctest-modules`, with a list of `--ignore`s and a `-k` filter (see the test step in `.github/workflows/lint-and-test.yml`).
23
+
Neither `poe test` nor the `addopts` in `pyproject.toml` include doctests,
24
+
so a green local run can still fail in CI on a docstring example alone, for instance after a dependency upgrade.
25
+
Before pushing a dependency change or a docstring example, run the doctests with the same `--ignore` and `-k` arguments as the workflow.
26
+
27
+
A doctest that shows a pint `Quantity` should `print()` it rather than rely on its `repr`,
28
+
because the `repr` differs between pint versions.
29
+
30
+
## Never migrate the test database
31
+
32
+
Do not run `flexmeasures db upgrade` (or `flask db upgrade`) against the test database to check a migration.
33
+
Pytest owns that database: the `db` fixture runs `drop_all()` and `create_all()` and expects nothing else in it.
34
+
The migration chain creates legacy tables (`power`, `price`, `weather`, `market`, `asset`, …) that are not in the current models,
35
+
so `drop_all()` leaves them behind, and since `market` holds a foreign key onto `sensor`,
36
+
every later `drop_all()` fails with `DependentObjectsStillExist` and the whole suite errors at setup.
37
+
`flexmeasures db downgrade base` does not undo it either: an early revision's downgrade recreates a table that still exists, and the chain stops halfway.
38
+
39
+
Verify a migration on a scratch database instead.
40
+
If the test database was migrated by accident, drop the legacy tables explicitly:
41
+
42
+
```sql
43
+
DROPTABLE IF EXISTS power, price, weather, market, market_type, weather_sensor, weather_sensor_type,
0 commit comments