2025-01-06 16:27:57 +01:00
|
|
|
|
import json
|
2025-02-12 21:35:51 +01:00
|
|
|
|
import os
|
2025-11-13 22:53:46 +01:00
|
|
|
|
import shutil
|
2025-01-06 16:27:57 +01:00
|
|
|
|
import sys
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
from unittest.mock import patch
|
|
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
DIR_PROJECT_ROOT = Path(__file__).parent.parent
|
|
|
|
|
|
DIR_TESTDATA = Path(__file__).parent / "testdata"
|
|
|
|
|
|
|
2025-11-13 22:53:46 +01:00
|
|
|
|
DIR_DOCS_GENERATED = DIR_PROJECT_ROOT / "docs" / "_generated"
|
|
|
|
|
|
DIR_TEST_GENERATED = DIR_TESTDATA / "docs" / "_generated"
|
|
|
|
|
|
|
2025-01-06 16:27:57 +01:00
|
|
|
|
|
Add database support for measurements and historic prediction data. (#848)
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-02-22 14:12:42 +01:00
|
|
|
|
def test_openapi_spec_current(config_eos, set_other_timezone):
|
2025-01-06 16:27:57 +01:00
|
|
|
|
"""Verify the openapi spec hasn´t changed."""
|
Add database support for measurements and historic prediction data. (#848)
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-02-22 14:12:42 +01:00
|
|
|
|
set_other_timezone("UTC") # CI runs on UTC
|
|
|
|
|
|
|
2025-01-06 16:27:57 +01:00
|
|
|
|
expected_spec_path = DIR_PROJECT_ROOT / "openapi.json"
|
|
|
|
|
|
new_spec_path = DIR_TESTDATA / "openapi-new.json"
|
|
|
|
|
|
|
2025-02-12 21:35:51 +01:00
|
|
|
|
with expected_spec_path.open("r", encoding="utf-8", newline=None) as f_expected:
|
2025-01-06 16:27:57 +01:00
|
|
|
|
expected_spec = json.load(f_expected)
|
|
|
|
|
|
|
2025-01-09 16:54:49 +01:00
|
|
|
|
# Patch get_config and import within guard to patch global variables within the eos module.
|
Add database support for measurements and historic prediction data. (#848)
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-02-22 14:12:42 +01:00
|
|
|
|
with patch("akkudoktoreos.core.coreabc.get_config", return_value=config_eos):
|
2025-01-06 16:27:57 +01:00
|
|
|
|
# Ensure the script works correctly as part of a package
|
|
|
|
|
|
root_dir = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
sys.path.insert(0, str(root_dir))
|
|
|
|
|
|
from scripts import generate_openapi
|
|
|
|
|
|
|
|
|
|
|
|
spec = generate_openapi.generate_openapi()
|
2025-02-12 21:35:51 +01:00
|
|
|
|
spec_str = json.dumps(spec, indent=4, sort_keys=True)
|
2025-01-06 16:27:57 +01:00
|
|
|
|
|
2025-02-12 21:35:51 +01:00
|
|
|
|
with new_spec_path.open("w", encoding="utf-8", newline="\n") as f_new:
|
|
|
|
|
|
f_new.write(spec_str)
|
2025-01-06 16:27:57 +01:00
|
|
|
|
|
|
|
|
|
|
# Serialize to ensure comparison is consistent
|
|
|
|
|
|
expected_spec_str = json.dumps(expected_spec, indent=4, sort_keys=True)
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
Add database support for measurements and historic prediction data. (#848)
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-02-22 14:12:42 +01:00
|
|
|
|
assert json.loads(spec_str) == json.loads(expected_spec_str)
|
2025-01-06 16:27:57 +01:00
|
|
|
|
except AssertionError as e:
|
|
|
|
|
|
pytest.fail(
|
|
|
|
|
|
f"Expected {new_spec_path} to equal {expected_spec_path}.\n"
|
|
|
|
|
|
+ f"If ok: `make gen-docs` or `cp {new_spec_path} {expected_spec_path}`\n"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
Add database support for measurements and historic prediction data. (#848)
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-02-22 14:12:42 +01:00
|
|
|
|
def test_openapi_md_current(config_eos, set_other_timezone):
|
2025-01-06 16:27:57 +01:00
|
|
|
|
"""Verify the generated openapi markdown hasn´t changed."""
|
Add database support for measurements and historic prediction data. (#848)
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-02-22 14:12:42 +01:00
|
|
|
|
set_other_timezone("UTC") # CI runs on UTC
|
|
|
|
|
|
|
2025-01-06 16:27:57 +01:00
|
|
|
|
expected_spec_md_path = DIR_PROJECT_ROOT / "docs" / "_generated" / "openapi.md"
|
|
|
|
|
|
new_spec_md_path = DIR_TESTDATA / "openapi-new.md"
|
|
|
|
|
|
|
2025-02-12 21:35:51 +01:00
|
|
|
|
with expected_spec_md_path.open("r", encoding="utf-8", newline=None) as f_expected:
|
2025-01-06 16:27:57 +01:00
|
|
|
|
expected_spec_md = f_expected.read()
|
|
|
|
|
|
|
2025-01-09 16:54:49 +01:00
|
|
|
|
# Patch get_config and import within guard to patch global variables within the eos module.
|
Add database support for measurements and historic prediction data. (#848)
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-02-22 14:12:42 +01:00
|
|
|
|
with patch("akkudoktoreos.core.coreabc.get_config", return_value=config_eos):
|
2025-01-06 16:27:57 +01:00
|
|
|
|
# Ensure the script works correctly as part of a package
|
|
|
|
|
|
root_dir = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
sys.path.insert(0, str(root_dir))
|
|
|
|
|
|
from scripts import generate_openapi_md
|
|
|
|
|
|
|
|
|
|
|
|
spec_md = generate_openapi_md.generate_openapi_md()
|
|
|
|
|
|
|
2025-02-12 21:35:51 +01:00
|
|
|
|
with new_spec_md_path.open("w", encoding="utf-8", newline="\n") as f_new:
|
2025-01-06 16:27:57 +01:00
|
|
|
|
f_new.write(spec_md)
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
assert spec_md == expected_spec_md
|
|
|
|
|
|
except AssertionError as e:
|
|
|
|
|
|
pytest.fail(
|
|
|
|
|
|
f"Expected {new_spec_md_path} to equal {expected_spec_md_path}.\n"
|
|
|
|
|
|
+ f"If ok: `make gen-docs` or `cp {new_spec_md_path} {expected_spec_md_path}`\n"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
Add database support for measurements and historic prediction data. (#848)
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-02-22 14:12:42 +01:00
|
|
|
|
def test_config_md_current(config_eos, set_other_timezone):
|
2025-01-06 16:27:57 +01:00
|
|
|
|
"""Verify the generated configuration markdown hasn´t changed."""
|
Add database support for measurements and historic prediction data. (#848)
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-02-22 14:12:42 +01:00
|
|
|
|
set_other_timezone("UTC") # CI runs on UTC
|
|
|
|
|
|
|
2025-11-13 22:53:46 +01:00
|
|
|
|
assert DIR_DOCS_GENERATED.exists()
|
|
|
|
|
|
|
|
|
|
|
|
# Remove any leftover files from last run
|
|
|
|
|
|
if DIR_TEST_GENERATED.exists():
|
|
|
|
|
|
shutil.rmtree(DIR_TEST_GENERATED)
|
2025-01-06 16:27:57 +01:00
|
|
|
|
|
2025-11-13 22:53:46 +01:00
|
|
|
|
# Ensure test dir exists
|
|
|
|
|
|
DIR_TEST_GENERATED.mkdir(parents=True, exist_ok=True)
|
2025-01-06 16:27:57 +01:00
|
|
|
|
|
2025-01-09 16:54:49 +01:00
|
|
|
|
# Patch get_config and import within guard to patch global variables within the eos module.
|
Add database support for measurements and historic prediction data. (#848)
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-02-22 14:12:42 +01:00
|
|
|
|
with patch("akkudoktoreos.core.coreabc.get_config", return_value=config_eos):
|
2025-01-06 16:27:57 +01:00
|
|
|
|
# Ensure the script works correctly as part of a package
|
|
|
|
|
|
root_dir = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
sys.path.insert(0, str(root_dir))
|
|
|
|
|
|
from scripts import generate_config_md
|
|
|
|
|
|
|
2025-11-13 22:53:46 +01:00
|
|
|
|
# Get all the top level fields
|
|
|
|
|
|
field_names = sorted(config_eos.__class__.model_fields.keys())
|
|
|
|
|
|
|
|
|
|
|
|
# Create the file paths
|
|
|
|
|
|
expected = [ DIR_DOCS_GENERATED / "config.md", DIR_DOCS_GENERATED / "configexample.md", ]
|
|
|
|
|
|
tested = [ DIR_TEST_GENERATED / "config.md", DIR_TEST_GENERATED / "configexample.md", ]
|
|
|
|
|
|
for field_name in field_names:
|
|
|
|
|
|
file_name = f"config{field_name.lower()}.md"
|
|
|
|
|
|
expected.append(DIR_DOCS_GENERATED / file_name)
|
|
|
|
|
|
tested.append(DIR_TEST_GENERATED / file_name)
|
|
|
|
|
|
|
|
|
|
|
|
# Create test files
|
Add database support for measurements and historic prediction data. (#848)
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-02-22 14:12:42 +01:00
|
|
|
|
try:
|
|
|
|
|
|
config_eos._force_documentation_mode = True
|
|
|
|
|
|
config_md = generate_config_md.generate_config_md(tested[0], config_eos)
|
|
|
|
|
|
finally:
|
|
|
|
|
|
config_eos._force_documentation_mode = False
|
2025-11-13 22:53:46 +01:00
|
|
|
|
|
|
|
|
|
|
# Check test files are the same as the expected files
|
|
|
|
|
|
for i, expected_path in enumerate(expected):
|
|
|
|
|
|
tested_path = tested[i]
|
|
|
|
|
|
|
|
|
|
|
|
with expected_path.open("r", encoding="utf-8", newline=None) as f_expected:
|
|
|
|
|
|
expected_config_md = f_expected.read()
|
|
|
|
|
|
with tested_path.open("r", encoding="utf-8", newline=None) as f_expected:
|
|
|
|
|
|
tested_config_md = f_expected.read()
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
assert tested_config_md == expected_config_md
|
|
|
|
|
|
except AssertionError as e:
|
|
|
|
|
|
pytest.fail(
|
|
|
|
|
|
f"Expected {tested_path} to equal {expected_path}.\n"
|
|
|
|
|
|
+ f"If ok: `make gen-docs` or `cp {tested_path} {expected_path}`\n"
|
|
|
|
|
|
)
|