diff --git a/src/blueapi/cli/cli.py b/src/blueapi/cli/cli.py index db8a22d1c..e2b586232 100644 --- a/src/blueapi/cli/cli.py +++ b/src/blueapi/cli/cli.py @@ -11,6 +11,7 @@ from bluesky_stomp.models import Broker from observability_utils.tracing import setup_tracing from pydantic import ValidationError +from pydantic_settings.sources import PathType from requests.exceptions import ConnectionError from blueapi import __version__ @@ -32,7 +33,7 @@ "-c", "--config", type=Path, help="Path to configuration YAML file", multiple=True ) @click.pass_context -def main(ctx: click.Context, config: Path | None | tuple[Path, ...]) -> None: +def main(ctx: click.Context, config: PathType) -> None: # Override default yaml_file path in the model_config if `config` is provided ApplicationConfig.model_config["yaml_file"] = config app_config = ApplicationConfig() # Instantiates with customized sources diff --git a/src/blueapi/config.py b/src/blueapi/config.py index 2dccd12fd..f63bd5fd6 100644 --- a/src/blueapi/config.py +++ b/src/blueapi/config.py @@ -95,7 +95,9 @@ class ApplicationConfig(BaseSettings, cli_parse_args=True, cli_prog_name="blueap ) @classmethod - def customize_sources(cls, init_settings, env_settings, file_secret_settings): + def settings_customize_sources( + cls, init_settings, env_settings, file_secret_settings + ): path = cls.model_config.get("yaml_file") return ( init_settings, diff --git a/src/blueapi/service/interface.py b/src/blueapi/service/interface.py index f968fd925..9cfbe6116 100644 --- a/src/blueapi/service/interface.py +++ b/src/blueapi/service/interface.py @@ -15,7 +15,11 @@ from blueapi.worker.task_worker import TaskWorker, TrackableTask """This module provides interface between web application and underlying Bluesky -context and worker""" +context and worker + +the _CONFIG global variable is used by the subprocess only + +""" _CONFIG: ApplicationConfig = ApplicationConfig() @@ -26,6 +30,10 @@ def config() -> ApplicationConfig: def set_config(new_config: ApplicationConfig): + """ + This is a setter function that the main process uses + to pass the config into the subprocess + """ global _CONFIG _CONFIG = new_config