From 2894b1e5c249099ff4faa497ceab34c5bf56eb58 Mon Sep 17 00:00:00 2001 From: appel_c Date: Wed, 11 Jun 2025 15:09:24 +0200 Subject: [PATCH] wip test template for bec_config.yaml resolution --- .../bec_ipython_client/startup/pre_startup.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/startup/pre_startup.py b/csaxs_bec/bec_ipython_client/startup/pre_startup.py index 1446114..81e2149 100644 --- a/csaxs_bec/bec_ipython_client/startup/pre_startup.py +++ b/csaxs_bec/bec_ipython_client/startup/pre_startup.py @@ -1,11 +1,15 @@ """ Pre-startup script for BEC client. This script is executed before the BEC client -is started. It can be used to add additional command line arguments. +is started. It can be used to add additional command line arguments. """ + import os -import csaxs_bec + from bec_lib.service_config import ServiceConfig +import csaxs_bec + + def extend_command_line_args(parser): """ Extend the command line arguments of the BEC client. @@ -20,10 +24,9 @@ def get_config() -> ServiceConfig: """ Create and return the service configuration. """ - path = os.path.dirname(csaxs_bec.__file__) - if path.startswith('/data/test/x12sa-test-bec/production'): - return ServiceConfig(redis={"host": "x12sa-bec-001", "port": 6379}) - elif path.startswith('/data/test/x12sa-test-bec/test'): - return ServiceConfig(redis={"host": "x12sa-bec-002", "port": 6379}) + deployment_path = os.path.dirname(os.path.dirname(csaxs_bec.__file__)) + files = os.listdir(deployment_path) + if "bec_config.yaml" in files: + return ServiceConfig(config_path=os.path.join(deployment_path, "bec_config.yaml")) else: return ServiceConfig(redis={"host": "localhost", "port": 6379})