Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

77: Update optimizer worker to 2.0.0 to include mesido 0.1.5.2 which … #78

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ services:
condition: service_healthy

grow_worker_optimizer: &grow_worker
image: ghcr.io/project-omotes/omotes-grow-optimizer-worker:1.0.14
image: ghcr.io/project-omotes/omotes-grow-optimizer-worker:2.0.0
restart: unless-stopped
deploy:
replicas: 2
Expand Down
1 change: 1 addition & 0 deletions system_tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pytest ~= 8.1.2
pytest-timeout
xmltodict ~= 0.13.0
pip-tools
deepdiff ~= 7.0

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

780 changes: 390 additions & 390 deletions system_tests/src/test_esdl/output/test__grow_simulator__happy_path.esdl

Large diffs are not rendered by default.

90 changes: 29 additions & 61 deletions system_tests/src/test_workflows_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import time
import unittest
from pathlib import Path
from pprint import pformat

from omotes_sdk.config import RabbitMQConfig
from omotes_sdk.omotes_interface import (
Expand All @@ -16,6 +17,7 @@
)
from omotes_sdk.workflow_type import WorkflowType, WorkflowTypeManager
import xmltodict
from deepdiff import DeepDiff

# TODO Now the SQL setup is moved to orchestrator, it takes a while for orchestrator to boot up.
# Therefore, the queues may not yet have been declared. We should fix this in SDK by declaring
Expand Down Expand Up @@ -90,10 +92,13 @@ def retrieve_esdl_file(path_str: str) -> str:


ID_PATTERN = re.compile(r"id=\"[a-z0-9-]+\"")
DATABASE_PATTERN = re.compile(r"database=\"[a-z0-9-]+\"")


def normalize_esdl(esdl: str) -> dict:
return xmltodict.parse(ID_PATTERN.sub('id=""', esdl))
esdl_normalized = ID_PATTERN.sub('id=""', esdl)
esdl_normalized = DATABASE_PATTERN.sub('database=""', esdl_normalized)
return xmltodict.parse(esdl_normalized)


def submit_a_job(
Expand Down Expand Up @@ -126,6 +131,13 @@ def expect_a_result(
print(result.logs)
self.fail(f"The job did not finish as {expected_result}. Found {result.result_type}")

def compare_esdl(self, expected_esdl: str, result_esdl: str) -> None:
expected = normalize_esdl(expected_esdl)
result = normalize_esdl(result_esdl)
diff_msg = pformat(DeepDiff(expected, result))

self.assertEqual(expected, result, msg=f'Found the following differences:\n{diff_msg}')

def test__grow_optimizer_default__happy_path(self) -> None:
# Arrange
workflow_manager_ = workflow_manager()
Expand All @@ -143,14 +155,8 @@ def test__grow_optimizer_default__happy_path(self) -> None:

# Assert
self.expect_a_result(result_handler, JobResult.SUCCEEDED)
self.assertEqual(
normalize_esdl(
retrieve_esdl_file(
"./test_esdl/output/test__grow_optimizer_default__happy_path.esdl"
)
),
normalize_esdl(result_handler.result.output_esdl),
)
expected_esdl = retrieve_esdl_file("./test_esdl/output/test__grow_optimizer_default__happy_path.esdl")
self.compare_esdl(expected_esdl, result_handler.result.output_esdl)

def test__grow_optimizer_no_heat_losses__happy_path(self) -> None:
# Arrange
Expand All @@ -169,14 +175,8 @@ def test__grow_optimizer_no_heat_losses__happy_path(self) -> None:

# Assert
self.expect_a_result(result_handler, JobResult.SUCCEEDED)
self.assertEqual(
normalize_esdl(
retrieve_esdl_file(
"./test_esdl/output/test__grow_optimizer_no_heat_losses__happy_path.esdl"
)
),
normalize_esdl(result_handler.result.output_esdl),
)
expected_esdl = retrieve_esdl_file("./test_esdl/output/test__grow_optimizer_no_heat_losses__happy_path.esdl")
self.compare_esdl(expected_esdl, result_handler.result.output_esdl)

def test__grow_optimizer_with_pressure__happy_path(self) -> None:
# Arrange
Expand All @@ -195,14 +195,8 @@ def test__grow_optimizer_with_pressure__happy_path(self) -> None:

# Assert
self.expect_a_result(result_handler, JobResult.SUCCEEDED)
self.assertEqual(
normalize_esdl(
retrieve_esdl_file(
"./test_esdl/output/test__grow_optimizer_with_pressure__happy_path.esdl"
)
),
normalize_esdl(result_handler.result.output_esdl),
)
expected_esdl = retrieve_esdl_file("./test_esdl/output/test__grow_optimizer_with_pressure__happy_path.esdl")
self.compare_esdl(expected_esdl, result_handler.result.output_esdl)

def test__grow_simulator__happy_path(self) -> None:
# Arrange
Expand All @@ -221,12 +215,8 @@ def test__grow_simulator__happy_path(self) -> None:

# Assert
self.expect_a_result(result_handler, JobResult.SUCCEEDED)
self.assertEqual(
normalize_esdl(
retrieve_esdl_file("./test_esdl/output/test__grow_simulator__happy_path.esdl")
),
normalize_esdl(result_handler.result.output_esdl),
)
expected_esdl = retrieve_esdl_file("./test_esdl/output/test__grow_simulator__happy_path.esdl")
self.compare_esdl(expected_esdl, result_handler.result.output_esdl)

def test__simulator__happy_path(self) -> None:
# Arrange
Expand All @@ -245,12 +235,8 @@ def test__simulator__happy_path(self) -> None:

# Assert
self.expect_a_result(result_handler, JobResult.SUCCEEDED)
self.assertEqual(
normalize_esdl(
retrieve_esdl_file("./test_esdl/output/test__simulator__happy_path.esdl")
),
normalize_esdl(result_handler.result.output_esdl),
)
expected_esdl = retrieve_esdl_file("./test_esdl/output/test__simulator__happy_path.esdl")
self.compare_esdl(expected_esdl, result_handler.result.output_esdl)

def test__grow_optimizer_default__happy_path_1source(self) -> None:
# Arrange
Expand All @@ -269,14 +255,8 @@ def test__grow_optimizer_default__happy_path_1source(self) -> None:

# Assert
self.expect_a_result(result_handler, JobResult.SUCCEEDED)
self.assertEqual(
normalize_esdl(
retrieve_esdl_file(
"./test_esdl/output/test__grow_optimizer_default__happy_path_1source.esdl"
)
),
normalize_esdl(result_handler.result.output_esdl),
)
expected_esdl = retrieve_esdl_file("./test_esdl/output/test__grow_optimizer_default__happy_path_1source.esdl")
self.compare_esdl(expected_esdl, result_handler.result.output_esdl)

def test__grow_optimizer_default__happy_path_2ndsource(self) -> None:
# Arrange
Expand All @@ -295,14 +275,8 @@ def test__grow_optimizer_default__happy_path_2ndsource(self) -> None:

# Assert
self.expect_a_result(result_handler, JobResult.SUCCEEDED)
self.assertEqual(
normalize_esdl(
retrieve_esdl_file(
"./test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource.esdl"
)
),
normalize_esdl(result_handler.result.output_esdl),
)
expected_esdl = retrieve_esdl_file("./test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource.esdl")
self.compare_esdl(expected_esdl, result_handler.result.output_esdl)

def test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped(self) -> None:
# Arrange
Expand All @@ -323,11 +297,5 @@ def test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped(self)

# Assert
self.expect_a_result(result_handler, JobResult.SUCCEEDED)
self.assertEqual(
normalize_esdl(
retrieve_esdl_file(
"./test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped.esdl"
)
),
normalize_esdl(result_handler.result.output_esdl),
)
expected_esdl = retrieve_esdl_file("./test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped.esdl")
self.compare_esdl(expected_esdl, result_handler.result.output_esdl)
Loading