From e497662dccc83694a6c72b1d5440608a1ad19029 Mon Sep 17 00:00:00 2001 From: Frode Aarstad Date: Thu, 7 Jul 2022 14:54:19 +0200 Subject: [PATCH] Add a beta label --- tests/conftest.py | 9 +++- tests/views/test_observation_view.py | 10 ++++- tests/views/test_parameter_selector.py | 10 ++++- tests/views/test_plot_view.py | 9 +++- tests/views/test_response_correlation.py | 9 +++- webviz_ert/assets/ert-style.css | 6 +++ webviz_ert/assets/webviz-config.yml | 1 + webviz_ert/plugins/_observation_analyzer.py | 31 +++++++++----- webviz_ert/plugins/_parameter_comparison.py | 33 ++++++++++----- webviz_ert/plugins/_response_comparison.py | 35 ++++++++++------ webviz_ert/plugins/_response_correlation.py | 46 +++++++++++++-------- 11 files changed, 142 insertions(+), 57 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index cc78a646..4da2f2f5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -101,10 +101,15 @@ def get_options(dash_duo, selector): def setup_plugin( - dash_duo, name, plugin_class, window_size=(630, 2000), project_identifier=None + dash_duo, + name, + plugin_class, + window_size=(630, 2000), + project_identifier=None, + beta: bool = False, ): app = dash.Dash(name) - plugin = plugin_class(app, project_identifier=project_identifier) + plugin = plugin_class(app, project_identifier=project_identifier, beta=beta) layout = plugin.layout app.layout = layout dash_duo.start_server(app) diff --git a/tests/views/test_observation_view.py b/tests/views/test_observation_view.py index 7ded5d72..89b0947a 100644 --- a/tests/views/test_observation_view.py +++ b/tests/views/test_observation_view.py @@ -1,11 +1,12 @@ import dash - +import pytest from webviz_ert.plugins import ObservationAnalyzer from tests.conftest import ( select_first, get_options, select_by_name, verify_key_in_dropdown, + setup_plugin, ) @@ -69,3 +70,10 @@ def test_observation_analyzer_view_ensemble_with_observations( verify_key_in_dropdown(dash_duo, plugin.uuid("response-selector"), "FOPR") # assert dash_duo.get_logs() == [], "browser console should contain no error" + + +@pytest.mark.parametrize("input", [True, False]) +def test_displaying_beta_warning(input: bool, dash_duo): + plugin = setup_plugin(dash_duo, __name__, ObservationAnalyzer, beta=input) + beta_warning_element = dash_duo.find_element("#" + plugin.uuid("beta-warning")) + assert beta_warning_element.is_displayed() == input diff --git a/tests/views/test_parameter_selector.py b/tests/views/test_parameter_selector.py index 6eee6fbc..7721e948 100644 --- a/tests/views/test_parameter_selector.py +++ b/tests/views/test_parameter_selector.py @@ -1,5 +1,4 @@ -import dash -import webviz_ert +import pytest from selenium.webdriver.common.keys import Keys from webviz_ert.plugins import ParameterComparison @@ -158,3 +157,10 @@ def test_parameter_selector_sorting( assert parameter_list[2] == "test_parameter_2::a" assert parameter_list[3] == "test_parameter_2::b" assert parameter_list[4] == "test_parameter_77" + + +@pytest.mark.parametrize("input", [True, False]) +def test_displaying_beta_warning(input: bool, dash_duo): + plugin = setup_plugin(dash_duo, __name__, ParameterComparison, beta=input) + beta_warning_element = dash_duo.find_element("#" + plugin.uuid("beta-warning")) + assert beta_warning_element.is_displayed() == input diff --git a/tests/views/test_plot_view.py b/tests/views/test_plot_view.py index 4d241dbd..59f33420 100644 --- a/tests/views/test_plot_view.py +++ b/tests/views/test_plot_view.py @@ -1,4 +1,4 @@ -import dash +import pytest from webviz_ert.plugins._response_comparison import ResponseComparison from tests.conftest import ( setup_plugin, @@ -148,3 +148,10 @@ def test_axis_labels(mock_data, dash_duo): assert x_axis_title_index.text == "Index" # assert dash_duo.get_logs() == [], "browser console should contain no error" + + +@pytest.mark.parametrize("input", [True, False]) +def test_displaying_beta_warning(input: bool, dash_duo): + plugin = setup_plugin(dash_duo, __name__, ResponseComparison, beta=input) + beta_warning_element = dash_duo.find_element("#" + plugin.uuid("beta-warning")) + assert beta_warning_element.is_displayed() == input diff --git a/tests/views/test_response_correlation.py b/tests/views/test_response_correlation.py index 0649701d..65cd29a7 100644 --- a/tests/views/test_response_correlation.py +++ b/tests/views/test_response_correlation.py @@ -1,4 +1,4 @@ -import dash +import pytest from webviz_ert.plugins._response_correlation import ResponseCorrelation from tests.conftest import ( setup_plugin, @@ -102,3 +102,10 @@ def test_axes_labels(mock_data, dash_duo): dash_duo.wait_for_contains_text(f"#{response_selector_id}", wanted_response) # assert dash_duo.get_logs() == [], "browser console should contain no error" + + +@pytest.mark.parametrize("input", [True, False]) +def test_displaying_beta_warning(input: bool, dash_duo): + plugin = setup_plugin(dash_duo, __name__, ResponseCorrelation, beta=input) + beta_warning_element = dash_duo.find_element("#" + plugin.uuid("beta-warning")) + assert beta_warning_element.is_displayed() == input diff --git a/webviz_ert/assets/ert-style.css b/webviz_ert/assets/ert-style.css index 6a5cef80..b73e2712 100644 --- a/webviz_ert/assets/ert-style.css +++ b/webviz_ert/assets/ert-style.css @@ -30,6 +30,12 @@ padding-top: 10px; padding-bottom: 10px; } +.ert-beta-warning { + color: #664d03; + background-color: #fff3cd; + border-color: #ffecb5; + padding: 1rem 1rem; +} .selected-ensemble-dropdown> div > div >div.Select-value:nth-child(5n-4) { background-color: rgba(56,108,176,0.8); diff --git a/webviz_ert/assets/webviz-config.yml b/webviz_ert/assets/webviz-config.yml index 50f678b0..4d817cad 100644 --- a/webviz_ert/assets/webviz-config.yml +++ b/webviz_ert/assets/webviz-config.yml @@ -18,4 +18,5 @@ pages: - title: Response Correlation Viewer content: - ResponseCorrelation: + beta: True experimental: False diff --git a/webviz_ert/plugins/_observation_analyzer.py b/webviz_ert/plugins/_observation_analyzer.py index 50b47505..22ad3c4c 100644 --- a/webviz_ert/plugins/_observation_analyzer.py +++ b/webviz_ert/plugins/_observation_analyzer.py @@ -1,30 +1,41 @@ import dash +import webviz_ert.models +import webviz_ert.controllers from dash.development.base_component import Component from typing import List, Dict -from dash import html - -import webviz_ert.models - from webviz_ert.views import ensemble_selector_list, response_obs_view - from webviz_ert.plugins import WebvizErtPluginABC -import webviz_ert.controllers class ObservationAnalyzer(WebvizErtPluginABC): - def __init__(self, app: dash.Dash, project_identifier: str): + def __init__(self, app: dash.Dash, project_identifier: str, beta: bool = False): super().__init__(app, project_identifier) self.set_callbacks(app) + self.beta = beta @property def layout(self) -> Component: - return html.Div( + return dash.html.Div( [ - html.Div( + dash.html.Div( + children=[ + dash.html.P( + [ + "This page is considered a ", + dash.html.B("beta"), + " version and could be changed or removed. You are encouraged to use it and give feedback to us regarding functionality and / or bugs.", + ], + className="ert-beta-warning", + id=self.uuid("beta-warning"), + ) + ], + hidden=not self.beta, + ), + dash.html.Div( id=self.uuid("ensemble-content"), children=ensemble_selector_list(parent=self), ), - html.Div( + dash.html.Div( id=self.uuid("plotting-content"), children=response_obs_view(parent=self), ), diff --git a/webviz_ert/plugins/_parameter_comparison.py b/webviz_ert/plugins/_parameter_comparison.py index cfa4e370..8883ad16 100644 --- a/webviz_ert/plugins/_parameter_comparison.py +++ b/webviz_ert/plugins/_parameter_comparison.py @@ -1,38 +1,49 @@ import dash +import webviz_ert.controllers +import webviz_ert.models from dash.development.base_component import Component from typing import List, Dict -from dash import html - -import webviz_ert.models - from webviz_ert.views import ( ensemble_selector_list, parallel_coordinates_view, parameter_selector_view, ) - -import webviz_ert.controllers from webviz_ert.plugins import WebvizErtPluginABC from webviz_ert.models.data_model import DataType class ParameterComparison(WebvizErtPluginABC): - def __init__(self, app: dash.Dash, project_identifier: str): + def __init__(self, app: dash.Dash, project_identifier: str, beta: bool = False): super().__init__(app, project_identifier) self.set_callbacks(app) + self.beta = beta @property def layout(self) -> Component: - return html.Div( + return dash.html.Div( [ - html.Div( + dash.html.Div( + children=[ + dash.html.P( + [ + "This page is considered a ", + dash.html.B("beta"), + " version and could be changed or removed. You are encouraged to use it and give feedback to us regarding functionality and / or bugs.", + ], + className="ert-beta-warning", + id=self.uuid("beta-warning"), + ) + ], + hidden=not self.beta, + ), + dash.html.Div( id=self.uuid("ensemble-content"), children=ensemble_selector_list(parent=self), ), - html.Div( + dash.html.Div( id=self.uuid("parallel-coor-content"), children=[ - html.H5("Multi parameter selector:"), + dash.html.H5("Multi parameter selector:"), parameter_selector_view( parent=self, data_type=DataType.PARAMETER ), diff --git a/webviz_ert/plugins/_response_comparison.py b/webviz_ert/plugins/_response_comparison.py index 105a9fed..86d5bb0b 100644 --- a/webviz_ert/plugins/_response_comparison.py +++ b/webviz_ert/plugins/_response_comparison.py @@ -1,42 +1,53 @@ import dash +import webviz_ert.controllers +import webviz_ert.models from dash.development.base_component import Component from typing import List, Dict - -import webviz_ert.models -from dash import html - from webviz_ert.views import ( ensemble_selector_list, plot_view_body, plot_view_header, plot_view_menu, ) - -import webviz_ert.controllers from webviz_ert.models.data_model import DataType from webviz_ert.plugins import WebvizErtPluginABC class ResponseComparison(WebvizErtPluginABC): - def __init__(self, app: dash.Dash, project_identifier: str): + def __init__(self, app: dash.Dash, project_identifier: str, beta: bool = False): super().__init__(app, project_identifier) self.set_callbacks(app) + self.beta = beta @property def layout(self) -> Component: - return html.Div( + return dash.html.Div( [ - html.Div( + dash.html.Div( + children=[ + dash.html.P( + [ + "This page is considered a ", + dash.html.B("beta"), + " version and could be changed or removed. You are encouraged to use it and give feedback to us regarding functionality and / or bugs.", + ], + className="ert-beta-warning", + id=self.uuid("beta-warning"), + ) + ], + hidden=not self.beta, + ), + dash.html.Div( id=self.uuid("ensemble-content"), children=ensemble_selector_list(parent=self), ), - html.Div( + dash.html.Div( children=plot_view_header(parent=self), ), - html.Div( + dash.html.Div( children=plot_view_body(parent=self), ), - html.Div( + dash.html.Div( children=plot_view_menu(parent=self), ), ] diff --git a/webviz_ert/plugins/_response_correlation.py b/webviz_ert/plugins/_response_correlation.py index 5347957a..e8a553eb 100644 --- a/webviz_ert/plugins/_response_correlation.py +++ b/webviz_ert/plugins/_response_correlation.py @@ -1,26 +1,24 @@ import dash +import webviz_ert.assets as assets +import webviz_ert.models +import webviz_ert.controllers +import dash_bootstrap_components as dbc from dash.development.base_component import Component from typing import List, Dict - -from dash import html -from dash import dcc -import dash_bootstrap_components as dbc from webviz_ert.views import ( ensemble_selector_list, correlation_view, parameter_selector_view, ) -import webviz_ert.assets as assets -import webviz_ert.models from webviz_ert.models.data_model import DataType from webviz_ert.plugins import WebvizErtPluginABC -import webviz_ert.controllers class ResponseCorrelation(WebvizErtPluginABC): - def __init__(self, app: dash.Dash, project_identifier: str): + def __init__(self, app: dash.Dash, project_identifier: str, beta: bool = False): super().__init__(app, project_identifier) self.set_callbacks(app) + self.beta = beta @property def tour_steps(self) -> List[Dict[str, str]]: @@ -75,13 +73,27 @@ def tour_steps(self) -> List[Dict[str, str]]: @property def layout(self) -> Component: - return html.Div( + return dash.html.Div( [ - dcc.Store( + dash.html.Div( + children=[ + dash.html.P( + [ + "This page is considered a ", + dash.html.B("beta"), + " version and could be changed or removed. You are encouraged to use it and give feedback to us regarding functionality and / or bugs.", + ], + className="ert-beta-warning", + id=self.uuid("beta-warning"), + ) + ], + hidden=not self.beta, + ), + dash.dcc.Store( id=self.uuid("correlation-store-xindex"), data={}, ), - dcc.Store( + dash.dcc.Store( id=self.uuid("correlation-store-selection"), data=self.load_state( "active_correlation", @@ -89,7 +101,7 @@ def layout(self) -> Component: ), storage_type="session", ), - html.Div( + dash.html.Div( id=self.uuid("ensemble-content"), children=ensemble_selector_list(parent=self), ), @@ -97,7 +109,7 @@ def layout(self) -> Component: [ dbc.Col( [ - html.Label("Responses", className="ert-label"), + dash.html.Label("Responses", className="ert-label"), parameter_selector_view( self, data_type=DataType.RESPONSE ), @@ -106,7 +118,7 @@ def layout(self) -> Component: ), dbc.Col( [ - html.Label("Parameters", className="ert-label"), + dash.html.Label("Parameters", className="ert-label"), parameter_selector_view( self, data_type=DataType.PARAMETER ), @@ -115,7 +127,7 @@ def layout(self) -> Component: ), ], ), - dcc.RadioItems( + dash.dcc.RadioItems( id=self.uuid("correlation-metric"), options=[ {"label": "spearman", "value": "spearman"}, @@ -156,10 +168,10 @@ def layout(self) -> Component: ), ] ), - html.Div( + dash.html.Div( id=self.uuid("response-info-text"), className="ert-label", - children=[dcc.Markdown("INFO")], + children=[dash.dcc.Markdown("INFO")], ), ] )