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

Enable filter on data.format #309

Merged
merged 4 commits into from
Mar 25, 2024
Merged

Conversation

perolavsvendsen
Copy link
Member

@perolavsvendsen perolavsvendsen commented Mar 23, 2024

Issue

#304

Short description

  • Add dataformat to the filter options, so that filtering is possible on data.format.
  • Add .dataformat property on the Child class, change .format into alias for .dataformat

_We may consider deprecating .format at some point, to avoid guiding people into overwriting built-in format.

This may work as a mitigation for equinor/fmu-dataio#492. However, note:

  • Require data consumers to actively filter on supported formats ⚠️

An alternative would be to default to data.format="irap_binary" in the explorer, but this does not feel right.

Extra: Also improved testing of some other filters (assert that no results come back when filtering on non-existing value)

Pre-review checklist

  • Read through all changes. No redundant print() statements, commented-out code, or other remnants from the development. 👀
  • Make sure tests pass after every commit. ✅
  • New/refactored code is following same conventions as the rest of the code base. 🧬
  • New/refactored code is tested. ⚙
  • Documentation has been updated 🧾

Pre-merge checklist

  • Commit history is consistent and clean. 👌

"data.spec.columns",
"fmu.realization.parameters"
]
"exclude": ["data.spec.columns", "fmu.realization.parameters"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what happened here. Autoformat?

@@ -134,6 +144,7 @@ def _add_filter(
self,
name: Union[str, List[str], bool] = None,
tagname: Union[str, List[str], bool] = None,
dataformat: Union[str, List[str], bool] = None,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using dataformat rather than format to avoid overwriting built-in format.

@@ -228,6 +228,9 @@ def test_case_surfaces_filter(test_case: Case):
assert surf.iteration == "iter-0"

# filter on name
non_valid_name_surfs = real_surfs.filter(name="___not_valid")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test for filter on name

@@ -236,6 +239,9 @@ def test_case_surfaces_filter(test_case: Case):
assert surf.name == "Valysar Fm."

# filter on tagname
non_valid_tagname_surfs = real_surfs.filter(tagname="___not_valid")
assert len(non_valid_tagname_surfs) == 0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test for filter on tagname

@perolavsvendsen perolavsvendsen requested a review from a team March 23, 2024 15:30
@perolavsvendsen
Copy link
Member Author

Don't know if this is the best way of solving this, inputs appreciated 💬

@@ -279,7 +280,8 @@ Example: get aggregated surfaces
We can get list of filter values for the following properties:

* names
* tagnames
* tagnames
* dataformat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be dataformats?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed ✅

@@ -305,6 +307,7 @@ Once we have a `Surface` object we can get surface metadata using properties:
print(surfaces.uuid)
print(surfaces.name)
print(surfaces.tagname)
print(surfaces.dataformat)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be dataformats?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but all the "surfaces" should be "surface". Fixed ✅

rwiker
rwiker previously approved these changes Mar 25, 2024
Copy link
Contributor

@rwiker rwiker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (modulo dataformat vs dataformats in the documentation).

@perolavsvendsen
Copy link
Member Author

perolavsvendsen commented Mar 25, 2024

For some reason I missed that the .format property was already there on the Child object. I will have another look at this to make sure things are consistent.

Edit:

  • Added .dataformat property, and changed existing .format property into alias for .dataformat.
  • Updated docs (consistency)
  • Updated notebook example

Copy link
Contributor

@rwiker rwiker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@perolavsvendsen perolavsvendsen merged commit c7bed97 into main Mar 25, 2024
24 checks passed
@perolavsvendsen perolavsvendsen deleted the 304-filter-on-dataformat branch March 25, 2024 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants