Skip to content

Commit

Permalink
Merge pull request #91 from Project-OMOTES/90-update-all-components-t…
Browse files Browse the repository at this point in the history
…o-use-sdk-202-to-include-various-features

90 update all components to use sdk 202 to include various features
  • Loading branch information
lfse-slafleur authored Jul 25, 2024
2 parents bf9ccc1 + 92f0597 commit 16c01fa
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 74 deletions.
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ services:
- manual_dev

orchestrator:
image: ghcr.io/project-omotes/omotes_orchestrator:0.0.13
image: ghcr.io/project-omotes/omotes_orchestrator:0.1.0
restart: unless-stopped
networks:
- omotes
Expand Down Expand Up @@ -125,7 +125,7 @@ services:
condition: service_healthy

grow_worker_optimizer: &grow_worker
image: ghcr.io/project-omotes/omotes-grow-optimizer-worker:2.0.0
image: ghcr.io/project-omotes/omotes-grow-optimizer-worker:2.0.1
restart: unless-stopped
deploy:
replicas: 2
Expand Down Expand Up @@ -168,7 +168,7 @@ services:
GROW_TASK_TYPE: grow_optimizer_with_pressure

omotes_simulator_worker:
image: ghcr.io/project-omotes/omotes-simulator-worker:0.0.8
image: ghcr.io/project-omotes/omotes-simulator-worker:0.0.9
restart: unless-stopped
deploy:
replicas: 2
Expand Down
16 changes: 6 additions & 10 deletions example_sdk_client/optimizer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
from datetime import timedelta

from omotes_sdk.config import RabbitMQConfig
from omotes_sdk.omotes_interface import (
Expand All @@ -9,9 +10,7 @@
JobStatusUpdate,
)

rabbitmq_config = RabbitMQConfig(
username="omotes", password="somepass1", virtual_host="omotes"
)
rabbitmq_config = RabbitMQConfig(username="omotes", password="somepass1", virtual_host="omotes")


def handle_on_finished(job: Job, result: JobResult):
Expand Down Expand Up @@ -44,7 +43,7 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate):


try:
omotes_if = OmotesInterface(rabbitmq_config)
omotes_if = OmotesInterface(rabbitmq_config, "example_sdk")
omotes_if.start()

workflow_optimizer = omotes_if.get_workflow_type_manager().get_workflow_by_name(
Expand All @@ -56,18 +55,15 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate):

omotes_if.submit_job(
esdl=input_esdl,
params_dict={
"key1": "value1",
"key2": ["just", "a", "list", "with", "an", "integer", 3],
},
params_dict={"key1": "value1", "key2": ["just", "a", "list", "with", "an", "integer", 3]},
workflow_type=workflow_optimizer,
job_timeout=None,
job_timeout=timedelta(hours=1),
callback_on_finished=handle_on_finished,
callback_on_progress_update=handle_on_progress_update,
callback_on_status_update=handle_on_status_update,
auto_disconnect_on_result=True,
)
time.sleep(3)
time.sleep(60)
finally:
print("Closing rabbitmq connection")
omotes_if.stop()
14 changes: 5 additions & 9 deletions example_sdk_client/optimizer_cancel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
from datetime import timedelta

from omotes_sdk.config import RabbitMQConfig
from omotes_sdk.omotes_interface import (
Expand All @@ -9,9 +10,7 @@
JobStatusUpdate,
)

rabbitmq_config = RabbitMQConfig(
username="omotes", password="somepass1", virtual_host="omotes"
)
rabbitmq_config = RabbitMQConfig(username="omotes", password="somepass1", virtual_host="omotes")


def handle_on_finished(job: Job, result: JobResult):
Expand Down Expand Up @@ -44,7 +43,7 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate):


try:
omotes_if = OmotesInterface(rabbitmq_config)
omotes_if = OmotesInterface(rabbitmq_config, "example_sdk")
omotes_if.start()

workflow_optimizer = omotes_if.get_workflow_type_manager().get_workflow_by_name(
Expand All @@ -56,12 +55,9 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate):

job = omotes_if.submit_job(
esdl=input_esdl,
params_dict={
"key1": "value1",
"key2": ["just", "a", "list", "with", "an", "integer", 3],
},
params_dict={"key1": "value1", "key2": ["just", "a", "list", "with", "an", "integer", 3]},
workflow_type=workflow_optimizer,
job_timeout=None,
job_timeout=timedelta(hours=1),
callback_on_finished=handle_on_finished,
callback_on_progress_update=handle_on_progress_update,
callback_on_status_update=handle_on_status_update,
Expand Down
9 changes: 4 additions & 5 deletions example_sdk_client/reconnect.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
from uuid import UUID
from datetime import timedelta

from omotes_sdk.config import RabbitMQConfig
from omotes_sdk.omotes_interface import (
Expand Down Expand Up @@ -44,11 +44,10 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate):


workflow_optimizer = WorkflowType("grow_optimizer_default", "some descr")
workflow_manager = WorkflowTypeManager([workflow_optimizer])


try:
omotes_if_1 = OmotesInterface(rabbitmq_config, possible_workflows=workflow_manager)
omotes_if_1 = OmotesInterface(rabbitmq_config, "example_sdk")
with open("example_esdl_optimizer_poc_tutorial.esdl") as open_file:
input_esdl = open_file.read()

Expand All @@ -57,7 +56,7 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate):
esdl=input_esdl,
params_dict={"key1": "value1", "key2": ["just", "a", "list", "with", "an", "integer", 3]},
workflow_type=workflow_optimizer,
job_timeout=None,
job_timeout=timedelta(hours=1),
callback_on_finished=handle_on_finished,
callback_on_progress_update=handle_on_progress_update,
callback_on_status_update=handle_on_status_update,
Expand All @@ -79,7 +78,7 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate):
print("Reconnecting...")

try:
omotes_if_2 = OmotesInterface(rabbitmq_config, possible_workflows=workflow_manager)
omotes_if_2 = OmotesInterface(rabbitmq_config, "example_sdk")
omotes_if_2.start()
omotes_if_2.connect_to_submitted_job(
job=Job(id=submitted_job.id, workflow_type=workflow_optimizer),
Expand Down
2 changes: 1 addition & 1 deletion example_sdk_client/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
omotes_sdk_python==0.0.16
omotes_sdk_python==2.0.2
18 changes: 7 additions & 11 deletions example_sdk_client/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
JobStatusUpdate,
)

rabbitmq_config = RabbitMQConfig(
username="omotes", password="somepass1", virtual_host="omotes"
)
rabbitmq_config = RabbitMQConfig(username="omotes", password="somepass1", virtual_host="omotes")


def handle_on_finished(job: Job, result: JobResult):
Expand Down Expand Up @@ -47,25 +45,23 @@ def handle_on_progress_update(job: Job, progress_update: JobProgressUpdate):


try:
omotes_if = OmotesInterface(rabbitmq_config)
omotes_if = OmotesInterface(rabbitmq_config, "example_sdk")
omotes_if.start()

workflow_simulator = omotes_if.get_workflow_type_manager().get_workflow_by_name(
"simulator"
)
workflow_simulator = omotes_if.get_workflow_type_manager().get_workflow_by_name("simulator")

with open(r"./example_esdl_simulator.esdl", "r") as f:
input_esdl = f.read()

omotes_if.submit_job(
esdl=input_esdl,
params_dict={
"timestep_s": 3600,
"start_time_unix_s": datetime.datetime(2019, 1, 2, 0, 0, 0).timestamp(),
"end_time_unix_s": datetime.datetime(2019, 1, 2, 3, 0, 0).timestamp(),
"timestep": datetime.timedelta(hours=1),
"start_time": datetime.datetime(2019, 1, 2, 0, 0, 0),
"end_time": datetime.datetime(2019, 1, 2, 3, 0, 0),
},
workflow_type=workflow_simulator,
job_timeout=None,
job_timeout=datetime.timedelta(hours=1),
callback_on_finished=handle_on_finished,
callback_on_progress_update=handle_on_progress_update,
callback_on_status_update=handle_on_status_update,
Expand Down
2 changes: 0 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
ENV_FILE="./.env"
DOCKER_COMPOSE_FILE="./docker-compose.yml"

set -e

./scripts/setup_orchestrator_postgres_db.sh $ENV_FILE $DOCKER_COMPOSE_FILE
./scripts/setup_rabbitmq.sh $ENV_FILE $DOCKER_COMPOSE_FILE
./scripts/setup_influxdb.sh $ENV_FILE $DOCKER_COMPOSE_FILE
12 changes: 12 additions & 0 deletions scripts/setup_rabbitmq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,15 @@ ${DOCKER_EXEC} add_user --vhost omotes "${RABBITMQ_OMOTES_USER_NAME}" "${RABBITM
${DOCKER_EXEC} set_permissions --vhost omotes "${RABBITMQ_OMOTES_USER_NAME}" ".*" ".*" ".*"
${DOCKER_EXEC} add_user --vhost omotes_celery "${RABBITMQ_CELERY_USER_NAME}" "${RABBITMQ_CELERY_USER_PASSWORD}"
${DOCKER_EXEC} set_permissions --vhost omotes_celery "${RABBITMQ_CELERY_USER_NAME}" ".*" ".*" ".*"


#_________________________________________________________________________________________________
# QUEUE MIGRATIONS

# mvp.4.RC2
# Ticket 84 84-extend-available-workflow-functionality-to-support-multiple-sdks-at-once

# Remove available_workflows & request_available_workflows durable queues if they exist.
# Messages may be dropped without repercussions.
${DOCKER_EXEC} delete_queue --vhost omotes available_workflows
${DOCKER_EXEC} delete_queue --vhost omotes request_available_workflows
2 changes: 1 addition & 1 deletion system_tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
omotes_sdk_python==1.0.0
omotes_sdk_python==2.0.2
pytest ~= 8.1.2
pytest-timeout
xmltodict ~= 0.13.0
Expand Down
Loading

0 comments on commit 16c01fa

Please sign in to comment.