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

Adjust naming according to new property names after splitting GroupTree-component view/settings #1248

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: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"vtk>=9.2.2,<9.3",
"webviz-config",
"webviz-core-components>=0.6",
"webviz-subsurface-components==1.0.1",
"webviz-subsurface-components==1.0.2",
],
extras_require={"tests": TESTS_REQUIRE},
setup_requires=["setuptools_scm~=3.2"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ def create_grouptree_dataset(
grouptree data, before the filtered data is sent to the function that is
actually creating the dataset.

Returns the group tree data and two lists with dropdown options for what
to display on the edges and nodes.
Returns the group tree data and two lists with metadata for edges and nodes
in the tree data structure

A sample data set can be found here:
# pylint: disable=line-too-long
https://github.com/equinor/webviz-subsurface-components/blob/master/react/src/demo/example-data/group-tree.json
""" # noqa

Expand Down Expand Up @@ -130,13 +131,16 @@ def create_grouptree_dataset(
dfs.append(gruptree_filtered[gruptree_filtered[f"IS_{tpe.value}".upper()]])
gruptree_filtered = pd.concat(dfs).drop_duplicates()

# Metadata for node: {key: str, label: str, unit: Optional[str]}
# The "key" correspond to the key for node data in the tree data set.
node_metadata_list = [
{"key": datatype, "label": get_label(datatype)}
for datatype in [DataType.PRESSURE, DataType.BHP, DataType.WMCTL]
]
return (
create_dataset(smry, gruptree_filtered, self._sumvecs, self._terminal_node),
self.get_edge_options(node_types),
[
{"name": datatype, "label": get_label(datatype)}
for datatype in [DataType.PRESSURE, DataType.BHP, DataType.WMCTL]
],
self.create_edge_metadata_list(node_types),
node_metadata_list,
)

@CACHE.memoize()
Expand Down Expand Up @@ -217,32 +221,37 @@ def _check_that_sumvecs_exists(self, check_sumvecs: List[str]) -> None:
)

@CACHE.memoize()
def get_edge_options(self, node_types: List[NodeType]) -> List[Dict[str, str]]:
"""Returns a list with edge node options for the dropdown
menu in the GroupTree component. The output list has the format:
def create_edge_metadata_list(
self, node_types: List[NodeType]
) -> List[Dict[str, str]]:
"""Creates a list with edge metadata for both dropdowns and tree data
in the GroupTree component. The "key" correspond to the key for edge data
in the tree data set.

The output list has the format:
[
{"name": DataType.OILRATE, "label": "Oil Rate"},
{"name": DataType.GasRATE, "label": "Gas Rate"},
{"key": DataType.OILRATE, "label": "Oil Rate", "unit": "m3/d"},
{"key": DataType.GasRATE, "label": "Gas Rate", "unit": "m3/d"},
]
"""
options = []
if NodeType.PROD in node_types:
for rate in [DataType.OILRATE, DataType.GASRATE, DataType.WATERRATE]:
options.append({"name": rate, "label": get_label(rate)})
options.append({"key": rate, "label": get_label(rate)})
if NodeType.INJ in node_types and self._has_waterinj:
options.append(
{
"name": DataType.WATERINJRATE,
"key": DataType.WATERINJRATE,
"label": get_label(DataType.WATERINJRATE),
}
)
if NodeType.INJ in node_types and self._has_gasinj:
options.append(
{"name": DataType.GASINJRATE, "label": get_label(DataType.GASINJRATE)}
{"key": DataType.GASINJRATE, "label": get_label(DataType.GASINJRATE)}
)
if options:
return options
return [{"name": DataType.OILRATE, "label": get_label(DataType.OILRATE)}]
return [{"key": DataType.OILRATE, "label": get_label(DataType.OILRATE)}]


def get_edge_label(row: pd.Series) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def _render_grouptree(
ensemble_name: str,
) -> list:
"""This callback updates the input dataset to the Grouptree component."""
data, edge_options, node_options = self._group_tree_data[
data, edge_metadata_list, node_metadata_list = self._group_tree_data[
ensemble_name
].create_grouptree_dataset(
tree_mode,
Expand All @@ -312,8 +312,8 @@ def _render_grouptree(
wsc.GroupTree(
id=self._group_tree_component_id,
data=data,
edge_options=edge_options,
node_options=node_options,
edge_metadata_list=edge_metadata_list,
node_metadata_list=node_metadata_list,
),
]

Expand Down
Loading