generated from Hochfrequenz/python_template_repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump rebdhuhn from 0.3.1 to 0.4.0; Make kroki-port configurable via e…
…nv var; Clean Up docker image (#83) * Bump rebdhuhn from 0.3.1 to 0.4.0 Bumps [rebdhuhn](https://github.com/Hochfrequenz/rebdhuhn) from 0.3.1 to 0.4.0. - [Release notes](https://github.com/Hochfrequenz/rebdhuhn/releases) - [Commits](Hochfrequenz/rebdhuhn@v0.3.1...v0.4.0) --- updated-dependencies: - dependency-name: rebdhuhn dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * ➕ install `python-dotenv` and `pydantic-settings` * make kroki-port configurable * Update docker-compose.yaml * remove direct dependency to python-dotenv (keep indirect) * set min version * please the linters * hrm,. * docs * Fix Docker Compose Setup (#84) * remove healthcheck and networkmode host and make it more explicit which env file is getting used * make host name for kroki configurable * add config extra='ignore' * add test for base settings * remove pylint ignore command * fix path for linting * lower coverage threshold to 43 * ignore mypy, again * don't change linter setup in PR that attempts to fix docker ;) * fix type_check in unittests * add KROKI_HOST to env example * Remove docker-compose code from readme * avoid loading from .env in test case --------- Co-authored-by: konstantin <konstantin.klein@hochfrequenz.de> Co-authored-by: Konstantin <konstantin.klein+github@hochfrequenz.de> * WIP on fix-docker-compose-setup * more docs * Update README.md * update docker-compose * Update README.md --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Konstantin <konstantin.klein+github@hochfrequenz.de> Co-authored-by: konstantin <konstantin.klein@hochfrequenz.de> Co-authored-by: kevin <68426071+hf-krechan@users.noreply.github.com> Co-authored-by: kevin <kevin.krechan@hochfrequenz.de>
- Loading branch information
1 parent
f04b8a6
commit da741bd
Showing
9 changed files
with
107 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
services: | ||
kroki: | ||
image: yuzutech/kroki:0.24.1 | ||
ports: | ||
- "8125:8000" | ||
# hardcoded 8125 because: https://github.com/Hochfrequenz/rebdhuhn/issues/205 | ||
healthcheck: | ||
test: [ "CMD", "curl", "-f", "http://localhost:8000/health" ] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 3 | ||
|
||
scrape-and-plot: | ||
build: . | ||
depends_on: | ||
kroki: | ||
condition: service_healthy | ||
image: ghcr.io/hochfrequenz/ebd_toolchain:latest | ||
# If you run into 'manifest unknown' during docker pull, try replacing `:latest` with `:v1.2.3`. | ||
# where v1.2.3 is the latest version of the GHCR image, which can be found here: | ||
# https://github.com/Hochfrequenz/ebd_toolchain/pkgs/container/ebd_toolchain | ||
volumes: | ||
- ${EBD_DOCX_FILE}:/container/ebd.docx | ||
- ${OUTPUT_DIR}:/container/output | ||
network_mode: host # Allow the container to use the host's network | ||
# this is also a side effect of https://github.com/Hochfrequenz/rebdhuhn/issues/205 | ||
# this prevents: requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8125): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fddfb8c9430>: Failed to establish a new connection: [Errno 111] Connection refused')) | ||
# we need to set the KROKI_HOST and KROKI_PORT to the host and port of the kroki service | ||
# this is configurable here, but it does not need to be changed if the kroki service is named "kroki" | ||
environment: | ||
KROKI_PORT: "8000" | ||
KROKI_HOST: "kroki" | ||
# the .env file contains the parameter which the user can set | ||
env_file: | ||
- path: .env | ||
required: true # default is true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
EBD_DOCX_FILE=./edi_energy_mirror/edi_energy_de/FV2410/Entscheidungsbaum-DiagrammeundCodelisten-informatorischeLesefassung3.5KonsolidierteLesefassungmitFehlerkorrekturenStand31.07.2024_20250403_20240403.docx | ||
OUTPUT_DIR=./ebd_toolchain/machine-readable_entscheidungsbaumdiagramme/FV2404 | ||
KROKI_PORT=8125 | ||
KROKI_HOST=kroki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# mypy: disable-error-code="call-arg" | ||
import pytest | ||
from _pytest.monkeypatch import MonkeyPatch | ||
from pydantic import ValidationError | ||
|
||
from ebd_toolchain.main import Settings | ||
|
||
|
||
def test_settings_from_env(monkeypatch: MonkeyPatch) -> None: | ||
# Mock environment variables to simulate the .env behavior | ||
monkeypatch.setenv("KROKI_PORT", "8000") | ||
monkeypatch.setenv("KROKI_HOST", "localhost") | ||
|
||
# Instantiate the Settings class | ||
settings = Settings() | ||
|
||
# Assert the settings have loaded correctly from environment | ||
assert settings.kroki_port == 8000 | ||
assert settings.kroki_host == "localhost" | ||
|
||
|
||
def test_settings_missing_required_fields(monkeypatch: MonkeyPatch) -> None: | ||
# Ensure no environment variables are set | ||
monkeypatch.delenv("KROKI_PORT", raising=False) | ||
monkeypatch.delenv("KROKI_HOST", raising=False) | ||
|
||
# Expecting ValidationError due to missing required environment variables | ||
with pytest.raises(ValidationError): | ||
Settings(_env_file="foo.env") # change env file to avoid loading from .env | ||
|
||
|
||
def test_invalid_port_value(monkeypatch: MonkeyPatch) -> None: | ||
# Set invalid environment variables | ||
monkeypatch.setenv("KROKI_PORT", "not_an_integer") | ||
monkeypatch.setenv("KROKI_HOST", "localhost") | ||
|
||
# Expecting ValidationError because KROKI_PORT is not a valid integer | ||
with pytest.raises(ValidationError): | ||
Settings() |