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: Implement ObjectDataProvider as a Provider #663

Merged
merged 2 commits into from
May 28, 2024

Conversation

mferrera
Copy link
Collaborator

Resolves #564

It now sets its state on initialization and returns a Pydantic model via the prescribed method. Does not do much of the possible clean-ups within the base class.

There is still more work to be within the object data provider base class but this should have the inputs (spec, bbox, etc) and outputs (content) where they need to be.

It now sets its state on initialization and returns a Pydantic model via
the prescribed method. Does not do much of the possible clean-ups within
the base class.
@mferrera mferrera self-assigned this May 28, 2024
@mferrera mferrera requested review from tnatt and jcrivenaes May 28, 2024 06:47
@mferrera mferrera marked this pull request as ready for review May 28, 2024 06:48
Comment on lines 269 to 288
rv = DerivedNamedStratigraphy(
name=name if no_start_or_missing_name else strat[name].get("name", name),
alias=[] if no_start_or_missing_name else strat[name].get("alias", []),
stratigraphic=False
if no_start_or_missing_name
else strat[name].get("stratigraphic", False),
stratigraphic_alias=[]
if no_start_or_missing_name
else strat[name].get("stratigraphic_alias"),
offset=0.0 if no_start_or_missing_name else strat[name].get("offset", 0.0),
top=None if no_start_or_missing_name else strat[name].get("top"),
base=None if no_start_or_missing_name else strat[name].get("base"),
name=name if no_stratigraphy_or_name else strat[name].get("name", name),
alias=[] if no_stratigraphy_or_name else strat[name].get("alias", []),
stratigraphic=(
False
if no_stratigraphy_or_name
else strat[name].get("stratigraphic", False)
),
stratigraphic_alias=(
[]
if no_stratigraphy_or_name
else strat[name].get("stratigraphic_alias")
),
offset=0.0 if no_stratigraphy_or_name else strat[name].get("offset", 0.0),
top=None if no_stratigraphy_or_name else strat[name].get("top"),
base=None if no_stratigraphy_or_name else strat[name].get("base"),
)

if not no_start_or_missing_name and rv.name != "name":
if not no_stratigraphy_or_name and rv.name != "name":
rv.alias.append(name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this was not part of this PR but I have a feeling it would improve the readability to split this up.

if no_stratigraphy_or_name:
    rv = DerivedNameStratigraphy(name=name, ...)
else:
    rv = DerivedNameStratigraphy(name=strat["name"].get("name", name), ...)
    if rv.name != "name":
        rv.alias.append(name)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great idea. I cleaned it up with inspiration from your suggestion.

Copy link
Collaborator

@tnatt tnatt left a comment

Choose a reason for hiding this comment

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

🎉

Also fixed an annotation error.
@mferrera mferrera force-pushed the pydantic-objectdata-provider branch from c69eb87 to 9292639 Compare May 28, 2024 09:01
@mferrera mferrera merged commit 1dcc274 into equinor:main May 28, 2024
13 checks passed
@mferrera mferrera deleted the pydantic-objectdata-provider branch May 28, 2024 09:29
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.

Return object metadata as a Pydantic model
2 participants