353 Commits

Author SHA1 Message Date
Bobby Noelte
82cbf0f649 Round pv forecast report data. (#194)
Report data are floats.

The report is used for unit testing which may be affected by the float precision of the test environment.
Round to make the test result more robust without loosing the general test case.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2024-11-11 21:27:08 +01:00
Bobby Noelte
b630625a4d Add test to PVForecast (#174)
* Add documentation to class_pv_forecast.py.

Added documentation. Beware mostly generated by ChatGPT.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>

* Add CacheFileStore, datetime and logger utilities.

The `CacheFileStore` class is a singleton-based, thread-safe key-value store for managing
temporary file objects, allowing the creation, retrieval, and management of cache files.

The utility modules offer a flexible logging setup (`get_logger`) and utilities to handle
different date-time formats (`to_datetime`, `to_timestamp`) and timezone detection
(`to_timezone).

- Cache files are automatically valid for the the current date unless specified otherwise.
  This is to mimic the current behaviour used in several classes.
- The logger supports rotating log files to prevent excessive log file size.
- The `to_datetime` and `to_timestamp`functions support a wide variety of input types and formats.
  They provide the time conversion that is e.g. used in PVForecast.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>

* Improve testability of PVForecast

Improvements for testing of PVForecast
- Use common utility functions to allow for general testing at one spot.
  - to_datetime
  - CacheFileStore
- Use logging instead of print to easily capture in testing.
- Add validation of the json schema for Akkudoktor PV forecast data.
- Allow to create an empty PVForecast instance as base instance for testing.
- Make process_data() complete for filling a PVForecast instance for testing.
- Normalize forecast datetime to timezone of system given in loaded data.
- Do not print report but provide report for test checks.
- Get rid of cache file path using the CachFileStore to automate cache file usage.
- Improved module documentation.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>

* Add test for PVForecast and newly extracted utility modules.

- Add test for PVForecast
- Add test for CacheFileStore in the new cachefilestore module
- Add test for to_datetime, to_timestamp, to_timezone in the new
  datetimeutil module
- Add test for get_logger in the new logutil module

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>

---------

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Co-authored-by: Normann <github@koldrack.com>
2024-11-10 23:49:10 +01:00
dependabot[bot]
c4c9e59a57 Bump pytest-cov from 5.0.0 to 6.0.0 (#190)
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 5.0.0 to 6.0.0.
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v5.0.0...v6.0.0)

---
updated-dependencies:
- dependency-name: pytest-cov
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-10 23:35:48 +01:00
dependabot[bot]
86f0d48863 Bump numpy from 2.1.2 to 2.1.3 (#189)
Bumps [numpy](https://github.com/numpy/numpy) from 2.1.2 to 2.1.3.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst)
- [Commits](https://github.com/numpy/numpy/compare/v2.1.2...v2.1.3)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-10 23:34:10 +01:00
Bobby Noelte
94467e1a69 Add API documentation generation and use Markdown (#160)
* Add package API documentation generation

Add generation of the API documentation for akkudoktoreos
and akkudoktoreosserver packages.

The API documentation is generated by the Sphinx autosummary extension.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>

* Enable Google style source commenting and documentation generation.

Enable automatic documentation generation from Google style docstrings in the source.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>

* Check Google style source commenting.

Check Google style commenting by the appropriate ruff rules.

Commenting is _NOT_ enforced. Missing docstrings are ignored.

Minor commenting quirks of the code base are adapted.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>

* Improve Markdown handling and switch to Markdown documentation.

Switch to Markdown for the documentation files to improve the user and developer experience (see issue #181).

Keep files with special directives for automatic API documentation in RST format. The
directives expect RST.

Also add dummy handling for openai/ swagger server documentation. The openai interface definition is
for now taken from the fastapi PR as EOS will switch to fastAPI.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>

---------

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Co-authored-by: Normann <github@koldrack.com>
2024-11-10 23:27:52 +01:00
Dominique Lasserre
3652298134 Add more optimization tests (#171)
* Integrated single_test_optimization into pytest to run a basic optimization test with tolerance set to 1e-6, ensuring quick detection of deviations.
* Added a long-run test (400 generations, like single_test_optimization), which can be triggered using --full-run in pytest.
* Mocked PDF creation in optimization tests and added a new PDF generation test with image comparison validation.

Note: Current tolerance is set to 1e-6; feedback on whether this tolerance is tight enough is welcome.

---------

Co-authored-by: Normann <github@koldrack.com>
Co-authored-by: Michael Osthege <michael.osthege@outlook.com>
2024-11-10 23:22:30 +01:00
Chris
de9fe2ddc9 Add settings and extension recommendations (#139)
- Added recommended settings for the Pylance and Pyright extensions
- Enabled pytest and debugging support in configuration
- Reformatted code with Prettier
---------
Co-authored-by: Chris <git@nootch.de>
2024-11-10 23:00:16 +01:00
Normann
1ed06fc270 set min_soc_prozent 0 by default (#184)
#183 the current default value of "Null" is not compatible with the class_akku. A default value of 0 is more reasonable.
2024-11-10 17:37:24 +01:00
dependabot[bot]
c1cc07e060 Bump sphinx from 8.0.2 to 8.1.3 (#172)
Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 8.0.2 to 8.1.3.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/master/CHANGES.rst)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v8.0.2...v8.1.3)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-31 11:57:51 +01:00
Dominique Lasserre
219bff1d04 Cleanup: Fix violin chart labels, remove debug code (#167) 2024-10-31 11:17:45 +01:00
Andreas
2e54775efe Hopefully the last precommit fix 2024-10-22 10:39:10 +02:00
Andreas
3f064ba5ef PreCommit Fixed 2024-10-22 10:39:10 +02:00
Andreas
cfbe7130e7 PreCommit Fixed 2024-10-22 10:39:10 +02:00
Andreas
c47f071f55 PreCommit Fixed 2024-10-22 10:39:10 +02:00
Andreas
45a3bcdb09 Tests fixed 2024-10-22 10:39:10 +02:00
Andreas
24c7593056 Time problems in EMS / Optimization 2024-10-22 10:39:10 +02:00
Andreas
ad550c874b AC Charge Bug, Price Cache On/Off 2024-10-22 10:39:10 +02:00
Andreas
7adf3d336a AC /DC / Discharge optimzation - First try (not finished yet) 2024-10-22 10:39:10 +02:00
Andreas
87ec02a90e class_ems: AC / DC Charging
class_optimize: Timing Bugs fixed
class_numpy_encoder: JSON Encoder with Numpy support
visualize: AC / DC / Discharge
test_class_ems_2: New Test for AC / DC charging decision
2024-10-22 10:39:10 +02:00
Andreas
cafed7eaca EV Bugs 2024-10-22 10:39:10 +02:00
Andreas
2b5f0ee53c EV Charge Parameters optional + AC Charge first try (Parameter Reduction) 2024-10-22 10:39:10 +02:00
Andreas
6881710295 EV possible currents -> Work now (new Mutate Function)
-> Some Penalties are removed (deprecated)
AC Charge -> Parameter in Optimization -1,0,1
-> Missing integration in class_ems
2024-10-22 10:39:10 +02:00
Chris
e65eb6b6dd Ruff format 2024-10-11 09:07:53 +02:00
Chris
5503b8876c Extend line length 2024-10-11 09:07:53 +02:00
Dominique Lasserre
a71eab3bd0 Streamline Dockerfile, remove unused deps
* Dockerfile: Use non-root user, buildx cache, setup for readonly
   container, remove unused apt deps.
   For now don't install pip package and keep development flask server
   as this will be replaced in the future (fastapi). Then a proper
   webserver (e.g. nginx) should be used and the pip package can be
   created and deployed just to the run-stage (with the webserver).
 * docker-compose: Set to readonly (anonymous volumes declared in
   Dockerfile should maintain all writable data).
   Mount config.py for easier development. Should be replaced by
   environment support for all config file variables.
 * Remove unused runtime dependencies: mariadb, joblib, pytest,
   pytest-cov.
 * Move pytest-cov to dev dependencies.
 * Add output_dir to config.py.
 * Fix visualization_results.pdf endpoint.
 * Update docs.
2024-10-11 08:39:14 +02:00
Bobby Noelte
86639b9437 Add documentation infrastructure
Add documentation infrastructure and some sample content.

Documentation is generated by sphinx using extensions to support
Markdown an restructuredText for simple documentation writing.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2024-10-10 15:22:34 +02:00
Dominique Lasserre
12c9e4428e Replace pytz with stdlib zoneinfo/timezone, Bump python to 3.10
* Timezone support comes with the standard lib since 3.9
 * Bump to 3.10 because typing.TypeGuard
2024-10-10 14:18:40 +02:00
Bobby Noelte
6cf1215ba1 Fix test server startup detection.
Startup of the test server is detected by a scan on the server logging output to stdout.
Startup is now detected on the late log output.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2024-10-10 13:53:28 +02:00
Michael Osthege
be0ab5e297 Run tests after merging
Previously tests did not run after merging.

This lead to incompatible changes being merged right after one another.

By running tests on main we will notice breaks earlier.

Other options would be to require every PR to rebase on main before merging.
This is known as requiring linear history and can be changed in the project settings.
2024-10-10 13:52:45 +02:00
Dominique Lasserre
5edff42954 Fix test_server Closes #147
* Don´t rely on calculation per specific day, just verify length.
2024-10-10 07:41:42 +02:00
Bobby Noelte
5bd8c532af Fix Adapt data to package directory structure
Due to .gitignore directive files in data/ were ignored. Thus data was not moved to correct location by pr #122.

Add load_profiles.npz and remove gitignore directive.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2024-10-09 18:18:35 +02:00
Michael Osthege
2f1f37577b Activate optimization test with 3 generations 2024-10-09 17:05:36 +02:00
Michael Osthege
f4661b0043 Remove and ignore visualization side-effect outputs 2024-10-09 17:05:36 +02:00
Normann
987bffe148 JSON files for test_class_optimize.py
Update test_class_optimize.py

added Skipped per default

Fix optimization test

Fix optimization test
2024-10-09 17:05:36 +02:00
Michael Osthege
2c1dd7a1fd Fix matplotlib warning about xticklabels 2024-10-09 17:05:36 +02:00
Normann
0526f2417b Update README.md
clarify the None/Null/NaN values of the output.
2024-10-09 17:03:05 +02:00
BerndCzech
7156aed85a refactor: remove README-DE.md 2024-10-09 17:02:16 +02:00
Andreas
38a457a3dc Ruff 2024-10-09 16:59:50 +02:00
Andreas
004e1f3dc7 [BUG]: class_ems nd_array not JSON serializable
Big Bugfix - not sure if everything works
2024-10-09 16:59:50 +02:00
Andreas
e72008471f JSON Response fixed 2024-10-09 16:59:50 +02:00
Bobby Noelte
65044b6c6c Add test for server
A test fixture to start the server and a first test case is added.

The fixture tries to assure that the server is installed and running.
If it is not installed the fixture uses pip to install it.

The server and the installation by pip is run bei the same Python
executable that also runs pytest.

The github workflow for pytest is adapted to install akkudoktor-eos.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2024-10-08 19:22:16 +02:00
Normann
1e78abb074 convert np arrys to lists before changing 2024-10-08 18:55:51 +02:00
Normann
dc8f2f94b8 revert check in test for ems 2024-10-08 18:55:51 +02:00
Normann
62339a0e6c set current hour value None in class_ems.py 2024-10-08 18:55:51 +02:00
Normann
3050320607 remove unused function
replace_nan_with_none(data) is not needed anymore since we don't have any NaN values. Another 13% speed increase.
2024-10-08 18:55:51 +02:00
dependabot[bot]
0e81241fdc Bump numpy from 1.26.4 to 2.1.2
Bumps [numpy](https://github.com/numpy/numpy) from 1.26.4 to 2.1.2.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst)
- [Commits](https://github.com/numpy/numpy/compare/v1.26.4...v2.1.2)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-08 18:54:11 +02:00
Normann
03efff52d9 TypeGuard[float] added to isfloat 2024-10-08 07:53:07 +02:00
Normann
56587305e0 README-DE Python req. pushed to 3.10 2024-10-08 07:53:07 +02:00
Normann
4e0e363ba5 README.md Python req. pushed to 3.10 2024-10-08 07:53:07 +02:00
Normann
76be16b06a empty line added 2024-10-08 07:53:07 +02:00