Skip to content

Commit 766ac8f

Browse files
cappel89d-perl
andauthored
feat(pre-startup): resolve bec_config.yaml path automatically for beamline deployments, otherwise fallback to default cfg (#4)
Co-authored-by: David Perl <david.perl@psi.ch>
1 parent 6f4d40c commit 766ac8f

2 files changed

Lines changed: 31 additions & 16 deletions

File tree

template/{{project_name}}/bec_ipython_client/startup/pre_startup.py

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Pre-startup script for BEC client. This script is executed before the BEC client
3+
is started. It can be used to add additional command line arguments.
4+
"""
5+
6+
import os
7+
8+
from bec_lib.service_config import ServiceConfig
9+
10+
import {{ project_name }}
11+
12+
13+
def extend_command_line_args(parser):
14+
"""
15+
Extend the command line arguments of the BEC client.
16+
"""
17+
18+
# parser.add_argument("--session", help="Session name", type=str, default="cSAXS")
19+
20+
return parser
21+
22+
def get_config() -> ServiceConfig:
23+
"""
24+
Create and return the ServiceConfig for the plugin repository
25+
"""
26+
deployment_path = os.path.dirname(os.path.dirname(os.path.dirname({{ project_name }}.__file__)))
27+
files = os.listdir(deployment_path)
28+
if "bec_config.yaml" in files:
29+
return ServiceConfig(config_path=os.path.join(deployment_path, "bec_config.yaml"))
30+
else:
31+
return ServiceConfig(redis={"host": "localhost", "port": 6379})

0 commit comments

Comments
 (0)