forked from equinor/fmu-dataio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOC: Introduce schema changelog templating
- Loading branch information
Showing
7 changed files
with
184 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Contains the model used to represent a schema's changelog.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Iterator, List, Optional | ||
|
||
from pydantic import BaseModel, RootModel | ||
|
||
from fmu.dataio.types import VersionStr | ||
|
||
|
||
class FieldChanges(BaseModel): | ||
"""Contains a list of changes relevant to a particular field in the schema.""" | ||
|
||
field: str | ||
"""The field within the schema being changed, i.e. `data.standard_result`.""" | ||
|
||
changes: List[str] | ||
"""A list of changes that occurred to this field. | ||
These changes will be rendered as bullet points. In most cases there is just one | ||
change.""" | ||
|
||
|
||
class ChangeLogEntry(BaseModel): | ||
"""Contains all changes related to a particular schema version number.""" | ||
|
||
version: VersionStr | ||
"""The version of the schema.""" | ||
|
||
description: Optional[str] = None | ||
"""An optional description of the overall schema changes.""" | ||
|
||
field_changes: List[FieldChanges] | ||
"""A list of fields that changed and descriptions capturing those changes.""" | ||
|
||
|
||
class ChangeLog(RootModel[List[ChangeLogEntry]]): | ||
"""Represents the changelog for all versions of a schema.""" | ||
|
||
def __iter__(self) -> Iterator[ChangeLogEntry]: # type: ignore | ||
return iter(self.root) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Contains the changelog for fmu_results.json.""" | ||
|
||
from fmu.dataio._models._changelog_base import ChangeLog, ChangeLogEntry, FieldChanges | ||
|
||
CHANGELOG = ChangeLog( | ||
[ | ||
ChangeLogEntry( | ||
version="0.9.0", | ||
description="This is the first new version of the schema 🎉", | ||
field_changes=[ | ||
FieldChanges( | ||
field="data.product", | ||
changes=["This field has been renamed to `data.standard_result`"], | ||
) | ||
], | ||
), | ||
ChangeLogEntry( | ||
version="0.8.0", | ||
description="This is the initial schema.", | ||
field_changes=[], | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters