From afd6590360c86fb5ae93f82b80edd75ee5ee9271 Mon Sep 17 00:00:00 2001 From: gac-x12sa Date: Wed, 11 Jun 2025 12:51:02 +0200 Subject: [PATCH 1/4] fix(pre-startup): update pre_startup get_config for test, production and local usage --- .../bec_ipython_client/startup/pre_startup.py | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/startup/pre_startup.py b/csaxs_bec/bec_ipython_client/startup/pre_startup.py index c9e6274..1446114 100644 --- a/csaxs_bec/bec_ipython_client/startup/pre_startup.py +++ b/csaxs_bec/bec_ipython_client/startup/pre_startup.py @@ -2,7 +2,9 @@ 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. """ - +import os +import csaxs_bec +from bec_lib.service_config import ServiceConfig def extend_command_line_args(parser): """ @@ -14,8 +16,14 @@ def extend_command_line_args(parser): return parser -# def get_config() -> ServiceConfig: -# """ -# Create and return the service configuration. -# """ -# return ServiceConfig(redis={"host": "localhost", "port": 6379}) +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}) + else: + return ServiceConfig(redis={"host": "localhost", "port": 6379}) -- 2.49.1 From 2894b1e5c249099ff4faa497ceab34c5bf56eb58 Mon Sep 17 00:00:00 2001 From: appel_c Date: Wed, 11 Jun 2025 15:09:24 +0200 Subject: [PATCH 2/4] 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}) -- 2.49.1 From 8eac0a2c3826145c0caee2f6182d3fe2ef45d00f Mon Sep 17 00:00:00 2001 From: gac-x12sa Date: Wed, 11 Jun 2025 15:14:44 +0200 Subject: [PATCH 3/4] wip --- csaxs_bec/bec_ipython_client/startup/pre_startup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csaxs_bec/bec_ipython_client/startup/pre_startup.py b/csaxs_bec/bec_ipython_client/startup/pre_startup.py index 81e2149..7d5459f 100644 --- a/csaxs_bec/bec_ipython_client/startup/pre_startup.py +++ b/csaxs_bec/bec_ipython_client/startup/pre_startup.py @@ -24,7 +24,7 @@ def get_config() -> ServiceConfig: """ Create and return the service configuration. """ - deployment_path = os.path.dirname(os.path.dirname(csaxs_bec.__file__)) + deployment_path = os.path.dirname(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")) -- 2.49.1 From 2baaaac1f3079ebf044be0f01800dc0fc34a236a Mon Sep 17 00:00:00 2001 From: appel_c Date: Wed, 11 Jun 2025 16:53:34 +0200 Subject: [PATCH 4/4] fix: copier update for pre_startup --- .copier-answers.yml | 2 +- csaxs_bec/bec_ipython_client/startup/pre_startup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.copier-answers.yml b/.copier-answers.yml index 3dd46f1..8c4bd24 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -2,7 +2,7 @@ # It is needed to track the repo template version, and editing may break things. # This file will be overwritten by copier on template updates. -_commit: v1.0.0 +_commit: v1.0.3-1-g7cb3be0 _src_path: https://github.com/bec-project/plugin_copier_template.git make_commit: false project_name: csaxs_bec diff --git a/csaxs_bec/bec_ipython_client/startup/pre_startup.py b/csaxs_bec/bec_ipython_client/startup/pre_startup.py index 7d5459f..4ba6343 100644 --- a/csaxs_bec/bec_ipython_client/startup/pre_startup.py +++ b/csaxs_bec/bec_ipython_client/startup/pre_startup.py @@ -22,7 +22,7 @@ def extend_command_line_args(parser): def get_config() -> ServiceConfig: """ - Create and return the service configuration. + Create and return the ServiceConfig for the plugin repository """ deployment_path = os.path.dirname(os.path.dirname(os.path.dirname(csaxs_bec.__file__))) files = os.listdir(deployment_path) -- 2.49.1