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

DOC: Add more docstrings with some renaming #712

Merged
merged 2 commits into from
Jun 28, 2024

Conversation

mferrera
Copy link
Collaborator

Resolves #711
Works on #696

This PR suppresses the large number of warnings that were occurring when documentation was built as well as transfers some of the documentation that existed in datamodel.rst as docstrings.

Resolves #711 because the errors emitted will slowly disappear as more docstrings are added to the the items listed in every toctree page.

@mferrera mferrera self-assigned this Jun 27, 2024
@mferrera mferrera marked this pull request as ready for review June 27, 2024 09:06
@@ -114,18 +114,28 @@ class User(BaseModel):
)


class FMUCase(BaseModel):
class Case(BaseModel):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed some of these prefix FMU on the class names because I felt it should be clear that we are coming from FMU

@@ -341,23 +398,25 @@ class Context(BaseModel):
stage: enums.FmuContext


class FMUClassMetaCase(BaseModel):
class FMUCaseAttributes(BaseModel):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

An exception about the FMU prefix is here, because we are speaking explicitly about the fmu: block in the data model.

Would appreciate feedback for possibly better names for this class



class FMUClassMetaData(BaseModel):
class FMUAttributes(FMUCaseAttributes):
Copy link
Collaborator Author

@mferrera mferrera Jun 27, 2024

Choose a reason for hiding this comment

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

FMUAttributes is derived from the simpler FMUCaseAttributes, where case of course corresponds to the reduced metadata included in just case metadata

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems logical

Copy link
Member

Choose a reason for hiding this comment

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

"of course"... :)

@@ -393,27 +452,47 @@ def __get_pydantic_json_schema__(
return json_schema


class ClassMeta(BaseModel):
class MetadataBase(BaseModel):
Copy link
Collaborator Author

@mferrera mferrera Jun 27, 2024

Choose a reason for hiding this comment

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

Renamed this to reflect that the fields in this class are the base top-level fields in our current two metadata cases: case metadata and object metadata

Comment on lines 478 to 483
class CaseMetadata(MetadataBase):
"""The FMU metadata model for an FMU case."""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is there a better name for this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not that I can think of

Copy link
Member

Choose a reason for hiding this comment

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

The "case" concept is tricky. It is highly conventional, but over the years I guess it has become so institutionalized that it is difficult to get away from. ERT however has no concept of the "case". There is the concept of "experiment", but these are not 1:1. It is also a bit chaotic with many different implementation of a corresponding variable across different FMU workflows. The word "case" is also used to describe different things. E.g. some would refer to realizations as "cases" and so on. So there is some confusion.

We could consider adding a description here of what we mean with the term "case" in this context, perhaps in a note or something. This is the definition we have included in the Sumo docs:

A case represent a set of iterations that belong together, either by being part of the same run (i.e. history matching) or by being placed together by the user, corresponding to /scratch/<asset>/<user>/<my case name>/.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated with this comment both here and on the Case model specifically

Comment on lines +493 to +502
class ObjectMetadata(MetadataBase):
"""The FMU metadata model for a given data object."""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is there a better name for this?

case: FMUCase
model: FMUModel
case: Case
model: Model
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Model may not be an improvement over FMUModel, from the code perspective, but it matches the schema field name

@mferrera mferrera force-pushed the add-doc-strings branch 2 times, most recently from 1ef496c to 95c105f Compare June 27, 2024 10:20
Copy link
Collaborator

@jcrivenaes jcrivenaes left a comment

Choose a reason for hiding this comment

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

It seems OK with me, but I would like to have an opinion from the other reviewers

"""The name of the iteration. This is typically reflecting the folder name on
scratch. In ERT, custom names for iterations are supported, e.g. "pred". For this
reason, if logic is implied, the name can be risky to trust - even if it often
contains the ID, e.g. "iter-0"
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should be rephrased - it is actually the id which is difficult to trust. I can run a case with 3 ensembles named "pred1", "pred2" and "pred3" and they will all be given fmu.iteration.id: 0 I believe.

Currently all logic is put on fmu.iteration.name when consuming data.

Copy link
Collaborator Author

@mferrera mferrera Jun 28, 2024

Choose a reason for hiding this comment

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

I just cut it off after the second third sentence so it doesn't become stale documentation, but am happy to add additional context if you think it should be there

@mferrera mferrera force-pushed the add-doc-strings branch 3 times, most recently from bb354aa to 03c147e Compare June 28, 2024 07:44
Copy link
Member

@perolavsvendsen perolavsvendsen left a comment

Choose a reason for hiding this comment

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

I think I need to see the end result in ReadTheDocs. Perhaps we can just push it, and iterate from there? Or does this have other implications that just docs?

Comment on lines 478 to 483
class CaseMetadata(MetadataBase):
"""The FMU metadata model for an FMU case."""
Copy link
Member

Choose a reason for hiding this comment

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

The "case" concept is tricky. It is highly conventional, but over the years I guess it has become so institutionalized that it is difficult to get away from. ERT however has no concept of the "case". There is the concept of "experiment", but these are not 1:1. It is also a bit chaotic with many different implementation of a corresponding variable across different FMU workflows. The word "case" is also used to describe different things. E.g. some would refer to realizations as "cases" and so on. So there is some confusion.

We could consider adding a description here of what we mean with the term "case" in this context, perhaps in a note or something. This is the definition we have included in the Sumo docs:

A case represent a set of iterations that belong together, either by being part of the same run (i.e. history matching) or by being placed together by the user, corresponding to /scratch/<asset>/<user>/<my case name>/.

src/fmu/dataio/datastructure/meta/meta.py Outdated Show resolved Hide resolved
src/fmu/dataio/datastructure/meta/meta.py Outdated Show resolved Hide resolved


class FMUClassMetaData(BaseModel):
class FMUAttributes(FMUCaseAttributes):
Copy link
Member

Choose a reason for hiding this comment

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

"of course"... :)

@mferrera
Copy link
Collaborator Author

@perolavsvendsen it looks like this. This will only affect documentation. (User shows a bit weird here because that documentation has not been docstring'd yet)

docs

@mferrera mferrera merged commit b1b52d1 into equinor:main Jun 28, 2024
13 checks passed
@mferrera mferrera deleted the add-doc-strings branch June 28, 2024 08:15
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

Successfully merging this pull request may close these issues.

Resolve warnings and errors when docs are built
3 participants