Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Dash version to 2.0 #760

Merged
merged 2 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#755](https://github.com/equinor/webviz-subsurface/pull/755) - Updated existing and added new tests for the Drogon dataset.

### Changed
- [#760](https://github.com/equinor/webviz-subsurface/pull/760) - Updated to `Dash 2.0`.
- [#761](https://github.com/equinor/webviz-subsurface/pull/761) - Store `xtgeo.RegularSurface` as bytestream instead of serializing to `json`.


## [0.2.5] - 2021-09-03
### Added
- [#733](https://github.com/equinor/webviz-subsurface/pull/733) - Added plugin to visualize well logs from files using [videx-welllog](https://github.com/equinor/videx-wellog).
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
],
},
install_requires=[
"dash>=1.20.0",
"dash>=2.0.0",
"dash_bootstrap_components>=0.10.3",
"dash-daq>=0.5.0",
"dataclasses>=0.8; python_version<'3.7'",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json

import dash_html_components as html
from dash.dependencies import Input, Output, State
from dash import html, Input, Output, State
from webviz_config.themes import default_theme
from webviz_config import WebvizSettings

Expand Down
6 changes: 0 additions & 6 deletions tests/integration_tests/test_parameter_filter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import json

import pandas as pd
import dash_html_components as html
from dash.dependencies import Input, Output, State
from webviz_config.themes import default_theme
from webviz_config import WebvizSettings
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these were unused? Strange that pylint haven't captured it before? 🤔


from webviz_subsurface._components.parameter_filter import ParameterFilter

Expand Down
3 changes: 1 addition & 2 deletions tests/integration_tests/test_structural_uncertainty.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json

import dash_html_components as html
from dash.dependencies import Input, Output, State
from dash import html, Input, Output, State
from webviz_config.themes import default_theme
from webviz_config import WebvizSettings

Expand Down
5 changes: 2 additions & 3 deletions tests/integration_tests/test_surface_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pandas as pd
import dash
from dash.dependencies import Input, Output
import dash_html_components as html

from webviz_subsurface._private_plugins.surface_selector import SurfaceSelector

Expand Down Expand Up @@ -40,8 +39,8 @@ def test_surface_selector(dash_duo: dash.testing.composite.DashComposite) -> Non
realizations = pd.read_csv("tests/data/realizations.csv")
surface_selector = SurfaceSelector(app, surface_context, realizations)

app.layout = html.Div(
children=[surface_selector.layout, html.Pre(id="pre", children="ok")]
app.layout = dash.html.Div(
children=[surface_selector.layout, dash.html.Pre(id="pre", children="ok")]
)

@app.callback(
Expand Down
10 changes: 3 additions & 7 deletions webviz_subsurface/_components/color_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@

import numpy as np
import pandas as pd
import dash
from dash.dependencies import Input, Output, State
from dash import html, dcc, dash_table, Dash, Input, Output, State
from dash.exceptions import PreventUpdate
import dash_core_components as dcc
import dash_html_components as html
import dash_table
import dash_daq
import webviz_core_components as wcc

Expand All @@ -20,7 +16,7 @@ class ColorPicker:
a color picker for that row to change the color. The current colors can be
retrieved as a list from a dcc.Store component"""

def __init__(self, app: dash.Dash, uuid: str, dframe: pd.DataFrame) -> None:
def __init__(self, app: Dash, uuid: str, dframe: pd.DataFrame) -> None:
"""
* **`app`:** The Dash app instance.
* **`uuid`:** Unique id (use the plugin id).
Expand Down Expand Up @@ -154,7 +150,7 @@ def color_store_id(self) -> Input:
to get the list of current colors"""
return {"id": self._uuid, "element": "store"}

def _set_callbacks(self, app: dash.Dash) -> None:
def _set_callbacks(self, app: Dash) -> None:
@app.callback(
Output(
{"id": self._uuid, "element": "pickerwrapper"},
Expand Down
9 changes: 3 additions & 6 deletions webviz_subsurface/_components/parameter_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

import numpy as np
import pandas as pd
import dash
from dash.dependencies import Input, Output, State, ALL
from dash import html, dcc, Dash, Input, Output, State, ALL
from dash.exceptions import PreventUpdate
import dash_core_components as dcc
import dash_html_components as html
import webviz_core_components as wcc
import dash_bootstrap_components as dbc
from webviz_config.utils import calculate_slider_step
Expand All @@ -15,7 +12,7 @@
class ParameterFilter:
"""Component that can be added to a plugin to filter parameters"""

def __init__(self, app: dash.Dash, uuid: str, dframe: pd.DataFrame) -> None:
def __init__(self, app: Dash, uuid: str, dframe: pd.DataFrame) -> None:
"""
* **`app`:** The Dash app instance.
* **`uuid`:** Unique id (use the plugin id).
Expand Down Expand Up @@ -197,7 +194,7 @@ def buttons(self) -> html.Div:
],
)

def set_callbacks(self, app: dash.Dash) -> None:
def set_callbacks(self, app: Dash) -> None:
@app.callback(
Output({"id": self._uuid, "type": "data-store"}, "data"),
Input({"id": self._uuid, "type": "button", "element": "apply"}, "n_clicks"),
Expand Down
24 changes: 15 additions & 9 deletions webviz_subsurface/_components/tornado/tornado_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
from pathlib import Path

import pandas as pd
import dash
from dash.dependencies import Input, Output, State, ClientsideFunction
from dash import (
html,
dcc,
callback_context,
Dash,
dash_table,
Input,
Output,
State,
ClientsideFunction,
)
from dash.exceptions import PreventUpdate
import dash_table
import dash_html_components as html
import dash_core_components as dcc
import webviz_core_components as wcc
from webviz_config import WebvizSettings
from webviz_config.webviz_assets import WEBVIZ_ASSETS
Expand Down Expand Up @@ -57,7 +63,7 @@ class TornadoWidget:

def __init__(
self,
app: dash.Dash,
app: Dash,
webviz_settings: WebvizSettings,
realizations: pd.DataFrame,
reference: str = "rms_seed",
Expand Down Expand Up @@ -333,7 +339,7 @@ def layout(self) -> html.Div:
],
)

def set_callbacks(self, app: dash.Dash) -> None:
def set_callbacks(self, app: Dash) -> None:
@app.callback(
Output(self.ids("label"), "disabled"),
Input(self.ids("plot-options"), "value"),
Expand Down Expand Up @@ -451,10 +457,10 @@ def _calc_tornado(
],
)
def _save_click_data(data: dict, nclicks: Optional[int]) -> str:
if dash.callback_context.triggered is None:
if callback_context.triggered is None:
raise PreventUpdate

ctx = dash.callback_context.triggered[0]["prop_id"].split(".")[0]
ctx = callback_context.triggered[0]["prop_id"].split(".")[0]
if ctx == self.ids("reset") and nclicks:

return json.dumps(
Expand Down
15 changes: 6 additions & 9 deletions webviz_subsurface/_private_plugins/surface_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
import yaml
import numpy as np
import pandas as pd
import dash
from dash.dependencies import Input, Output, State
from dash import html, dcc, Dash, callback_context, Input, Output, State
from dash.exceptions import PreventUpdate
import dash_html_components as html
import dash_core_components as dcc


class SurfaceSelector:
Expand Down Expand Up @@ -41,7 +38,7 @@ class SurfaceSelector:
- somedate"""

def __init__(
self, app: dash.Dash, config: Union[str, dict], ensembles: pd.DataFrame
self, app: Dash, config: Union[str, dict], ensembles: pd.DataFrame
) -> None:

self._configuration = self.read_config(config)
Expand Down Expand Up @@ -206,7 +203,7 @@ def layout(self) -> html.Div:
]
)

def set_callbacks(self, app: dash.Dash) -> None:
def set_callbacks(self, app: Dash) -> None:
@app.callback(
Output(self.attr_id, "value"),
[
Expand All @@ -218,7 +215,7 @@ def set_callbacks(self, app: dash.Dash) -> None:
def _update_attr(
_n_prev: Optional[int], _n_next: Optional[int], current_value: str
) -> str:
ctx = dash.callback_context.triggered
ctx = callback_context.triggered
if ctx is None or not current_value:
raise PreventUpdate
if not ctx[0]["value"]:
Expand Down Expand Up @@ -249,7 +246,7 @@ def _update_name(
_n_next: Optional[int],
current_value: str,
) -> Tuple[Optional[List[Dict[str, str]]], Optional[str], Dict[str, str]]:
ctx = dash.callback_context.triggered
ctx = callback_context.triggered
if ctx is None:
raise PreventUpdate
names = self._names_in_attr(attr)
Expand Down Expand Up @@ -285,7 +282,7 @@ def _update_date(
_n_next: Optional[int],
current_value: str,
) -> Tuple[List[Dict[str, str]], Optional[str], Dict[str, str]]:
ctx = dash.callback_context.triggered
ctx = callback_context.triggered

if ctx is None:
raise PreventUpdate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
import pandas as pd
import plotly.express as px
import plotly.graph_objs as go
import dash_table
import dash_html_components as html
import dash_core_components as dcc
import webviz_core_components as wcc
from dash.dependencies import Input, Output
from dash import html, dcc, dash_table, Dash, Input, Output
from dash.exceptions import PreventUpdate
import webviz_core_components as wcc
from webviz_config import WebvizPluginABC
from webviz_config import WebvizSettings
from webviz_config.common_cache import CACHE
Expand Down Expand Up @@ -49,7 +46,7 @@ class AssistedHistoryMatchingAnalysis(WebvizPluginABC):

def __init__(
self,
app,
app: Dash,
webviz_settings: WebvizSettings,
input_dir: Path,
ks_filter: float = 0.0,
Expand Down
8 changes: 3 additions & 5 deletions webviz_subsurface/plugins/_bhp_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import pandas as pd
import numpy as np
import dash
import dash_html_components as html
from dash.dependencies import Input, Output
from dash import html, Dash, Input, Output
import webviz_core_components as wcc
from webviz_config.common_cache import CACHE
from webviz_config import WebvizPluginABC
Expand Down Expand Up @@ -43,7 +41,7 @@ class BhpQc(WebvizPluginABC):

def __init__(
self,
app: dash.Dash,
app: Dash,
webviz_settings: WebvizSettings,
ensembles: list,
wells: Optional[List[str]] = None,
Expand Down Expand Up @@ -213,7 +211,7 @@ def layout(self) -> wcc.FlexBox:
],
)

def set_callbacks(self, app: dash.Dash) -> None:
def set_callbacks(self, app: Dash) -> None:
@app.callback(
Output(self.uuid("graph"), "figure"),
Input(self.uuid("ensemble"), "value"),
Expand Down
2 changes: 1 addition & 1 deletion webviz_subsurface/plugins/_disk_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import datetime

import pandas as pd
import dash_html_components as html
from dash import html
import webviz_core_components as wcc
from webviz_config.webviz_store import webvizstore
from webviz_config.common_cache import CACHE
Expand Down
2 changes: 1 addition & 1 deletion webviz_subsurface/plugins/_history_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import pandas as pd
from scipy.stats import chi2
import dash_html_components as html
from dash import html
import webviz_subsurface_components as wsc
from webviz_config import WebvizPluginABC
from webviz_config import WebvizSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@

import numpy as np
import xtgeo
import dash
import dash_table
from dash.dependencies import Input, Output, State
import dash_html_components as html
import dash_core_components as dcc
from dash import html, dcc, dash_table, Dash, callback_context, Input, Output, State
import dash_bootstrap_components as dbc
import webviz_core_components as wcc
import webviz_subsurface_components
Expand Down Expand Up @@ -49,7 +45,7 @@ class HorizonUncertaintyViewer(WebvizPluginABC):
# pylint: disable=too-many-instance-attributes
def __init__(
self,
app: dash.Dash,
app: Dash,
webviz_settings: WebvizSettings,
basedir: Path,
planned_wells_dir: Path = None,
Expand Down Expand Up @@ -573,7 +569,7 @@ def layout(self) -> dcc.Tabs:
)

# pylint: disable=too-many-statements
def set_callbacks(self, app: dash.Dash) -> None:
def set_callbacks(self, app: Dash) -> None:
@app.callback(
Output(self.ids("layered-map"), "layers"),
[
Expand Down Expand Up @@ -647,7 +643,7 @@ def _render_xsection(
):
"""Renders cross section view from wellfile or polyline drawn in map view"""
_ = n_apply_sfc, n_apply_well
ctx = dash.callback_context
ctx = callback_context
if wellfile in self.wellfiles:
well = self.wells[wellfile]
is_planned = False
Expand Down
12 changes: 4 additions & 8 deletions webviz_subsurface/plugins/_inplace_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

import numpy as np
import pandas as pd
import dash
from dash_table import DataTable
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output
from dash import html, dcc, dash_table, Dash, Input, Output
import webviz_core_components as wcc
from webviz_config.common_cache import CACHE
from webviz_config.webviz_store import webvizstore
Expand Down Expand Up @@ -90,7 +86,7 @@ class InplaceVolumes(WebvizPluginABC):

def __init__(
self,
app: dash.Dash,
app: Dash,
webviz_settings: WebvizSettings,
csvfile: Path = None,
ensembles: list = None,
Expand Down Expand Up @@ -384,7 +380,7 @@ def layout(self) -> html.Div:
style={"textAlign": "center"},
children="",
),
DataTable(
dash_table.DataTable(
id=self.ids("table"),
sort_action="native",
filter_action="native",
Expand All @@ -400,7 +396,7 @@ def layout(self) -> html.Div:
]
)

def set_callbacks(self, app: dash.Dash) -> None:
def set_callbacks(self, app: Dash) -> None:
@app.callback(
[ # type: ignore
Output(self.ids("graph"), "figure"),
Expand Down
Loading