* optimization states for AC, DC and IDLE now similar probab. Also AC states taken from config. Maybe a single config option for AC and E-Auto States is sensefull.
* Ruff
* test_class_optimize: Update testdata
* Write pdf and json to test/testdata/new.... so it can be analyzed
manually or just copied as new expected result.
* workflow: Upload pytest optimization result artifacts (pdf, json)
---------
Co-authored-by: Andreas <drbacke@gmx.de>
* Mypy: Initial support
* Add to pre-commit (currently installs own deps, could maybe changed
to poetry venv in the future to reuse environment and don't need
duplicated types deps).
* Add type hints.
* Mypy: Add missing annotations
* Migrate from Flask to FastAPI
* FastAPI migration:
- Use pydantic model classes as input parameters to the
data/calculation classes.
- Interface field names changed to constructor parameter names (for
simplicity only during transition, should be updated in a followup
PR).
- Add basic interface requirements (e.g. some values > 0, etc.).
* Update tests for new data format.
* Python requirement down to 3.9 (TypeGuard no longer needed)
* Makefile: Add helpful targets (e.g. development server with reload)
* Move API doc from README to pydantic model classes (swagger)
* Link to swagger.io with own openapi.yml.
* Commit openapi.json and check with pytest for changes so the
documentation is always up-to-date.
* Streamline docker
* FastAPI: Run startup action on dev server
* Fix config for /strompreis, endpoint still broken however.
* test_openapi: Compare against docs/.../openapi.json
* Move fastapi to server/ submodule
* See #187 for new repository structure.
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>
* 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>
* 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>
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
* 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.
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>