From d4eee4f80b2e422073d5646b4e51429d10887bfb Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Mon, 14 Oct 2024 17:21:10 +0200 Subject: [PATCH 1/6] 105: Add a job reference to each example SDK script. --- example_sdk_client/optimizer.py | 1 + example_sdk_client/optimizer_cancel.py | 1 + example_sdk_client/reconnect.py | 1 + example_sdk_client/simulator.py | 1 + 4 files changed, 4 insertions(+) diff --git a/example_sdk_client/optimizer.py b/example_sdk_client/optimizer.py index a4bf1a9..5a6cab1 100644 --- a/example_sdk_client/optimizer.py +++ b/example_sdk_client/optimizer.py @@ -58,6 +58,7 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate): omotes_if.submit_job( esdl=input_esdl, + job_reference="example_sdk_client.optimizer", params_dict={"key1": "value1", "key2": ["just", "a", "list", "with", "an", "integer", 3]}, workflow_type=workflow_optimizer, job_timeout=timedelta(hours=1), diff --git a/example_sdk_client/optimizer_cancel.py b/example_sdk_client/optimizer_cancel.py index 70dfdf4..8930820 100644 --- a/example_sdk_client/optimizer_cancel.py +++ b/example_sdk_client/optimizer_cancel.py @@ -59,6 +59,7 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate): job = omotes_if.submit_job( esdl=input_esdl, + job_reference="example_sdk_client.optimizer_cancel", params_dict={"key1": "value1", "key2": ["just", "a", "list", "with", "an", "integer", 3]}, workflow_type=workflow_optimizer, job_timeout=timedelta(hours=1), diff --git a/example_sdk_client/reconnect.py b/example_sdk_client/reconnect.py index 04f1318..8ce2e40 100644 --- a/example_sdk_client/reconnect.py +++ b/example_sdk_client/reconnect.py @@ -58,6 +58,7 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate): ) submitted_job: Job = omotes_if_1.submit_job( esdl=input_esdl, + job_reference="example_sdk_client.optimizer_reconnect", params_dict={"key1": "value1", "key2": ["just", "a", "list", "with", "an", "integer", 3]}, workflow_type=workflow_optimizer, job_timeout=timedelta(hours=1), diff --git a/example_sdk_client/simulator.py b/example_sdk_client/simulator.py index 906c4d7..1b19830 100644 --- a/example_sdk_client/simulator.py +++ b/example_sdk_client/simulator.py @@ -57,6 +57,7 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate): omotes_if.submit_job( esdl=input_esdl, + job_reference="example_sdk_client.simulator", params_dict={ "timestep": datetime.timedelta(hours=1), "start_time": datetime.datetime(2019, 1, 2, 0, 0, 0), From 7758eae0ccde0eebe14f3bde227e3c6a80b4ddf6 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Mon, 14 Oct 2024 17:21:35 +0200 Subject: [PATCH 2/6] 105: Add system test to check if job reference is added successfully. --- system_tests/requirements.txt | 1 + system_tests/src/test_workflows_steps.py | 26 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/system_tests/requirements.txt b/system_tests/requirements.txt index 1e1f0ad..1975e17 100644 --- a/system_tests/requirements.txt +++ b/system_tests/requirements.txt @@ -4,3 +4,4 @@ pytest-timeout xmltodict ~= 0.13.0 pip-tools deepdiff ~= 7.0 +pyesdl ~= 24.2 diff --git a/system_tests/src/test_workflows_steps.py b/system_tests/src/test_workflows_steps.py index 93cc269..bdd15cf 100644 --- a/system_tests/src/test_workflows_steps.py +++ b/system_tests/src/test_workflows_steps.py @@ -19,6 +19,7 @@ import xmltodict from deepdiff import DeepDiff from omotes_sdk.types import ParamsDict +import esdl.esdl_handler RABBITMQ_CONFIG = RabbitMQConfig( @@ -285,3 +286,28 @@ def test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped(self) "./test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped.esdl" ) self.compare_esdl(expected_esdl, result_handler.result.output_esdl) + + def test__simulator__job_reference_is_set(self) -> None: + # Arrange + result_handler = OmotesJobHandler() + esdl_file = retrieve_esdl_file("./test_esdl/input/simulator_tutorial.esdl") + workflow_type = "simulator" + timeout_seconds = 60.0 + params_dict = { + "timestep": datetime.timedelta(hours=1), + "start_time": datetime.datetime(2019, 1, 1, 0, 0, 0), + "end_time": datetime.datetime(2019, 1, 1, 3, 0, 0), + } + + # Act + with omotes_client() as omotes_client_: + submit_a_job(omotes_client_, esdl_file, workflow_type, params_dict, result_handler) + result_handler.wait_until_result(timeout_seconds) + + # Assert + self.expect_a_result(result_handler, JobResult.SUCCEEDED) + output_esh = esdl.esdl_handler.EnergySystemHandler() + output_esh.load_from_string(result_handler.result.output_esdl) + self.assertEqual( + output_esh.energy_system.name, "Untitled EnergySystem with return network_simulator" + ) From f2e0a030429325d4701a54230954bf00982de8f5 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 15 Oct 2024 12:12:26 +0200 Subject: [PATCH 3/6] 105: Update SDK to include job reference. --- example_sdk_client/requirements.txt | 2 +- system_tests/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example_sdk_client/requirements.txt b/example_sdk_client/requirements.txt index cfa9729..99607c0 100644 --- a/example_sdk_client/requirements.txt +++ b/example_sdk_client/requirements.txt @@ -1 +1 @@ -omotes_sdk_python==3.1.2 +omotes-sdk-python==3.2.2 diff --git a/system_tests/requirements.txt b/system_tests/requirements.txt index 1975e17..7c3e379 100644 --- a/system_tests/requirements.txt +++ b/system_tests/requirements.txt @@ -1,4 +1,4 @@ -omotes_sdk_python==3.1.2 +omotes-sdk-python==3.2.2 pytest ~= 8.1.2 pytest-timeout xmltodict ~= 0.13.0 From 64e417a3e8066adb4da435bac6f88dd100db3e18 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 15 Oct 2024 12:12:44 +0200 Subject: [PATCH 4/6] 105: Update orchestrator to include job reference. --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 557d4c6..a19f032 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -87,7 +87,7 @@ services: - manual_dev orchestrator: - image: ghcr.io/project-omotes/omotes_orchestrator:1.1.0 + image: ghcr.io/project-omotes/omotes_orchestrator:1.2.0 restart: unless-stopped networks: - omotes From 8084ee74702eb2df7d4f4f06de5d71acf04837c6 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 15 Oct 2024 13:51:56 +0200 Subject: [PATCH 5/6] 105: Update optimizer & simulator worker images to include job reference handling. --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a19f032..ae1a16b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -126,7 +126,7 @@ services: condition: service_healthy grow_worker_optimizer: &grow_worker - image: ghcr.io/project-omotes/omotes-grow-optimizer-worker:2.0.3 + image: ghcr.io/project-omotes/omotes-grow-optimizer-worker:2.0.4 restart: unless-stopped deploy: replicas: 2 @@ -174,7 +174,7 @@ services: GROW_TASK_TYPE: grow_optimizer_with_pressure omotes_simulator_worker: - image: ghcr.io/project-omotes/omotes-simulator-worker:0.0.12 + image: ghcr.io/project-omotes/omotes-simulator-worker:0.0.13 restart: unless-stopped deploy: replicas: 2 From 581770082e21f9c355d82a2a4d2167583fb0cd40 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 15 Oct 2024 14:09:26 +0200 Subject: [PATCH 6/6] 105: Update expected name of ESDL in system test with the introduction of job reference. --- .../output/test__grow_optimizer_default__happy_path.esdl | 2 +- .../test__grow_optimizer_default__happy_path_1source.esdl | 2 +- .../test__grow_optimizer_default__happy_path_2ndsource.esdl | 2 +- ...mizer_default__happy_path_2ndsource_merit_order_swapped.esdl | 2 +- .../output/test__grow_optimizer_no_heat_losses__happy_path.esdl | 2 +- .../output/test__grow_optimizer_with_pressure__happy_path.esdl | 2 +- .../src/test_esdl/output/test__grow_simulator__happy_path.esdl | 2 +- .../src/test_esdl/output/test__simulator__happy_path.esdl | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path.esdl b/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path.esdl index b1fc783..4ce86fa 100644 --- a/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path.esdl +++ b/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path.esdl @@ -1,5 +1,5 @@ - + diff --git a/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_1source.esdl b/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_1source.esdl index 84204fc..0160185 100644 --- a/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_1source.esdl +++ b/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_1source.esdl @@ -1,5 +1,5 @@ - + diff --git a/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource.esdl b/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource.esdl index 6b75ac2..063de63 100644 --- a/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource.esdl +++ b/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource.esdl @@ -1,5 +1,5 @@ - + diff --git a/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped.esdl b/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped.esdl index 83e30db..d4f0332 100644 --- a/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped.esdl +++ b/system_tests/src/test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped.esdl @@ -1,5 +1,5 @@ - + diff --git a/system_tests/src/test_esdl/output/test__grow_optimizer_no_heat_losses__happy_path.esdl b/system_tests/src/test_esdl/output/test__grow_optimizer_no_heat_losses__happy_path.esdl index 832d39e..1caec5b 100644 --- a/system_tests/src/test_esdl/output/test__grow_optimizer_no_heat_losses__happy_path.esdl +++ b/system_tests/src/test_esdl/output/test__grow_optimizer_no_heat_losses__happy_path.esdl @@ -1,5 +1,5 @@ - + diff --git a/system_tests/src/test_esdl/output/test__grow_optimizer_with_pressure__happy_path.esdl b/system_tests/src/test_esdl/output/test__grow_optimizer_with_pressure__happy_path.esdl index 4f4f103..00f0bb5 100644 --- a/system_tests/src/test_esdl/output/test__grow_optimizer_with_pressure__happy_path.esdl +++ b/system_tests/src/test_esdl/output/test__grow_optimizer_with_pressure__happy_path.esdl @@ -1,5 +1,5 @@ - + diff --git a/system_tests/src/test_esdl/output/test__grow_simulator__happy_path.esdl b/system_tests/src/test_esdl/output/test__grow_simulator__happy_path.esdl index e3c3c7a..de12ac3 100644 --- a/system_tests/src/test_esdl/output/test__grow_simulator__happy_path.esdl +++ b/system_tests/src/test_esdl/output/test__grow_simulator__happy_path.esdl @@ -1,5 +1,5 @@ - + diff --git a/system_tests/src/test_esdl/output/test__simulator__happy_path.esdl b/system_tests/src/test_esdl/output/test__simulator__happy_path.esdl index d2702fb..a932877 100644 --- a/system_tests/src/test_esdl/output/test__simulator__happy_path.esdl +++ b/system_tests/src/test_esdl/output/test__simulator__happy_path.esdl @@ -1,5 +1,5 @@ - +