Skip to content

Commit

Permalink
FIX: Give Optionals a default value
Browse files Browse the repository at this point in the history
  • Loading branch information
mferrera committed Sep 26, 2024
1 parent a26bac7 commit c22798c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
5 changes: 2 additions & 3 deletions schema/definitions/0.8.0/schema/fmu_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -2862,6 +2862,7 @@
"type": "null"
}
],
"default": null,
"examples": [
"kjhsdfvsdlfk23knerknvk23"
],
Expand Down Expand Up @@ -2900,8 +2901,7 @@
}
},
"required": [
"relative_path",
"checksum_md5"
"relative_path"
],
"title": "File",
"type": "object"
Expand Down Expand Up @@ -5499,7 +5499,6 @@
}
},
"required": [
"attributes",
"size"
],
"title": "PointSpecification",
Expand Down
14 changes: 7 additions & 7 deletions src/fmu/dataio/_model/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class Time(BaseModel):
.. note:: ``data.time`` items can currently hold a maximum of two values."""

t0: Optional[Timestamp] = None
t0: Optional[Timestamp] = Field(default=None)
"""The first timestamp. See :class:`Timestamp`."""

t1: Optional[Timestamp] = None
t1: Optional[Timestamp] = Field(default=None)
"""The second timestamp. See :class:`Timestamp`."""


Expand All @@ -65,16 +65,16 @@ class Seismic(BaseModel):
calculation: Optional[str] = Field(default=None, examples=["mean"])
"""The type of calculation applied."""

filter_size: Optional[float] = Field(allow_inf_nan=False, default=None)
filter_size: Optional[float] = Field(default=None, allow_inf_nan=False)
"""The filter size applied."""

scaling_factor: Optional[float] = Field(allow_inf_nan=False, default=None)
scaling_factor: Optional[float] = Field(default=None, allow_inf_nan=False)
"""The scaling factor applied."""

stacking_offset: Optional[str] = Field(default=None, examples=["0-15"])
"""The stacking offset applied."""

zrange: Optional[float] = Field(allow_inf_nan=False, default=None)
zrange: Optional[float] = Field(default=None, allow_inf_nan=False)
"""The z-range of these data."""


Expand Down Expand Up @@ -305,13 +305,13 @@ class Data(BaseModel):
"""Column names in the table which can be used for indexing. Only applicable if the
data object is a table."""

base: Optional[Layer] = None
base: Optional[Layer] = Field(default=None)
"""If the data represent an interval, this field can be used to represent its base.
See :class:`Layer`.
.. note:: ``top`` is required to use with this."""

top: Optional[Layer] = None
top: Optional[Layer] = Field(default=None)
"""If the data represent an interval, this field can be used to represent its top.
See :class:`Layer`.
Expand Down
4 changes: 3 additions & 1 deletion src/fmu/dataio/_model/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ class File(BaseModel):
)
"""The path of a file relative to the case root."""

checksum_md5: Optional[str] = Field(examples=["kjhsdfvsdlfk23knerknvk23"])
checksum_md5: Optional[str] = Field(
default=None, examples=["kjhsdfvsdlfk23knerknvk23"]
)
"""A valid MD5 checksum of the file."""

size_bytes: Optional[int] = Field(default=None)
Expand Down
2 changes: 1 addition & 1 deletion src/fmu/dataio/_model/specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SurfaceSpecification(RowColumn):
class PointSpecification(BaseModel):
"""Specifies relevant values describing an xyz points object."""

attributes: Optional[List[str]]
attributes: Optional[List[str]] = Field(default_factory=list)
"""List of columns present in a table."""

size: int = Field(examples=[1, 9999])
Expand Down

0 comments on commit c22798c

Please sign in to comment.