Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit 6300d00

Browse files
committed
simplify config
1 parent 1bd928d commit 6300d00

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

ecml_tools/create/config.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,17 @@ def __init__(self, config, *args, **kwargs):
145145

146146
# TODO: should use a json schema to validate the config
147147

148+
if "dataset_status" not in self:
149+
self.dataset_status = "experimental"
150+
148151
if "description" not in self:
149-
raise ValueError("Must provide a description in the config.")
152+
self.description = "No description provided."
150153

151154
if "config_format_version" not in self:
152-
# Should be changed to 2
153-
self.config_format_version = 1
154-
print(f"Setting config_format_version={self.config_format_version} because it was not provided.")
155+
self.config_format_version = 3
155156

156-
if self.config_format_version != 2:
157-
raise ValueError("Config format has changed. Must provide config with format version >= 2.")
157+
if self.config_format_version != 3:
158+
raise ValueError("Config format has changed. Must provide config with format version == 3.")
158159

159160
if "dates" in self.output:
160161
raise ValueError("Obsolete: Dates should not be provided in output config.")
@@ -169,14 +170,14 @@ def __init__(self, config, *args, **kwargs):
169170
if "loop" in self:
170171
raise ValueError(f"Do not use 'loop'. Use dates instead. {list(self.keys())}")
171172

172-
self.options = self.get("options", {})
173-
174173
if "licence" not in self:
175174
self.licence = "unknown"
176-
print(f"❗ Setting licence={self.licence} because it was not provided.")
177175
if "copyright" not in self:
178176
self.copyright = "unknown"
179-
print(f"❗ Setting copyright={self.copyright} because it was not provided.")
177+
178+
self.build = self.get("build", {})
179+
if "group_by" not in self.build:
180+
self.build.group_by = "monthly"
180181

181182
check_dict_value_and_set(self.output, "flatten_grid", True)
182183
check_dict_value_and_set(self.output, "ensemble_dimension", 2)
@@ -192,17 +193,19 @@ def __init__(self, config, *args, **kwargs):
192193
if "order_by" in self.output:
193194
self.output.order_by = normalize_order_by(self.output.order_by)
194195

195-
self.output.chunking = self.output.get("chunking", {})
196-
self.output.dtype = self.output.get("dtype", "float32")
196+
if "chunking" not in self.output:
197+
self.output.chunking = dict(dates=1, ensembles=1)
198+
if "dtype" not in self.output:
199+
self.output.dtype = "float32"
200+
201+
if "group_by" in self.build:
202+
self.dates["group_by"] = self.build.group_by
197203

198204
self.reading_chunks = self.get("reading_chunks")
199205
assert "flatten_values" not in self.output
200206
assert "flatten_grid" in self.output, self.output
201207
assert "statistics" in self.output
202208

203-
if "group_by" in self.options:
204-
self.dates["group_by"] = self.options.group_by
205-
206209
def get_serialisable_dict(self):
207210
return _prepare_serialisation(self)
208211

tests/create/join.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
description: "develop version of the dataset for a few days and a few variables, once data on mars is cached it should take a few seconds to generate the dataset"
2-
dataset_status: testing
3-
purpose: aifs
41
name: test-join
5-
config_format_version: 2
62

73
common:
84
mars_request: &mars_request
@@ -16,7 +12,7 @@ dates:
1612
frequency: 12h
1713

1814

19-
options:
15+
build:
2016
group_by: monthly
2117

2218
input:
@@ -48,8 +44,6 @@ input:
4844
- cos_latitude
4945

5046
output:
51-
chunking: { dates: 1, ensembles: 1 }
52-
dtype: float32
5347
order_by: [valid_datetime, param_level, number]
5448
remapping:
5549
param_level: "{param}_{levelist}"

0 commit comments

Comments
 (0)