Skip to content

Commit

Permalink
Add a beta label
Browse files Browse the repository at this point in the history
  • Loading branch information
frode-aarstad committed Jul 8, 2022
1 parent 35009d0 commit e497662
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 57 deletions.
9 changes: 7 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion tests/views/test_observation_view.py
Original file line number Diff line number Diff line change
@@ -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,
)


Expand Down Expand Up @@ -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
10 changes: 8 additions & 2 deletions tests/views/test_parameter_selector.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import dash
import webviz_ert
import pytest

from selenium.webdriver.common.keys import Keys
from webviz_ert.plugins import ParameterComparison
Expand Down Expand Up @@ -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
9 changes: 8 additions & 1 deletion tests/views/test_plot_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dash
import pytest
from webviz_ert.plugins._response_comparison import ResponseComparison
from tests.conftest import (
setup_plugin,
Expand Down Expand Up @@ -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
9 changes: 8 additions & 1 deletion tests/views/test_response_correlation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dash
import pytest
from webviz_ert.plugins._response_correlation import ResponseCorrelation
from tests.conftest import (
setup_plugin,
Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions webviz_ert/assets/ert-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions webviz_ert/assets/webviz-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ pages:
- title: Response Correlation Viewer
content:
- ResponseCorrelation:
beta: True
experimental: False
31 changes: 21 additions & 10 deletions webviz_ert/plugins/_observation_analyzer.py
Original file line number Diff line number Diff line change
@@ -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),
),
Expand Down
33 changes: 22 additions & 11 deletions webviz_ert/plugins/_parameter_comparison.py
Original file line number Diff line number Diff line change
@@ -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
),
Expand Down
35 changes: 23 additions & 12 deletions webviz_ert/plugins/_response_comparison.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
Expand Down
Loading

0 comments on commit e497662

Please sign in to comment.