Commit Graph
68 Commits
Author SHA1 Message Date
Dominique LasserreandGitHub c89e8e95fa fix: Catch optimize error and return error message. (#534) 2025-04-23 16:26:35 +02:00
Dominique LasserreandGitHub 7ade15e9e3 fix: Circular runtime import Closes #533 (#535) 2025-04-23 16:26:04 +02:00
Dominique Lasserre cc5fb060ed Merge remote-tracking branch 'origin/main' into feature/config-nested 2025-04-09 00:24:50 +02:00
Dominique Lasserre 0f7837458f Merge remote-tracking branch 'origin/main' into feature/config-nested 2025-04-06 14:51:07 +02:00
Dominique Lasserre 5eb6d84572 Dockerfile: Set default for EOS_SERVER__EOSDASH_SESSKEY Closes #447 (#467)
* This allows to start the container without any extra settings
   (potentially unsafe).
   It is recommended to set EOS_SERVER__EOSDASH_SESSKEY.
2025-04-06 14:46:52 +02:00
Dominique Lasserre c46d13731d docker-compose: Expose EOSdash port Closes #447
* Fixes direct EOSdash access on Windows localhost:8504 (required for
   redirect).
2025-04-06 14:46:52 +02:00
Dominique Lasserre 00229c39e4 visualize.py: Support variable remuneration Closes #451 (#459) 2025-04-06 14:46:52 +02:00
Dominique Lasserre a95d6c939a Windows: Fix EOSdash startup Closes #436 #447 (#450)
* On Windows use 127.0.0.1 as default config host (model defaults) and
   addionally redirect 0.0.0.0 to localhost on Windows (because default
   config file still has 0.0.0.0).
   Use 0.0.0.0 as default otherwise (e.g. Linux/Docker) to allow EOS
   being accessible on local network (not just same host).
   Note: Docs generation on Windows is incompatible with the Github
   pipeline tests. Address this in the nested-config feature branch.
 * Update install/startup instructions as package installation is
   required atm and Docker on Windows has to be accessed at localhost or
   127.0.0.1 even though the server log says 0.0.0.0 (which is required
   to be available outside the container).
 * Fix EOSdash startup with read_only: true (support session key via
   EOS_SERVER__EOSDASH_SESSKEY variable). Backport of feature branch.
 * Remove root_path, causing Windows to fail load swagger UI (/docs).
2025-04-06 14:46:52 +02:00
Dominique Lasserre 84598c592c README.md: Add some system requirements (#438) 2025-04-06 12:47:34 +02:00
Dominique LasserreandGitHub d2136f1447 Dockerfile: Set default for EOS_SERVER__EOSDASH_SESSKEY Closes #447 (#467)
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
* This allows to start the container without any extra settings
   (potentially unsafe).
   It is recommended to set EOS_SERVER__EOSDASH_SESSKEY.
2025-02-23 16:17:54 +01:00
Dominique LasserreandBobby Noelte 20621aa626 docker-compose: Expose EOSdash port Closes #447
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
* Fixes direct EOSdash access on Windows localhost:8504 (required for
   redirect).
2025-02-18 07:08:14 +01:00
Dominique LasserreandGitHub 76b5ec3638 visualize.py: Support variable remuneration Closes #451 (#459)
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
2025-02-16 11:06:31 +01:00
Dominique LasserreandGitHub 694655311f Workflow: Docker build on all PRs (#429)
* Just amd64 and no push.
2025-02-15 19:48:20 +01:00
Dominique LasserreandGitHub 1a2cb4d37d Fix Python 3.13: classmethod + property unsupported (#448)
* Use own classproperty (don't inherit from property).
 * Config generation: Rename pathlib._local to pathlib
2025-02-11 21:01:45 +01:00
Dominique LasserreandGitHub b380624c9f Windows: Fix EOSdash startup Closes #436 #447 (#450)
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
* On Windows use 127.0.0.1 as default config host (model defaults) and
   addionally redirect 0.0.0.0 to localhost on Windows (because default
   config file still has 0.0.0.0).
   Use 0.0.0.0 as default otherwise (e.g. Linux/Docker) to allow EOS
   being accessible on local network (not just same host).
   Note: Docs generation on Windows is incompatible with the Github
   pipeline tests. Address this in the nested-config feature branch.
 * Update install/startup instructions as package installation is
   required atm and Docker on Windows has to be accessed at localhost or
   127.0.0.1 even though the server log says 0.0.0.0 (which is required
   to be available outside the container).
 * Fix EOSdash startup with read_only: true (support session key via
   EOS_SERVER__EOSDASH_SESSKEY variable). Backport of feature branch.
 * Remove root_path, causing Windows to fail load swagger UI (/docs).
2025-02-10 00:38:35 +01:00
Dominique LasserreandGitHub d05b161e24 Config: Don't fail on config error, fix Windows config dir (#426)
* Support setting logger level (env) before config load.
2025-02-08 00:45:11 +01:00
Dominique LasserreandBobby Noelte da4994ca39 Remove potentially unexpected config update 2025-02-02 10:09:15 +01:00
Dominique LasserreandBobby Noelte 94618f5f66 REST: Allow setting single config value
* /v1/config/{path} supports setting single config value (post body). Lists are
   supported as well by using the index:
    - general/latitude (value: 55.55)
    - optimize/ev_available_charge_rates_percent/0 (value: 42)

   Whole tree can be overriden as well (no merge):
    - optimize/ev_available_charge_rates_percent (value: [42, 43, 44]

 * ConfigEOS: Add set_config_value, get_config_value
2025-02-02 10:09:15 +01:00
Dominique LasserreandGitHub 29cf3a3174 README.md: Add some system requirements (#438)
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
2025-02-01 20:46:00 +01:00
Dominique LasserreandGitHub 6516455071 Readme: Add hint for interfering ports on Synology Closes #408 (#419) 2025-01-26 18:26:46 +01:00
Dominique Lasserre 26762e5e93 Review comments 2025-01-24 21:14:37 +01:00
Dominique Lasserre 56403fe053 EOSdash: Sort config by name 2025-01-24 20:08:53 +01:00
Dominique Lasserre 5bd8321e95 Docs: Add global example documentation.
* merge_models: Use deecopy to not change input data.
2025-01-24 20:08:53 +01:00
Dominique Lasserre c1dd31528b Config: Move lat/long/timezone from prediction to general 2025-01-24 20:08:53 +01:00
Dominique Lasserre 1658b491d2 Update manual documentation for nested config.
* Add config_file_path, config_folder_path back to general
   (ConfigCommonSettings). Overwrite in docs generation.
2025-01-24 20:08:52 +01:00
Dominique Lasserre af5e4a753a PVForecast: planes as nested config (list) 2025-01-24 20:08:52 +01:00
Dominique Lasserre e0b1ece524 PR review 2025-01-24 20:08:50 +01:00
Dominique Lasserre 437d38f508 Fix EOSdash startup (docker)
* Docker: Copy the same directory structure (src/) to support the
   lifespan startup of EOSdash.
   Use EOS_SERVER_EOSDASH_SESSKEY environment variable to provide
   EOSdash with session key.
2025-01-24 20:08:48 +01:00
Dominique Lasserre 95be7b914f Fix API endpoint 2025-01-24 20:07:23 +01:00
Dominique Lasserre 3257dac92b Rename settings variables (remove prefixes) 2025-01-24 20:07:21 +01:00
Dominique Lasserre 1e1bac9fdb EOSdash: Support nested types 2025-01-24 20:06:38 +01:00
Dominique Lasserre d74a56b75a Documentation: Support nested config
* Add examples to pydantic models.
2025-01-24 20:05:48 +01:00
Dominique Lasserre be26457563 Nested config, devices registry
* All config now nested.
    - Use default config from model field default values. If providers
      should be enabled by default, non-empty default config file could
      be provided again.
    - Environment variable support with EOS_ prefix and __ between levels,
      e.g. EOS_SERVER__EOS_SERVER_PORT=8503 where all values are case
      insensitive.
      For more information see:
      https://docs.pydantic.dev/latest/concepts/pydantic_settings/#parsing-environment-variable-values
    - Use devices as registry for configured devices. DeviceBase as base
      class with for now just initializion support (in the future expand
      to operations during optimization).
    - Strip down ConfigEOS to the only configuration instance. Reload
      from file or reset to defaults is possible.

 * Fix multi-initialization of derived SingletonMixin classes.
2025-01-24 20:05:48 +01:00
Dominique LasserreandBobby Noelte f09658578a Fix docker access. Closes #278
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
* Need to start within container with host 0.0.0.0 to access it later
   on host.
2025-01-24 07:45:40 +01:00
Dominique Lasserre dae1a7ad17 Combine main and feature/config-overhaul
* Merge main with -s ours strategy
2025-01-16 18:51:32 +01:00
Dominique LasserreandGitHub 9ad61f66b2 Cleanup: parameters: extra=forbid, optimize: battery, inverter optional (#361)
* Cleanup: parameters: extra=forbid, optimize: battery, inverter optional

 * Don't allow extra fields for parameters/REST-API (at least for now while
   changing API).
 * Allow both battery and inverter to be set optionally (atm optional
   battery not implemented, no API constraints).
 * inverter: Remove default max_power_wh
 * single_test_optimization: Add more cli-parameters

* Workflow docker-build: Don't try to authenticate for PRs

 * Secrets are not available anyway for forks.
2025-01-13 21:44:17 +01:00
Dominique LasserreandGitHub b6111517ca workflow: docker-build upload to DockerHub (#318) (#363)
docker-build / platform-excludes (push) Waiting to run
docker-build / build (push) Blocked by required conditions
docker-build / merge (push) Blocked by required conditions
* workflow: docker-build upload to DockerHub
   - Upload on release, tag, push to main.
   - Build on pr to main (amd64 only).
 * docker:
   - Update documentation.
   - Temporarily set akkudoktor/eos:main in compose.yml (with
     releases/tags it should be replaced by latest again)
2025-01-12 00:52:42 +01:00
Dominique LasserreandGitHub ef60f5b9f5 Tests: Ignore config in current test execution directory. Closes #342 (#345) 2025-01-06 23:50:20 +01:00
Dominique LasserreandGitHub 10acc705ec Initial readthedocs config (#339)
* Add links to documentation.
 * Drop unused file class_soc_calc.
2025-01-06 19:34:15 +01:00
Dominique LasserreandGitHub eabc2a795a workflow: docker-build upload to DockerHub (#318)
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
* workflow: docker-build upload to DockerHub
   - Upload on release, tag, push to main.
   - Build on pr to main (amd64 only).
 * docker: temporarily disable read-only container Closes #278
   - Update documentation.
   - Temporarily set akkudoktor/eos:main in compose.yml (with
     releases/tags it should be replaced by latest again)
2025-01-04 01:24:37 +01:00
Dominique LasserreandGitHub 03ec729e50 Update regular_grid_interpolator.pkl to scipy 1.15 Closes #335 (#336) (#337) 2025-01-04 00:52:20 +01:00
Dominique LasserreandGitHub 64e62022e2 Update regular_grid_interpolator.pkl to scipy 1.15 Closes #335 (#336)
pre-commit / pre-commit (push) Waiting to run
Run Pytest on Pull Request / test (push) Waiting to run
2025-01-04 00:42:19 +01:00
Dominique LasserreandGitHub 4cb6dc7270 Fix ruff (#328) 2025-01-02 18:34:55 +01:00
Dominique LasserreandGitHub 69eac26885 Prediction: Support manual update (#319)
* Provide /v1/prediction/update and
   /v1/prediction/update/{provider_id} as POST endpoints to update
   provider data.
 * Update description for deprecated endpoints how to use new API.
2025-01-01 16:10:34 +01:00
Dominique LasserreandGitHub 05ed5ab836 Update README.md (#303)
- Development on feature/config-overhaul
2024-12-30 23:46:20 +01:00
Dominique LasserreandGitHub 75987db9e1 Reasonable defaults, isolate tests, EOS_LOGGING_LEVEL, EOS_CONFIG_DIR
* Add EOS_CONFIG_DIR to set config dir (relative path to EOS_DIR or
   absolute path).
    - config_folder_path read-only
    - config_file_path read-only
 * Default values to support app start with empty config:
    - latitude/longitude (Berlin)
    - optimization_ev_available_charge_rates_percent (null, so model
      default value is used)
    - Enable Akkudoktor electricity price forecast (docker-compose).
 * Fix some endpoints (empty data, remove unused params, fix types).
 * cacheutil: Use cache dir. Closes #240
 * Support EOS_LOGGING_LEVEL environment variable to set log level.
 * tests: All tests use separate temporary config
    - Add pytest switch --check-config-side-effect to check user
      config file existence after each test. Will also fail if user config
      existed before test execution (but will only check after the test has
      run).
      Enable flag in github workflow.
    - Globally mock platformdirs in config module. Now no longer required
      to patch individually.
      Function calls to config instance (e.g. merge_settings_from_dict)
      were unaffected previously.
 * Set Berlin as default location (default config/docker-compose).
2024-12-30 13:41:39 +01:00
Dominique Lasserre 267a9bf427 pvforecast: Some values optional. Closes #292 (#293)
* temperature, relativehumidity_2m, windspeed_10m can be null
 * prettify pv_forecast_input_1.json (and add null value)
2024-12-30 13:07:08 +01:00
Dominique Lasserre b386c4be70 inverter test: Mock SelfConsumptionProbabilityInterpolator 2024-12-30 13:07:08 +01:00
Dominique Lasserre e8a47af04e simulate: more verbose validation 2024-12-30 13:07:08 +01:00
Dominique Lasserre 053e60aca4 Pythonic: Rename self_consumption_probability.py -> interpolator.py
* Rename class self_consumption_probability_interpolator to PascalCase
   SelfConsumptionProbabilityInterpolator.
2024-12-30 13:07:08 +01:00
Dominique LasserreandGitHub f195edb07d pvforecast: Some values optional. Closes #292 (#293)
* temperature, relativehumidity_2m, windspeed_10m can be null
 * prettify pv_forecast_input_1.json (and add null value)
2024-12-29 16:43:37 +01:00
Dominique LasserreandAndreas 6aa2112da1 workflow: Pytest also upload artifacts on test failure 2024-12-22 10:36:36 +01:00
Dominique LasserreandAndreas 11b925f9bd input data: Fix indentation
* Comment full_run (use pytest --full-run to activate)
2024-12-22 10:36:36 +01:00
79ecf71353 Optimize states (#256)
* 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>
2024-12-16 13:37:16 +01:00
Dominique LasserreandGitHub a5e637ab4c Update optimize full-run (#238)
* Enable full-run in github workflow
2024-12-12 14:37:46 +01:00
Dominique LasserreandGitHub 6db7e96bc1 pre-commit: Fix mypy hook (#233)
* Install missing deps. In the future we probably just want to reuse
   the dev environment (e.g. poetry shell) to have same result for hook
   and explicit execution in venv.
2024-12-11 00:21:07 +01:00
Dominique LasserreandGitHub 1163ddb4ac Mypy (#217)
* 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
2024-11-26 22:28:05 +01:00
Dominique LasserreandGitHub d697d0c079 Fix docs creation Closes #218 (#219)
* Fix swagger link in sphynx docs.
2024-11-23 16:44:46 +01:00
Dominique LasserreandGitHub 777303a2b7 optimize: Enforce start solution with at least two elements Closes #205 (#207)
* mate -> cxTwoPoints needs at least two elements.
2024-11-18 20:54:39 +01:00
Dominique LasserreandGitHub edfe309a26 Update README/CONTRIBUTING Closes #180 (#204)
* Update README/CONTRIBUTING Closes #180

 * Remove duplicated files in docs/develop and copy them from project
   root to there on documentation generation.

* Makefile: Use fastapi to start server, set port to 8503
2024-11-17 15:27:43 +01:00
Dominique LasserreandGitHub b3914ab16b visualize: Keep shape of plots the same on dst change Closes #185 (#203)
* Currently prediction hours are relative from current hour and don't
   adjust on daylight saving change.
 * ist_dst_wechsel now unused.
2024-11-16 21:52:51 +01:00
Dominique LasserreandGitHub 69212c3cff Update startup instructions. Closes #201 (#202) 2024-11-16 20:35:09 +01:00
Dominique LasserreandGitHub f61665669f Migrate from Flask to FastAPI (#163)
* 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.
2024-11-15 22:27:25 +01:00
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
Dominique LasserreandGitHub 219bff1d04 Cleanup: Fix violin chart labels, remove debug code (#167) 2024-10-31 11:17:45 +01:00
Dominique LasserreandAndreas 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
Dominique LasserreandAndreas 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
Dominique LasserreandAndreas 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