Skip to content

Commit

Permalink
Support Dash 1.11 (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kallekleiv authored Apr 28, 2020
1 parent 843bda0 commit 2c1f1c5
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 29 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
]
},
install_requires=[
"dash<=1.10", # https://github.com/equinor/webviz-subsurface/issues/317
"fmu-ensemble>=1.2.2",
"matplotlib>=3.0",
"pandas>=0.24",
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/test_aggregated_data_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def test_basic_example(dash_duo, tmp_path):
not in log["message"]
]
if logs != []:
raise AssertionError(logs)
raise AssertionError(page, logs)
2 changes: 1 addition & 1 deletion tests/integration_tests/test_raw_data_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ def test_full_example(dash_duo, tmp_path):
]

if logs != []:
raise AssertionError(logs)
raise AssertionError(page, logs)
2 changes: 1 addition & 1 deletion tests/integration_tests/test_surface_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_surface_selector(dash_duo):

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

@app.callback(Output("pre", "children"), [Input(s.storage_id, "children")])
@app.callback(Output("pre", "children"), [Input(s.storage_id, "data")])
def _test(data):
return json.dumps(json.loads(data))

Expand Down
8 changes: 4 additions & 4 deletions webviz_subsurface/_private_plugins/surface_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def set_callbacks(self, app):
)
def _update_attr(_n_prev, _n_next, current_value):
ctx = dash.callback_context.triggered
if not ctx or not current_value:
if ctx is None or not current_value:
raise PreventUpdate
if not ctx[0]["value"]:
return current_value
Expand All @@ -226,7 +226,7 @@ def _update_attr(_n_prev, _n_next, current_value):
)
def _update_name(attr, _n_prev, _n_next, current_value):
ctx = dash.callback_context.triggered
if not ctx:
if ctx is None:
raise PreventUpdate
names = self._names_in_attr(attr)
if not names:
Expand Down Expand Up @@ -258,7 +258,7 @@ def _update_name(attr, _n_prev, _n_next, current_value):
def _update_date(attr, _n_prev, _n_next, current_value):
ctx = dash.callback_context.triggered

if not ctx:
if ctx is None:
raise PreventUpdate
dates = self._dates_in_attr(attr)

Expand All @@ -276,7 +276,7 @@ def _update_date(attr, _n_prev, _n_next, current_value):
return options, value, {}

@app.callback(
Output(self.storage_id, "children"),
Output(self.storage_id, "data"),
[
Input(self.attr_id, "value"),
Input(self.name_id, "value"),
Expand Down
6 changes: 3 additions & 3 deletions webviz_subsurface/_private_plugins/tornado_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def set_callbacks(self, app):
Input(self.ids("reference"), "value"),
Input(self.ids("scale"), "value"),
Input(self.ids("cut-by-ref"), "value"),
Input(self.ids("storage"), "children"),
Input(self.ids("storage"), "data"),
],
)
def _calc_tornado(reference, scale, cutbyref, data):
Expand Down Expand Up @@ -240,14 +240,14 @@ def _calc_tornado(reference, scale, cutbyref, data):
if self.allow_click:

@app.callback(
Output(self.ids("click-store"), "children"),
Output(self.ids("click-store"), "data"),
[
Input(self.ids("tornado-graph"), "clickData"),
Input(self.ids("reset"), "n_clicks"),
],
)
def _save_click_data(data, nclicks):
if not dash.callback_context.triggered:
if dash.callback_context.triggered is None:
raise PreventUpdate

ctx = dash.callback_context.triggered[0]["prop_id"].split(".")[0]
Expand Down
4 changes: 2 additions & 2 deletions webviz_subsurface/plugins/_inplace_volumes_onebyone.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def set_callbacks(self, app):
@app.callback(
[
Output(self.ids("graph-wrapper"), "children"),
Output(self.tornadoplot.storage_id, "children"),
Output(self.tornadoplot.storage_id, "data"),
Output(self.ids("table"), "data"),
Output(self.ids("table"), "columns"),
],
Expand Down Expand Up @@ -517,7 +517,7 @@ def _render_vol_chart(plot_type, ensemble, response, source, *filters):

@app.callback(
Output(self.ids("graph"), "figure"),
[Input(self.tornadoplot.click_id, "children")],
[Input(self.tornadoplot.click_id, "data")],
[State(self.ids("plot-type"), "value"), State(self.ids("graph"), "figure")],
)
def _color_chart(hoverdata, plot_type, figure):
Expand Down
4 changes: 3 additions & 1 deletion webviz_subsurface/plugins/_parameter_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,15 @@ def set_callbacks(self, app):
def _set_parameter_from_btn(_prev_click, _next_click, column):

ctx = dash.callback_context.triggered
if not ctx:
if ctx is None:
raise PreventUpdate
callback = ctx[0]["prop_id"]
if callback == f"{self.ids('prev-btn')}.n_clicks":
column = prev_value(column, self.parameter_columns)
elif callback == f"{self.ids('next-btn')}.n_clicks":
column = next_value(column, self.parameter_columns)
else:
column = self.parameter_columns[0]
return column

@app.callback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def set_callbacks(self, app):
# Output(self.ids("date-store"), "children"),
Output(self.ids("table"), "data"),
Output(self.ids("table"), "columns"),
Output(self.tornadoplot.storage_id, "children"),
Output(self.tornadoplot.storage_id, "data"),
],
[
Input(self.ids("ensemble"), "value"),
Expand Down Expand Up @@ -350,7 +350,7 @@ def _render_date(ensemble, clickdata, vector):
@app.callback(
Output(self.ids("graph"), "figure"),
[
Input(self.tornadoplot.click_id, "children"),
Input(self.tornadoplot.click_id, "data"),
# Input(self.ids("date-store"), "children"),
Input(self.ids("ensemble"), "value"),
Input(self.ids("vector"), "value"),
Expand All @@ -360,12 +360,12 @@ def _render_date(ensemble, clickdata, vector):
)
def _render_tornado(tornado_click, ensemble, vector, date_click, figure):
"""Update graph with line coloring, vertical line and title"""
if not dash.callback_context.triggered:
if dash.callback_context.triggered is None:
raise PreventUpdate
ctx = dash.callback_context.triggered[0]["prop_id"].split(".")[0]

# Redraw figure if ensemble/vector hanges
if ctx == self.ids("ensemble") or ctx == self.ids("vector"):
# Draw initial figure and redraw if ensemble/vector changes
if ctx in ["", self.ids("ensemble"), self.ids("vector")]:
layout = {}
layout.update(self.plotly_theme["layout"])
data = filter_ensemble(self.data, ensemble, vector)
Expand Down
6 changes: 0 additions & 6 deletions webviz_subsurface/plugins/_running_time_analysis_fmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,6 @@ def _update_fig(ens, mode, rel_runtime, rel_real, params, filter_short):
[
Output(self.uuid("matrix_color"), "style"),
Output(self.uuid("parcoords_color"), "style"),
Output(self.uuid("matrix_heatmap"), "style"),
Output(self.uuid("parcoords"), "style"),
Output(self.uuid("parameter_dropdown"), "style"),
Output(self.uuid("filter_short_checkbox"), "style"),
],
Expand All @@ -350,15 +348,11 @@ def _update_mode(mode):
style = (
{"display": "block"},
{"display": "none"},
{"display": "block", "overflowX": "auto"},
{"display": "none"},
{"display": "none"},
{"display": "block"},
)
else:
style = (
{"display": "none"},
{"display": "block"},
{"display": "none"},
{"display": "block"},
{"display": "block"},
Expand Down
4 changes: 2 additions & 2 deletions webviz_subsurface/plugins/_surface_viewer_fmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,10 @@ def set_callbacks(self, app):
Output(self.uuid("map3-label"), "children"),
],
[
Input(self.selector.storage_id, "children"),
Input(self.selector.storage_id, "data"),
Input(self.uuid("ensemble"), "value"),
Input(self.uuid("realization"), "value"),
Input(self.selector2.storage_id, "children"),
Input(self.selector2.storage_id, "data"),
Input(self.uuid("ensemble2"), "value"),
Input(self.uuid("realization2"), "value"),
Input(self.uuid("calculation"), "value"),
Expand Down
9 changes: 7 additions & 2 deletions webviz_subsurface/plugins/_well_cross_section_fmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ def seismic_layout(self):
]
),
)
return html.Div(id=self.ids("cube"))
return html.Div(
style={"visibility": "hidden"}, children=dcc.Dropdown(id=self.ids("cube"))
)

@property
def marginal_log_layout(self):
Expand All @@ -247,7 +249,10 @@ def marginal_log_layout(self):
]
),
)
return html.Div(id=self.ids("marginal-log"))
return html.Div(
style={"visibility": "hidden"},
children=dcc.Dropdown(id=self.ids("marginal-log")),
)

@property
def intersection_option(self):
Expand Down

0 comments on commit 2c1f1c5

Please sign in to comment.