Skip to content

Commit

Permalink
PreventUpdate in download callback if not data_requested
Browse files Browse the repository at this point in the history
  • Loading branch information
asnyv committed Mar 25, 2021
1 parent 4c84bc6 commit c4ae7fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#586](https://github.com/equinor/webviz-subsurface/pull/586) - Added phase ratio vs pressure and density vs pressure plots. Added unit and density functions to PVT library. Refactored code and added checklist for plots to be viewed in PVT plot plugin. Improved the layout.

### Fixed
- [#602](https://github.com/equinor/webviz-subsurface/pull/602) - Prevent calculation of data for download at initialisation of ReservoirSimulationTimeSeries.
- [#592](https://github.com/equinor/webviz-subsurface/pull/592) - Fixed bug for inferred frequency of yearly summary data.
- [#594](https://github.com/equinor/webviz-subsurface/pull/594) - Fixed bug in SurfaceViewerFMU where surfaces with only undefined values was not handled properly.
- [#584](https://github.com/equinor/webviz-subsurface/pull/584) - Fixed bug for in RelativePermeability plugin where it was not possible to plot against oil saturation axis when using relperm data of "family 2".
Expand Down
22 changes: 10 additions & 12 deletions webviz_subsurface/plugins/_reservoir_simulation_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,8 @@ def _user_download_data(
cum_interval: str,
) -> Union[EncodedFile, str]:
"""Callback to download data based on selections"""
if data_requested is None:
raise PreventUpdate

# Combine selected vectors
vectors = [vector1]
Expand Down Expand Up @@ -868,18 +870,14 @@ def _user_download_data(

# : is replaced with _ in filenames to stay within POSIX portable pathnames
# (e.g. : is not valid in a Windows path)
return (
WebvizPluginABC.plugin_data_compress(
[
{
"filename": f"{vector.replace(':', '_')}.csv",
"content": df.get("stat", df["data"]).to_csv(index=False),
}
for vector, df in dfs.items()
]
)
if data_requested
else ""
return WebvizPluginABC.plugin_data_compress(
[
{
"filename": f"{vector.replace(':', '_')}.csv",
"content": df.get("stat", df["data"]).to_csv(index=False),
}
for vector, df in dfs.items()
]
)

@app.callback(
Expand Down

0 comments on commit c4ae7fd

Please sign in to comment.