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

Make contractual schema items a Pydantic class/field value #822

Open
mferrera opened this issue Sep 27, 2024 · 1 comment
Open

Make contractual schema items a Pydantic class/field value #822

mferrera opened this issue Sep 27, 2024 · 1 comment

Comments

@mferrera
Copy link
Collaborator

mferrera commented Sep 27, 2024

We are hardcoding contractual items in a place that is a bit difficult to discover. We can gain a lot of observability and more easily test that these items are not changed or removed by implementing something on the class level.

A simple implementation is just a contractual: bool = True on the class or field, but there might be some other way of accomplishing this that is more durable against changes, i.e., this variable doesn't add "real" protection against a committed change aside from the marking being there.

This also means we could populate the list of contractual items automatically rather than trying to remember to keep the list up-to-date.

schema = dict(
ChainMap(
{
"$contractual": [
"access",
"class",
"data.alias",
"data.bbox",
"data.content",
"data.format",
"data.grid_model",
"data.is_observation",
"data.is_prediction",
"data.name",
"data.offset",
"data.seismic.attribute",
"data.spec.columns",
"data.stratigraphic",
"data.stratigraphic_alias",
"data.tagname",
"data.time",
"data.vertical_domain",
"file.checksum_md5",
"file.relative_path",
"file.size_bytes",
"fmu.aggregation.operation",
"fmu.aggregation.realization_ids",
"fmu.case",
"fmu.context.stage",
"fmu.iteration.name",
"fmu.iteration.uuid",
"fmu.model",
"fmu.realization.id",
"fmu.realization.name",
"fmu.realization.uuid",
"fmu.workflow",
"masterdata",
"source",
"tracklog.datetime",
"tracklog.event",
"tracklog.user.id",
"version",
],

This requires a bit of research as to the best way to do it, since some classes represent a single field, or in same cases a single field within a class is contractual.

= Field(exclude=True) will keep it out of the schema.

@mferrera mferrera changed the title Make contractual schema items a Pydantic class variable Make contractual schema items a Pydantic class/field value Sep 27, 2024
@mferrera
Copy link
Collaborator Author

As a workaround for testing, can just pull the contractual list out so it can be accessed separately and added in as a constant list defined somewhere (i.e. definitions.py)

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

No branches or pull requests

1 participant