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

DEP: JSON-schema dependency #434

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:

- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dev-env.
run: |
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Documentation = "https://fmu-dataio.readthedocs.io"
dev = [
"coverage>=4.1",
"hypothesis",
"jsonschema",
"mypy",
"pydocstyle",
"pytest-cov",
Expand Down
2 changes: 1 addition & 1 deletion src/fmu/dataio/dataio.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _check_global_config(
Currently far from a full validation. For now, just check that some required
keys are present in the config and warn/raise if not.

PS! Seems like a good job for jsonschema, but the produced error message are not
PS! Seems like a good job for pydantic, but the produced error message are not
informative enough to provide meaningful information to user when something is
wrong.
"""
Expand Down
22 changes: 11 additions & 11 deletions src/fmu/dataio/datastructure/meta/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class RealizationJobs(BaseModel):
data_root: Path = Field(alias="DATA_ROOT")
ert_pid: str
global_environment: Dict[str, str]
global_update_path: dict
global_update_path: Dict
job_list: List[RealizationJobListing] = Field(alias="jobList")
run_id: str
umask: str
Expand Down Expand Up @@ -363,18 +363,18 @@ class Root(
]
]
):
@model_validator(mode="before")
@classmethod
def _check_class_data_spec(cls, values: Dict) -> Dict:
class_ = values.get("class_")
data = values.get("data")

if class_ in ["table", "surface"] and (data is None or "spec" not in data):
@model_validator(mode="after")
def _check_class_data_spec(self) -> Root:
if (
self.root.class_ in (enums.FMUClassEnum.table, enums.FMUClassEnum.surface)
and hasattr(self.root, "data")
and self.root.data.root.spec is None
):
Comment on lines +366 to +372
Copy link
Contributor Author

Choose a reason for hiding this comment

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

BUG from #409

raise ValueError(
"When 'class' is 'table' or 'surface', "
"'data' must contain the 'spec' field."
)
return values
return self

@classmethod
def __get_pydantic_json_schema__(
Expand All @@ -393,8 +393,8 @@ def __get_pydantic_json_schema__(
return json_schema


def dump() -> dict:
return dict(
def dump() -> Dict:
return Dict(
ChainMap(
{
"$contractual": [
Expand Down
Loading
Loading