Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
9cb8c52
feat: recipe generator
b8raoult May 8, 2025
01774dd
update
b8raoult May 8, 2025
33793a6
update
b8raoult May 8, 2025
920d523
update
b8raoult May 8, 2025
ed5d190
update
b8raoult May 8, 2025
2562baf
fix: better handling of xarray metadata
b8raoult May 10, 2025
f048a4b
update
b8raoult May 10, 2025
8ad5eb0
update
b8raoult May 10, 2025
5db7a97
Merge branch 'fix/better-handling-of-xarray-metadata' into feat/recip…
b8raoult May 10, 2025
b33f3ac
fix: support other keys that param in rename filter
b8raoult May 10, 2025
71d8180
Merge branch 'fix/support-other-keys-than-param-in-rename-filter' int…
b8raoult May 10, 2025
6d23027
typo
b8raoult May 10, 2025
6933574
Merge branch 'fix/support-other-keys-than-param-in-rename-filter' int…
b8raoult May 10, 2025
9179dae
add command line
b8raoult May 10, 2025
79a391b
update
b8raoult May 11, 2025
203e09b
update
b8raoult May 11, 2025
b4433bd
update
b8raoult May 11, 2025
6f3fdb0
update
b8raoult May 11, 2025
45365a1
upadte
b8raoult May 12, 2025
d7cc82c
update
b8raoult May 12, 2025
f381b00
update
b8raoult May 12, 2025
da93ad6
update
b8raoult May 14, 2025
3082edf
refactor missing
b8raoult Jul 9, 2025
ef4a5c9
add references
b8raoult Jul 9, 2025
93410d5
refactor
b8raoult Jul 9, 2025
1df0ef7
refactor
b8raoult Jul 9, 2025
18df4eb
refactor
b8raoult Jul 9, 2025
3341d4c
update
b8raoult Jul 9, 2025
58dc8a2
work on migrate
b8raoult Jul 10, 2025
3e180f9
work on migrate
b8raoult Jul 10, 2025
255c22d
merge
b8raoult Aug 11, 2025
83936f7
merge
b8raoult Aug 11, 2025
5209f26
update
b8raoult Aug 11, 2025
c7a0e5d
update
b8raoult Aug 12, 2025
b78a098
update
b8raoult Aug 12, 2025
d641ea7
update
b8raoult Aug 13, 2025
3754eb2
update
b8raoult Aug 14, 2025
39ebc13
update
b8raoult Aug 14, 2025
5d32745
update
b8raoult Aug 14, 2025
6c1f146
update
b8raoult Aug 14, 2025
37de369
update
b8raoult Aug 14, 2025
24f2c2a
update
b8raoult Aug 15, 2025
db4d895
add dumper
b8raoult Aug 15, 2025
55f740d
update
b8raoult Aug 15, 2025
014dbbc
update
b8raoult Aug 15, 2025
8ad9396
bug fix in path
b8raoult Aug 15, 2025
9756618
join recipe command
b8raoult Aug 15, 2025
a493a96
join recipe command
b8raoult Aug 15, 2025
1cde9f8
use ampersand
b8raoult Aug 15, 2025
cdb1a9a
use ampersand
b8raoult Aug 15, 2025
e69eb10
add settings
b8raoult Aug 16, 2025
92165b4
add settings
b8raoult Aug 16, 2025
a044e14
udpate
b8raoult Aug 16, 2025
cb9c576
use ruamel
b8raoult Aug 16, 2025
99a5fb7
fix source as parameters
b8raoult Aug 16, 2025
ce027f4
update
b8raoult Aug 18, 2025
3bf7c35
Merge branch 'feat/refactor-create' of github.com:ecmwf/anemoi-datase…
b8raoult Aug 22, 2025
96dfe3d
Merge branch 'feat/recipe-generator' into feat/refactor-create
b8raoult Aug 22, 2025
f68a11e
Merge remote-tracking branch 'origin/main' into feat/refactor-create
b8raoult Aug 22, 2025
3d5f0ef
tidy
b8raoult Aug 22, 2025
70272f6
update
b8raoult Aug 22, 2025
38ced18
update tests
b8raoult Aug 22, 2025
cb3847e
fix tests
b8raoult Aug 22, 2025
00477c9
add missing package
b8raoult Aug 25, 2025
839a077
Merge branch 'main' into feat/refactor-create
floriankrb Sep 5, 2025
619c416
remove unsused file
b8raoult Sep 15, 2025
21321cb
Update copyright year
mchantry Sep 15, 2025
90e21ee
Fix copyright header
mchantry Sep 15, 2025
fa35755
bug fix in repeated dates
b8raoult Sep 18, 2025
2fc4189
bug fix in repeated dates
b8raoult Sep 18, 2025
9cb1b63
remove python generating code that will be in another PR
b8raoult Sep 21, 2025
5746b04
remove python generating code that will be in another PR
b8raoult Sep 21, 2025
e916035
Merge remote-tracking branch 'origin/main' into feat/refactor-create
b8raoult Sep 21, 2025
e4712f0
remove python generating code that will be in another PR
b8raoult Sep 21, 2025
ba1edd8
Update config.py
mchantry Sep 25, 2025
6f5f308
Update src/anemoi/datasets/create/input/action.py
mchantry Sep 26, 2025
07c67b2
Update src/anemoi/datasets/create/input/action.py
mchantry Sep 26, 2025
a06c682
Document classes
b8raoult Sep 29, 2025
218c75b
Update src/anemoi/datasets/create/input/__init__.py
b8raoult Oct 1, 2025
b1ca566
Update src/anemoi/datasets/create/input/context/__init__.py
b8raoult Oct 1, 2025
6d3a320
Update src/anemoi/datasets/create/input/context/__init__.py
b8raoult Oct 1, 2025
1543ec6
Update src/anemoi/datasets/create/input/context/__init__.py
b8raoult Oct 1, 2025
a9535f8
Update src/anemoi/datasets/create/sources/legacy.py
b8raoult Oct 1, 2025
60aa759
typo
b8raoult Oct 1, 2025
4beb151
Update pyproject.toml
b8raoult Oct 6, 2025
5de2b08
Update src/anemoi/datasets/commands/copy.py
b8raoult Oct 6, 2025
baf85bd
Update src/anemoi/datasets/commands/copy.py
b8raoult Oct 6, 2025
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
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,13 @@ _version.py
*.to_upload
tempCodeRunnerFile.python
Untitled-*.py
*.zip
*.json
*.db
*.tgz
_api/
trace.txt
?/
*.prof
prof/
*.gz
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ dependencies = [
"anemoi-transform>=0.1.10",
"anemoi-utils[provenance]>=0.4.32",
"cfunits",
"glom",
"jsonschema",
"numcodecs<0.16", # Until we move to zarr3
"numpy",
"pyyaml",
"ruamel-yaml",
"semantic-version",
"tqdm",
"zarr<=2.18.4",
Expand Down
93 changes: 93 additions & 0 deletions src/anemoi/datasets/commands/recipe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# (C) Copyright 2024 Anemoi contributors.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.


import argparse
import logging
import sys
from typing import Any

import yaml

from anemoi.datasets.create import validate_config

from .. import Command
from .format import format_recipe
from .migrate import migrate_recipe

LOG = logging.getLogger(__name__)


class Recipe(Command):
def add_arguments(self, command_parser: Any) -> None:
"""Add arguments to the command parser.

Parameters
----------
command_parser : Any
Command parser object.
"""

command_parser.add_argument("--validate", action="store_true", help="Validate recipe.")
command_parser.add_argument("--format", action="store_true", help="Format the recipe.")
command_parser.add_argument("--migrate", action="store_true", help="Migrate the recipe to the latest version.")

group = command_parser.add_mutually_exclusive_group()
group.add_argument("--inplace", action="store_true", help="Overwrite the recipe file in place.")
group.add_argument("--output", type=str, help="Output file path for the converted recipe.")

command_parser.add_argument(
"path",
help="Path to recipe.",
)

def run(self, args: Any) -> None:

if not args.validate and not args.format and not args.migrate:
args.validate = True

with open(args.path) as file:
config = yaml.safe_load(file)

assert isinstance(config, dict)

if args.validate:
if args.inplace and (not args.format and not args.migrate):
argparse.ArgumentError(None, "--inplace is not supported with --validate.")

if args.output and (not args.format and not args.migrate):
argparse.ArgumentError(None, "--output is not supported with --validate.")

validate_config(config)
LOG.info(f"{args.path}: Recipe is valid.")
return

if args.migrate:
config = migrate_recipe(args, config)
if config is None:
LOG.info(f"{args.path}: No changes needed.")
return

args.format = True

if args.format:
formatted = format_recipe(args, config)
assert "dates" in formatted
f = sys.stdout
if args.output:
f = open(args.output, "w")

if args.inplace:
f = open(args.path, "w")

print(formatted, file=f)
f.close()


command = Recipe
55 changes: 55 additions & 0 deletions src/anemoi/datasets/commands/recipe/format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# (C) Copyright 2025 Anemoi contributors.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.


import datetime
import logging

from ...dumper import yaml_dump

LOG = logging.getLogger(__name__)


def make_dates(config):
if isinstance(config, dict):
return {k: make_dates(v) for k, v in config.items()}
if isinstance(config, list):
return [make_dates(v) for v in config]
if isinstance(config, str):
try:
return datetime.datetime.fromisoformat(config)
except ValueError:
return config
return config


ORDER = (
"name",
"description",
"dataset_status",
"licence",
"attribution",
"env",
"dates",
"common",
"data_sources",
"input",
"output",
"statistics",
"build",
"platform",
)


def format_recipe(args, config: dict) -> str:

config = make_dates(config)
assert config

return yaml_dump(config, order=ORDER)
Loading
Loading