Skip to content

Commit

Permalink
Use simplified import statements
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv committed Sep 10, 2021
1 parent 92c234b commit b5e91a1
Show file tree
Hide file tree
Showing 76 changed files with 185 additions and 257 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json

import dash_html_components as html
from dash import html
from dash.dependencies import 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

from webviz_subsurface._components.parameter_filter import ParameterFilter

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

import dash_html_components as html
from dash import html
from dash.dependencies import 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
9 changes: 3 additions & 6 deletions webviz_subsurface/_components/color_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@

import numpy as np
import pandas as pd
import dash
from dash import html, dcc, dash_table, Dash
from dash.dependencies import 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 +17,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 +151,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
8 changes: 3 additions & 5 deletions webviz_subsurface/_components/parameter_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import numpy as np
import pandas as pd
import dash
from dash import html, dcc, Dash
from dash.dependencies import 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 +13,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 +195,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
13 changes: 5 additions & 8 deletions webviz_subsurface/_components/tornado/tornado_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
from pathlib import Path

import pandas as pd
import dash
from dash import html, dcc, callback_context, Dash
from dash.dependencies import 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 +54,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 +330,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 +448,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
14 changes: 6 additions & 8 deletions webviz_subsurface/_private_plugins/surface_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
import yaml
import numpy as np
import pandas as pd
import dash
from dash import html, dcc, Dash, callback_context
from dash.dependencies import 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 +39,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 +204,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 +216,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 +247,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 +283,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,9 +5,7 @@
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
from dash import html, dcc, dash_table, Dash
import webviz_core_components as wcc
from dash.dependencies import Input, Output
from dash.exceptions import PreventUpdate
Expand Down Expand Up @@ -49,7 +47,7 @@ class AssistedHistoryMatchingAnalysis(WebvizPluginABC):

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

import pandas as pd
import numpy as np
import dash
import dash_html_components as html
from dash import html, Dash
from dash.dependencies import Input, Output
import webviz_core_components as wcc
from webviz_config.common_cache import CACHE
Expand Down Expand Up @@ -43,7 +42,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 +212,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,8 @@

import numpy as np
import xtgeo
import dash
import dash_table
from dash import html, dcc, dash_table, Dash, callback_context
from dash.dependencies import Input, Output, State
import dash_html_components as html
import dash_core_components as dcc
import dash_bootstrap_components as dbc
import webviz_core_components as wcc
import webviz_subsurface_components
Expand Down Expand Up @@ -49,7 +46,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 +570,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 +644,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
11 changes: 4 additions & 7 deletions webviz_subsurface/plugins/_inplace_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +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 import html, dcc, dash_table, Dash
from dash.dependencies import Input, Output
import webviz_core_components as wcc
from webviz_config.common_cache import CACHE
Expand Down Expand Up @@ -90,7 +87,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 +381,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 +397,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

0 comments on commit b5e91a1

Please sign in to comment.