Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ DB_HOSTNAME=omotes_postgres
DB_PORT=6432
DB_USERNAME=omotes_timeseries_rw
DB_PASSWORD=somepass4
# Required when ESDL_OUTPUT_PROFILES_TYPE=POSTGRESQL
PG_DB_TIMESERIES=omotes_timeseries

# ESDL_OUTPUT_PROFILES_TYPE=INFLUXDB
# DB_HOSTNAME=omotes_influxdb
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy_optimizer_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
-e DB_PORT=6432 \
-e DB_USERNAME=omotes_timeseries_rw \
-e DB_PASSWORD \
-e PG_DB_TIMESERIES=omotes_timeseries \
-e MINIO_HOST=omotes-minio \
-e MINIO_PORT=9000 \
-e MINIO_EXTERNAL_URL \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_container_image.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Publish Container Image
run-name: Releasing next version 🚀
run-name: Publish Container Image

on:
push:
Expand Down
5 changes: 5 additions & 0 deletions src/omotes_optimizer_worker/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def db_password() -> str:
"""Return database password."""
return require_env("DB_PASSWORD")

@staticmethod
def pg_db_timeseries() -> str:
"""Return PostgreSQL timeseries database name."""
return os.getenv("PG_DB_TIMESERIES", "omotes_timeseries")

@staticmethod
def prefect_api_url_for_worker() -> str:
"""Return Prefect API URL to be used inside worker."""
Expand Down
1 change: 1 addition & 0 deletions src/omotes_optimizer_worker/prefect_deploy_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async def _build_docker_image(command: list[str], cwd: Path | None = None) -> No
"DB_PORT": EnvSettings.db_port(),
"DB_USERNAME": EnvSettings.db_username(),
"DB_PASSWORD": EnvSettings.db_password(),
"PG_DB_TIMESERIES": EnvSettings.pg_db_timeseries(),
"MINIO_HOST": EnvSettings.minio_host(),
"MINIO_PORT": EnvSettings.minio_port(),
"MINIO_EXTERNAL_URL": EnvSettings.minio_external_url(),
Expand Down
25 changes: 15 additions & 10 deletions src/omotes_optimizer_worker/prefect_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,29 @@ def optimizer_flow(
)
esdl_output_profiles_type = ESDLOutputProfilesType.POSTGRESQL

logging.info(
"Will write result profiles to '%s' database at %s:%s",
esdl_output_profiles_type_str,
db_host,
db_port,
)

database_connection = []
pg_db_timeseries = None
if esdl_output_profiles_type == ESDLOutputProfilesType.POSTGRESQL:
pg_db_timeseries = EnvSettings.pg_db_timeseries()

database_connection.append({
db_connection = {
"access_type": DBAccessType.READ_WRITE,
"host": db_host,
"port": db_port,
"username": db_username,
"password": db_password,
"ssl": False,
"verify_ssl": False,
})
}

msg = f"Will write result profiles to '{esdl_output_profiles_type_str}' database at {db_host}:{db_port}"

if pg_db_timeseries:
db_connection["database"] = pg_db_timeseries
msg += f"/{db_connection['database']}"

logging.info(msg)

database_connection = [db_connection]

esdl_messages: list[EsdlMessage] = []

Expand Down
Loading