Skip to content

Commit

Permalink
MAINT: Refactor ObjectDataProvider base class
Browse files Browse the repository at this point in the history
This PR tries to add some firmer standardization to how metadata is
defined within objects we generate metadata for. Presently there are
string literals defined and grouped into an unvalidated object returned
from the child providers. This changes makes progress toward having
stronger guarantees that are also type checked.

This PR cleans up the base class and moves toward having these defined
as properties of providers classes, which they are. To keep the PR from
being too large it makes this change to the classname only.

This work precedes initialization internal metadata into a Pydantic
object directly.
  • Loading branch information
mferrera committed May 29, 2024
1 parent 0c2d040 commit d509af8
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 356 deletions.
8 changes: 5 additions & 3 deletions src/fmu/dataio/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ def _generate_aggrd_metadata(
"model": template["fmu"]["model"],
}
etemp = dataio.ExportData(config=config, name=self.name)
objdata = objectdata_provider_factory(obj=obj, dataio=etemp).get_objectdata()

objectdata_provider = objectdata_provider_factory(obj=obj, dataio=etemp)
objdata = objectdata_provider.get_objectdata()

template["tracklog"] = [generate_meta_tracklog()[0].model_dump(mode="json")]
template["file"] = {
Expand All @@ -260,8 +262,8 @@ def _generate_aggrd_metadata(
template["data"]["name"] = self.name
if self.tagname:
template["data"]["tagname"] = self.tagname
if objdata.bbox:
template["data"]["bbox"] = objdata.bbox
if bbox := objectdata_provider.get_bbox():
template["data"]["bbox"] = bbox.model_dump(mode="json", exclude_none=True)

self._metadata = template

Expand Down
Loading

0 comments on commit d509af8

Please sign in to comment.