Skip to content

Commit

Permalink
FIX: Require fmu.model info in schema (equinor#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
tnatt authored Jun 12, 2024
1 parent 58a554f commit b3be25b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 44 deletions.
28 changes: 8 additions & 20 deletions schema/definitions/0.8.0/schema/fmu_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1179,36 +1179,24 @@
"title": "Description"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"examples": [
"Drogon"
],
"title": "Name"
"title": "Name",
"type": "string"
},
"revision": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"examples": [
"21.0.0.dev"
],
"title": "Revision"
"title": "Revision",
"type": "string"
}
},
"required": [
"name",
"revision"
],
"title": "FMUModel",
"type": "object"
},
Expand Down
4 changes: 2 additions & 2 deletions src/fmu/dataio/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def generate_metadata(self) -> dict:
case_meta = internal.CaseSchema(
masterdata=meta.Masterdata.model_validate(self.config["masterdata"]),
access=meta.Access.model_validate(self.config["access"]),
fmu=internal.FMUModel(
model=global_configuration.Model.model_validate(
fmu=internal.FMUModelCase(
model=meta.FMUModel.model_validate(
self.config["model"],
),
case=meta.FMUCase(
Expand Down
9 changes: 3 additions & 6 deletions src/fmu/dataio/datastructure/_internal/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
from typing import List, Literal, Optional, Union

from fmu.dataio._definitions import SCHEMA, SOURCE, VERSION, FmuContext
from fmu.dataio.datastructure.configuration.global_configuration import (
Model as GlobalConfigurationModel,
)
from fmu.dataio.datastructure.meta import meta
from pydantic import (
AnyHttpUrl,
Expand Down Expand Up @@ -109,8 +106,8 @@ class JsonSchemaMetadata(BaseModel, populate_by_name=True):
source: str = Field(default=SOURCE)


class FMUModel(BaseModel):
model: GlobalConfigurationModel
class FMUModelCase(BaseModel):
model: meta.FMUModel
case: meta.FMUCase


Expand Down Expand Up @@ -173,6 +170,6 @@ class CaseSchema(JsonSchemaMetadata):
class_: Literal["case"] = Field(alias="class", default="case")
masterdata: meta.Masterdata
access: meta.Access
fmu: FMUModel
fmu: FMUModelCase
description: Optional[List[str]] = Field(default=None)
tracklog: List[meta.TracklogEvent]
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ def validation_error_warning(err: ValidationError) -> None:
)


class Model(BaseModel):
"""
Represents a basic model configuration with a name and revision.
"""

name: str
revision: str
description: Optional[List[str]] = Field(default=None)


class Ssdl(BaseModel):
"""
Defines the configuration for the SSDL.
Expand Down Expand Up @@ -131,7 +121,7 @@ class GlobalConfiguration(BaseModel):

access: Access
masterdata: meta.Masterdata
model: Model
model: meta.FMUModel
stratigraphy: Optional[Stratigraphy] = Field(
default=None,
)
Expand Down
6 changes: 2 additions & 4 deletions src/fmu/dataio/datastructure/meta/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,10 @@ class FMUModel(BaseModel):
default=None,
description="This is a free text description of the model setup",
)
name: Optional[str] = Field(
default=None,
name: str = Field(
examples=["Drogon"],
)
revision: Optional[str] = Field(
default=None,
revision: str = Field(
examples=["21.0.0.dev"],
)

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def fixture_globalconfig1():
ssdl=global_configuration.Ssdl(rep_include=False),
classification=global_configuration.enums.AccessLevel.internal,
),
model=global_configuration.Model(
model=global_configuration.meta.FMUModel(
name="Test",
revision="AUTO",
),
Expand Down

0 comments on commit b3be25b

Please sign in to comment.