Skip to content

Commit d7ee637

Browse files
committed
Backport PR #2007: Fix: forecasting CLI for v0.31 (#2007)
* fix: CLI options require serialized defaults Signed-off-by: F.N. Claessen <claessen@seita.nl> * fix: pass already deserialized config to forecaster Signed-off-by: F.N. Claessen <claessen@seita.nl> * dev: fix import issue for Python 3.10 Signed-off-by: F.N. Claessen <claessen@seita.nl> * feat: add test to cover CLI command execution with minimal options Signed-off-by: F.N. Claessen <claessen@seita.nl> * Revert "dev: fix import issue for Python 3.10" This reverts commit 1558573. * Revert "fix: pass already deserialized config to forecaster" This reverts commit 980591d. * Revert "fix: CLI options require serialized defaults" This reverts commit 1624d47. * fix: prefer tested and working forecasting CLI over CLI help type annotations Signed-off-by: F.N. Claessen <claessen@seita.nl> * style: itemize symbol Signed-off-by: F.N. Claessen <claessen@seita.nl> * docs: changelog entry Signed-off-by: F.N. Claessen <claessen@seita.nl> * docs: add release date for v0.31.1 Signed-off-by: F.N. Claessen <claessen@seita.nl> * docs: add API changelog entry Signed-off-by: F.N. Claessen <claessen@seita.nl> * docs: elaborate API changelog entry Signed-off-by: F.N. Claessen <claessen@seita.nl> --------- Signed-off-by: F.N. Claessen <claessen@seita.nl> (cherry picked from commit ccfd069) Signed-off-by: F.N. Claessen <claessen@seita.nl>
1 parent cace75e commit d7ee637

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

documentation/changelog.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ FlexMeasures Changelog
44
**********************
55

66

7-
v0.31.1 | March XX, 2026
7+
v0.31.1 | March 6, 2026
88
============================
99

1010
Bugfixes
1111
-----------
12-
- Add missing field documentation for ``aggregate-power`` and ``state-of-charge`` fields, which can be used to reference a sensor on which to record extra scheduling results [see `PR #2003 <https://www.github.com/FlexMeasures/flexmeasures/pull/2003>`_ and `PR #2006 <https://www.github.com/FlexMeasures/flexmeasures/pull/2006>`_]
12+
* Fix CLI command ``flexmeasures add forecasts`` [see `PR #2007 <https://www.github.com/FlexMeasures/flexmeasures/pull/2007>`_]
13+
* Add missing field documentation for ``aggregate-power`` and ``state-of-charge`` fields, which can be used to reference a sensor on which to record extra scheduling results [see `PR #2003 <https://www.github.com/FlexMeasures/flexmeasures/pull/2003>`_ and `PR #2006 <https://www.github.com/FlexMeasures/flexmeasures/pull/2006>`_]
1314

1415

1516
v0.31.0 | February 28, 2026

documentation/cli/change_log.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
FlexMeasures CLI Changelog
55
**********************
66

7+
since v0.31.1 | March 6, 2026
8+
=================================
9+
10+
* Fix CLI command ``flexmeasures add forecasts`` in exchange for less detailed type annotations on various CLI options (visible when using the ``--help`` flag).
11+
712
since v0.31.0 | February 28, 2026
813
=================================
914

flexmeasures/cli/data_add.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,9 @@ def add_forecast( # noqa: C901
11411141
)
11421142

11431143
try:
1144-
pipeline_returns = forecaster.compute(as_job=as_job, **parameters)
1144+
# Drop None values
1145+
parameters = {k: v for k, v in parameters.items() if v is not None}
1146+
pipeline_returns = forecaster.compute(as_job=as_job, parameters=parameters)
11451147

11461148
# Empty result
11471149
if not pipeline_returns:

flexmeasures/cli/tests/test_data_add_fresh_db.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@
1717
from flexmeasures.tests.utils import get_test_sensor
1818

1919

20+
def test_add_forecast(app, setup_dummy_data):
21+
from flexmeasures.cli.data_add import add_forecast
22+
23+
cli_input = {
24+
"sensor": 1,
25+
}
26+
runner = app.test_cli_runner()
27+
result = runner.invoke(add_forecast, to_flags(cli_input))
28+
assert result.exit_code == 0, result.output
29+
30+
2031
def test_add_reporter(app, fresh_db, setup_dummy_data, caplog):
2132
"""
2233
The reporter aggregates input data from two sensors (both have 200 data points)

flexmeasures/cli/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,18 +466,18 @@ def decorator(command):
466466
kwargs = {
467467
"help": help_text,
468468
"required": field.required,
469-
"default": field.load_default,
469+
# "default": field.load_default,
470470
}
471471

472472
if cli.get("is_flag"):
473473
kwargs["is_flag"] = True
474474

475475
# Transfer the original field type
476476
if isinstance(field, MarshmallowClickMixin):
477-
kwargs["type"] = field
477+
kwargs["type"] = str
478478
elif isinstance(field, fields.List):
479479
kwargs["multiple"] = True
480-
kwargs["type"] = field.inner
480+
kwargs["type"] = str
481481

482482
command = click.option(*options, **kwargs)(command)
483483

0 commit comments

Comments
 (0)