diff --git a/webviz_config/templates/webviz_template.py.jinja2 b/webviz_config/templates/webviz_template.py.jinja2 index 32f994f7..1e256fea 100644 --- a/webviz_config/templates/webviz_template.py.jinja2 +++ b/webviz_config/templates/webviz_template.py.jinja2 @@ -72,37 +72,46 @@ WEBVIZ_STORAGE.storage_folder = path.join(path.dirname(path.realpath(__file__)), WEBVIZ_ASSETS.portable = {{ portable }} {{ 'WEBVIZ_ASSETS.register_app(app)' if not portable else ''}} -app.layout = dcc.Tabs(parent_className="layoutWrapper", - content_className='pageWrapper', - vertical=True, children=[ - {% for page in pages %} - dcc.Tab( - {%- if loop.first -%} - id='logo', - className='styledLogo', - {%- else -%} - {%- if loop.last -%} - id='last_page', - {%- else -%} - id='{{page.id}}', - {%- endif -%} - label='{{page.title}}', - selected_className='selectedButton', - className='styledButton', - {%- endif -%} - children=[ - {% for content in page.content -%} - {%- if content is string -%} +if {{ not portable }} and not webviz_config.is_reload_process(): + # When Dash/Flask is started on localhost with hot module reload activated, + # we do not want the main process to call expensive component functions in + # the layout tree, as the layout tree used on initialization will anyway be called + # from the child/restart/reload process. + app.layout = html.Div() +else: + app.layout = dcc.Tabs( + parent_className="layoutWrapper", + content_className='pageWrapper', + vertical=True, + children=[ + {% for page in pages %} + dcc.Tab( + {%- if loop.first -%} + id='logo', + className='styledLogo', + {%- else -%} + {%- if loop.last -%} + id='last_page', + {%- else -%} + id='{{page.id}}', + {%- endif -%} + label='{{page.title}}', + selected_className='selectedButton', + className='styledButton', + {%- endif -%} + children=[ + {% for content in page.content -%} + {%- if content is string -%} dcc.Markdown(r'''{{ content }}''') - {%- else -%} + {%- else -%} {{ content._call_signature[0] }}.{{ content._call_signature[1] }} - {%- endif -%} - {{- '' if loop.last else ','}} - {% endfor -%} - ] - ){{- '' if loop.last else ',' -}} - {% endfor %}] -) + {%- endif -%} + {{- '' if loop.last else ','}} + {% endfor -%} + ] + ){{- '' if loop.last else ',' -}} + {% endfor %}] + ) if __name__ == '__main__': # This part is ignored when the webviz app is started