From bef5f2fa8add3e3f06a1ee81de64458ae1d6bf1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= <31612826+anders-kiaer@users.noreply.github.com> Date: Sun, 11 Dec 2022 19:57:45 +0100 Subject: [PATCH] Ensure `SETTINGS_SUBSCRIPTIONS` is loaded before `webviz_settings` (#661) --- webviz_config/templates/copy_data_template.py.jinja2 | 10 ++++++++++ webviz_config/templates/webviz_template.py.jinja2 | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/webviz_config/templates/copy_data_template.py.jinja2 b/webviz_config/templates/copy_data_template.py.jinja2 index 8cdda948..78a172d4 100644 --- a/webviz_config/templates/copy_data_template.py.jinja2 +++ b/webviz_config/templates/copy_data_template.py.jinja2 @@ -26,6 +26,16 @@ theme.from_json((Path(__file__).resolve().parent / "theme_settings.json").read_t app = dash.Dash() app.config.suppress_callback_exceptions = True +# Trigger import of plugins used, such that SHARED_SETTINGS_SUBSCRIPTIONS +# is populated before setting webviz_settings +{% for page in pageContents %} +{% for content in page.content %} +{% if content is not string %} +webviz_config.plugins.{{ content._call_signature[0].split('(')[0]}} +{% endif %} +{% endfor %} +{% endfor %} + # Create the common webviz_setting object that will get passed as an # argument to all plugins that request it. webviz_settings: webviz_config.WebvizSettings = webviz_config.WebvizSettings( diff --git a/webviz_config/templates/webviz_template.py.jinja2 b/webviz_config/templates/webviz_template.py.jinja2 index 3a59e150..6bc10e8d 100644 --- a/webviz_config/templates/webviz_template.py.jinja2 +++ b/webviz_config/templates/webviz_template.py.jinja2 @@ -73,6 +73,17 @@ print("Configuring logging from dictionary:", logging_config_dict) logging.config.dictConfig(logging_config_dict) {% endif %} + +# Trigger import of plugins used, such that SHARED_SETTINGS_SUBSCRIPTIONS +# is populated before setting webviz_settings +{% for page in pageContents %} +{% for content in page.content %} +{% if content is not string %} +webviz_config.plugins.{{ content._call_signature[0].split('(')[0]}} +{% endif %} +{% endfor %} +{% endfor %} + # Create the common webviz_setting object that will get passed as an # argument to all plugins that request it. webviz_settings: webviz_config.WebvizSettings = webviz_config.WebvizSettings(