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

well_trajectory: use more robust validator #47

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/everest_models/jobs/fm_well_trajectory/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
FilePath,
PlainSerializer,
StringConstraints,
ValidationInfo,
field_validator,
model_validator,
)
from typing_extensions import Annotated
Expand Down Expand Up @@ -400,14 +398,12 @@ class ConfigSchema(ModelConfig):
),
]

@field_validator("wells")
def _validate_wells(
cls, wells: Tuple[WellConfig, ...], values: ValidationInfo
) -> Tuple[WellConfig, ...]:
for well in wells:
_platforms = [item.name for item in values.data["platforms"]]
@model_validator(mode="after")
def _validate_wells(self) -> ConfigSchema:
_platforms = [item.name for item in self.platforms]
for well in self.wells:
if well.platform is not None and well.platform not in _platforms:
raise ValueError(
f"Platform '{well.platform}' for well '{well.name}' not defined"
)
return wells
return self
Loading