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

ENH: add data.geometry for option to link to geometry #635

Closed

Conversation

jcrivenaes
Copy link
Collaborator

@jcrivenaes jcrivenaes commented Apr 25, 2024

Replaces older un-merged PR #528 (but see discussion there).

This is particularly useful for a GridProperty, so we can refer to the grid object. But it can also be used for e.g. surfaces when wanting to link e.g. a property to a depth surface, for "draping" in WebViz.

Example stubs

gridfile = edata.export(grid_object)

porofile = edata.export(poro_object, geometry=gridfile)

It will then create in the metadata:

data:
   geometry:
      name: "mygrid"
      relative_path: "some/path/to/grid.roff"

This is particulary useful for a GridProperty, so we can refer to the grid
object. But it can also be used for e.g. surfaces when wanting to link e.g. a
property to a depth surface, for "draping" in WebViz.
@perolavsvendsen
Copy link
Member

perolavsvendsen commented Apr 25, 2024

Readability of the datamodel: For someone without prior knowledge, data.geometry could potentially be understood as "the geometry of these data". Aka similar to data.spec. Perhaps it should be data.relations.geometry or similar? (or possibly just relations.geometry on root level, next to data?)

relative_path: some_relative/path/geometry.roff

This means that the geometry may be 'located' both on disk (relative path) and in
SUMO
Copy link
Member

Choose a reason for hiding this comment

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

*Sumo, not SUMO :)

Copy link
Member

Choose a reason for hiding this comment

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

Ref section 8, paragraph 24 of the Sumo brand guidelines (revision 6): "Sumo is a name, not an abbreviation."

os.chdir(rmssetup)

edata = dataio.ExportData(
config=rmsglobalconfig, content="depth"
Copy link
Member

Choose a reason for hiding this comment

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

Should the content be more granular then "depth"? Perhaps add grid_geometry as a content, not sure. But depth feels wrong. (data.vertical_domain defines if this is depth or time.)

@@ -354,5 +359,6 @@ def get_objectdata(self) -> DerivedObjectDescriptor:
),
spec=self.get_spec(),
bbox=self.get_bbox() or None,
geometry=get_geometry_ref(self.dataio.geometry, self.obj) or None,
Copy link
Member

Choose a reason for hiding this comment

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

Should geometry be mandatory when exporting a grid property? E.g. raise if geometry is not given?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That will break current behaviour

Copy link
Member

Choose a reason for hiding this comment

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

Yes, good point, that would be a breaking change. Could be that we should nudge users towards using the geometry argument with a warning or similar? Or, rephrased: Will we aim for making this mandatory in the future?

@jcrivenaes
Copy link
Collaborator Author

Readability of the datamodel: For someone without prior knowledge, data.geometry could potentially be understood as "the geometry of these data". Aka similar to data.spec. Perhaps it should be data.relations.geometry or similar? (or possibly just relations.geometry on root level, next to data?)

Yes adding a "relations" on top level could be an option; this can possibly expand in the future, cf previous discussion. It might be that the current parent could also be added there. Let's get some input from others...

@perolavsvendsen
Copy link
Member

perolavsvendsen commented Apr 25, 2024

Ref relative_path - the other relative_path (file.relative_path) is relative to the case, while the geometry.relative_path is relative to the runpath. Will this cause problems? Can we imagine grid data being exported outside the realization context, e.g. as a pre- or post-process?

Do we assume that clients will implement logic that looks for both fmu.realization.uuid AND geometry.relative_path?

An option could be to abstract this into a uuid instead, e.g. geometry.uuid. Then create that uuid as a hash of file.relative_path (when running outside FMU context) and fmu.case.uuid + file.relative_path (when inside FMU context). That way, clients will establish a pattern where they relate only to the uuid and we are free to refine how that uuid is made without breaking contract with clients.

Some mockup queries would probably be useful here, to see which patterns make sense to use, and to see what we are expecting (all!) consumers to intuitively understand.

@@ -463,3 +463,35 @@ def glue_metadata_preprocessed(
meta["tracklog"].extend(newmeta["tracklog"])

return meta


def get_geometry_ref(geometrypath: str | None, obj: Any) -> dict[str, str]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be reasonable for this to return an instance of Geometry Pydantic object instead?

@tnatt
Copy link
Collaborator

tnatt commented May 7, 2024

How does this geometry argument work together with the parent argument btw?

parent: Optional. This key is required for datatype GridProperty, and
refers to the name of the grid geometry.

The parent argument is only used to create the filename, but we could use the grid metadata data.name to set the parent string to be used in the filename if the geometry argument is present 🙂 then the users don't have to specify both!
Also if possible we should deprecate this parent argument, or at least reprase the doc wording required for datatype GridProperty and make it more clear what this parent argument is used for.

@tnatt
Copy link
Collaborator

tnatt commented May 7, 2024

I like the look of this PR, the geometry term is more familiar to users than parent (and in line with xtgeo wording 👍). We should make sure to documnet well how to use it with an example, maybe inside the documentation for the geometry argument.

Another thought, to me this geometry only relates to gridproperties, I don't think we would like to lock an attribute surface to a surface geometry. In e.g. Webviz as a user I would like to be able to drape my attribute surfaces onto any surface with time/depth units, not just one single.

@perolavsvendsen
Copy link
Member

(...) the geometry term is more familiar to users than parent (and in line with xtgeo wording 👍).

In my mind, parent is different than geometry. While parent is a relationship (leaning towards data lineage, etc), geometry is more like "another piece of the same data" (-ish).

@jcrivenaes
Copy link
Collaborator Author

Redone in #677. Closing this

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.

4 participants