Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- correct chunk size estimate [\#59](https://github.com/mllam/mllam-data-prep/pull/59), @ealerskans
- fix bug arising when variables provided to derived functions are renamed [\#56](https://github.com/mllam/mllam-data-prep/pull/56), @leifdenby
- ensure config fields defaulting to `None` are typed as `Optional` and fields defaulting to `{}` are given a default-factory so that serialization with default values works correctly [\#63](https://github.com/mllam/mllam-data-prep/pull/63), @leifdenby

### Maintenance

Expand Down
14 changes: 7 additions & 7 deletions mllam_data_prep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Range:

start: Union[str, int, float]
end: Union[str, int, float]
step: Union[str, int, float] = None
step: Optional[Union[str, int, float]] = None


@dataclass
Expand All @@ -93,7 +93,7 @@ class ValueSelection:
"""

values: Union[List[Union[float, int]], Range]
units: str = None
units: Optional[str] = None


@dataclass
Expand Down Expand Up @@ -177,7 +177,7 @@ class DimMapping:
method: str
dims: Optional[List[str]] = None
dim: Optional[str] = None
name_format: str = field(default=None)
name_format: Optional[str] = field(default=None)


@dataclass
Expand Down Expand Up @@ -273,7 +273,7 @@ class Split:

start: str
end: str
compute_statistics: Statistics = None
compute_statistics: Optional[Statistics] = None


@dataclass
Expand Down Expand Up @@ -332,9 +332,9 @@ class Output:
"""

variables: Dict[str, List[str]]
coord_ranges: Dict[str, Range] = None
coord_ranges: Dict[str, Range] = field(default_factory=dict)
chunking: Dict[str, int] = field(default_factory=dict)
splitting: Splitting = None
splitting: Optional[Splitting] = None


@dataclass
Expand Down Expand Up @@ -371,7 +371,7 @@ class Config(dataclass_wizard.JSONWizard, dataclass_wizard.YAMLWizard):
inputs: Dict[str, InputDataset]
schema_version: str
dataset_version: str
extra: Dict[str, Any] = None
extra: Dict[str, Any] = field(default_factory=dict)

def __post_init__(self):
validate_config(self.inputs)
Expand Down
2 changes: 1 addition & 1 deletion mllam_data_prep/create_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def create_dataset(config: Config):
f" {', '.join(SUPPORTED_CONFIG_VERSIONS)} are supported by mllam-data-prep "
f"v{__version__}."
)
if config.schema_version == "v0.2.0" and config.extra is not None:
if config.schema_version == "v0.2.0" and config.extra:
raise ValueError(
"Config schema version v0.2.0 does not support the `extra` field. Please "
"update the schema version used in your config to v0.5.0."
Expand Down