Skip to content

Commit

Permalink
Add support for content filtering (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
adnejacobsen authored Mar 7, 2024
1 parent bce240a commit 1a5e2c1
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
14 changes: 13 additions & 1 deletion src/fmu/sumo/explorer/objects/_child_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ def vertical_domain(self) -> List[str]:
async def vertical_domain_async(self) -> List[str]:
"""List of unqiue object vertical domain"""
return await self._get_field_values_async("data.vertical_domain")

@property
def contents(self) -> List[str]:
"""List of unique contents"""
return self._get_field_values("data.content.keyword")

@property
async def contents_async(self) -> List[str]:
"""List of unique contents"""
return self._get_field_values_async("data.content.keyword")

def _init_query(self, doc_type: str, query: Dict = None) -> Dict:
new_query = super()._init_query(doc_type, query)
Expand All @@ -133,6 +143,7 @@ def _add_filter(
uuid: Union[str, List[str], bool] = None,
stratigraphic: Union[str, List[str], bool] = None,
vertical_domain: Union[str, List[str], bool] = None,
content: Union[str, List[str], bool] = None,
is_observation: bool = None,
is_prediction: bool = None
):
Expand All @@ -148,7 +159,8 @@ def _add_filter(
"fmu.context.stage.keyword": stage,
"data.spec.columns.keyword": column,
"_id": uuid,
"data.vertical_domain.keyword": vertical_domain
"data.vertical_domain.keyword": vertical_domain,
"data.content.keyword": content
}

for prop, value in prop_map.items():
Expand Down
3 changes: 3 additions & 0 deletions src/fmu/sumo/explorer/objects/cube_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def filter(
uuid: Union[str, List[str], bool] = None,
is_observation: bool = None,
is_prediction: bool = None,
content: Union[str, List[str], bool] = None,
) -> "CubeCollection":
"""Filter cubes
Expand All @@ -147,6 +148,7 @@ def filter(
uuid (Union[str, List[str], bool]): cube object uuid
is_observation (bool): cube is_observation
is_prediction (bool): cube is_prediction
content (Union[str, List[str], bool]): cube content
Returns:
CubeCollection: A filtered CubeCollection
Expand All @@ -161,6 +163,7 @@ def filter(
uuid=uuid,
is_observation=is_observation,
is_prediction=is_prediction,
content=content
)

return CubeCollection(self._sumo, self._case_uuid, query, self._pit)
9 changes: 6 additions & 3 deletions src/fmu/sumo/explorer/objects/dictionary_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ def filter(
aggregation: Union[str, List[str], bool] = None,
stage: Union[str, List[str], bool] = None,
uuid: Union[str, List[str], bool] = None,
content: Union[str, List[str], bool] = None,
) -> "DictionaryCollection":
"""Filter dictionaries
Args:
name (Union[str, List[str], bool]): polygon name
tagname (Union[str, List[str], bool]): polygon tagname
name (Union[str, List[str], bool]): dictionary name
tagname (Union[str, List[str], bool]): dictionary tagname
iteration (Union[int, List[int], bool]): iteration id
realization Union[int, List[int], bool]: realization id
uuid (Union[str, List[str], bool]): polygons object uuid
uuid (Union[str, List[str], bool]): dictionary object uuid
content (Union[str, List[str], bool]): dictionary content
Returns:
DictionaryCollection: A filtered DictionaryCollection
Expand All @@ -63,6 +65,7 @@ def filter(
aggregation=aggregation,
stage=stage,
uuid=uuid,
content=content
)

return DictionaryCollection(
Expand Down
3 changes: 3 additions & 0 deletions src/fmu/sumo/explorer/objects/polygons_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def filter(
iteration: Union[str, List[str], bool] = None,
realization: Union[int, List[int], bool] = None,
uuid: Union[str, List[str], bool] = None,
content: Union[str, List[str], bool] = None,
) -> "PolygonsCollection":
"""Filter polygons
Expand All @@ -49,6 +50,7 @@ def filter(
iteration (Union[int, List[int], bool]): iteration id
realization Union[int, List[int], bool]: realization id
uuid (Union[str, List[str], bool]): polygons object uuid
content (Union[str, List[str], bool]): polygons content
Returns:
PolygonsCollection: A filtered PolygonsCollection
Expand All @@ -59,6 +61,7 @@ def filter(
iteration=iteration,
realization=realization,
uuid=uuid,
content=content
)

return PolygonsCollection(
Expand Down
8 changes: 6 additions & 2 deletions src/fmu/sumo/explorer/objects/surface_collection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing class for collection of surfaces"""

from typing import Union, List, Dict, Tuple
from io import BytesIO
import xtgeo
Expand Down Expand Up @@ -173,8 +174,9 @@ def filter(
stage: Union[str, List[str], bool] = None,
time: TimeFilter = None,
uuid: Union[str, List[str], bool] = None,
content: Union[str, List[str], bool] = None,
is_observation: bool = None,
is_prediction: bool = None
is_prediction: bool = None,
) -> "SurfaceCollection":
"""Filter surfaces
Expand All @@ -191,6 +193,7 @@ def filter(
uuid (Union[str, List[str], bool]): surface object uuid
stratigraphic (Union[str, List[str], bool]): surface stratigraphic
vertical_domain (Union[str, List[str], bool]): surface vertical_domain
content (Union[str, List[str], bool): = surface content
Returns:
SurfaceCollection: A filtered SurfaceCollection
Expand Down Expand Up @@ -241,8 +244,9 @@ def filter(
uuid=uuid,
stratigraphic=stratigraphic,
vertical_domain=vertical_domain,
content=content,
is_observation=is_observation,
is_prediction=is_prediction
is_prediction=is_prediction,
)

return SurfaceCollection(self._sumo, self._case_uuid, query, self._pit)
Expand Down
3 changes: 3 additions & 0 deletions src/fmu/sumo/explorer/objects/table_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def filter(
stage: Union[str, List[str], bool] = None,
column: Union[str, List[str], bool] = None,
uuid: Union[str, List[str], bool] = None,
content: Union[str, List[str], bool] = None,
) -> "TableCollection":
"""Filter tables
Expand All @@ -64,6 +65,7 @@ def filter(
aggregation (Union[str, List[str], bool]): aggregation operation
stage (Union[str, List[str], bool]): context/stage
uuid (Union[str, List[str], bool]): table object uuid
content (Union[str, List[str], bool): table content
Returns:
TableCollection: A filtered TableCollection
Expand All @@ -78,5 +80,6 @@ def filter(
stage=stage,
column=column,
uuid=uuid,
content=content
)
return TableCollection(self._sumo, self._case_uuid, query, self._pit)

0 comments on commit 1a5e2c1

Please sign in to comment.