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

feat(config)!: Improved configuration and data structures #79

Open
wants to merge 149 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
639025b
feat: dataclasses for training config
theissenhelen Aug 16, 2024
ffbdff4
test: add test for dataclasses
theissenhelen Aug 16, 2024
ad9c178
refactor: unused config values
theissenhelen Sep 10, 2024
bae570c
feat: structured TrainingConfig
theissenhelen Sep 23, 2024
76cd43c
fix: training config not in configstore
theissenhelen Sep 23, 2024
194bac8
feat: HardwareConfig
theissenhelen Sep 23, 2024
3cb472a
fix: missing base config attributes
theissenhelen Sep 24, 2024
cbe84bd
fix: variable names (temporary fix only)
theissenhelen Sep 24, 2024
01d7bc0
feat: add data config schema
theissenhelen Sep 24, 2024
7d5a047
feat: add structured config for gnn
theissenhelen Sep 25, 2024
83fc4d2
feat: structured configs for transformer and graphtransformer
theissenhelen Sep 25, 2024
a623237
feat: extended config schema for model architectures
theissenhelen Sep 26, 2024
6f23137
feat: add diagnostics structured config
theissenhelen Oct 9, 2024
3ffaca2
feat: translate hardware config to pydantic
theissenhelen Oct 24, 2024
de33e0c
feat: translate data to pydantic
theissenhelen Oct 24, 2024
b2f192e
feat: translate training and diagostic to pydantic
theissenhelen Oct 24, 2024
9a05ef3
fix: hydra instantiation
theissenhelen Oct 25, 2024
c98a90b
feat: translate gnn config to pydantic
theissenhelen Oct 30, 2024
25d2c2f
fix: config setup working
theissenhelen Oct 30, 2024
54c731d
fix: type hints
theissenhelen Oct 30, 2024
f953c31
refactor: remove model component
theissenhelen Oct 30, 2024
b352fa1
feat: translate transformer config to pydantic
theissenhelen Oct 31, 2024
caf7b1b
feat: translate GraphTransformerConfig to pydantic
theissenhelen Oct 31, 2024
0c4568f
feat: add target validator
theissenhelen Oct 31, 2024
c44d231
chore: refactor
theissenhelen Oct 31, 2024
674e2d7
feat: add defaults
theissenhelen Oct 31, 2024
4d3ef0c
feat: add basic graph schemas
theissenhelen Nov 8, 2024
0e319a0
refactor: rename IcosahedralNodeSchema
theissenhelen Nov 8, 2024
076617b
feat: add schema for stretched grid
theissenhelen Nov 8, 2024
d3d3674
fix: import error
theissenhelen Nov 8, 2024
561ec39
feat: adjust to new training schema
theissenhelen Nov 11, 2024
98a16c6
refactor: rename
theissenhelen Nov 11, 2024
c704906
fix: spelling
theissenhelen Nov 11, 2024
2e894c1
refactor: adjust callbacks to pydantic
theissenhelen Nov 11, 2024
0ef7471
chore: put graph schema back in
theissenhelen Nov 11, 2024
f449c36
chore(deps): add pydantic
theissenhelen Nov 11, 2024
61fd8c7
fix: import
theissenhelen Nov 11, 2024
5c3c066
fix: missing imports
theissenhelen Nov 12, 2024
e6c3fdd
fix AnyUrl not supported by omegaconf
theissenhelen Nov 12, 2024
2c7b3a9
feat: merge loss and validation metrics schema
theissenhelen Nov 19, 2024
bde85aa
refactor: pressure level scaling config
theissenhelen Nov 20, 2024
af855f5
feat: add dataloader schema
theissenhelen Nov 21, 2024
b9a1690
feat: adjust datamodule to use dataloader schema
theissenhelen Nov 21, 2024
c9ee0af
feat: make Frequency model compatible
theissenhelen Nov 22, 2024
8b16f64
feat: add benchmarkprofiler schema
theissenhelen Nov 22, 2024
872b3eb
feat: config validate command
theissenhelen Nov 22, 2024
c50aa3a
refactor: replace with enum
theissenhelen Nov 25, 2024
5cdb0be
docs: add description to dataloader schema
Dec 2, 2024
a7d95f3
docs: add description to data schema
Dec 4, 2024
3df5eb2
doc: add docstrings
theissenhelen Dec 4, 2024
895a3c7
refactor: move schemas folder up
theissenhelen Dec 4, 2024
4412a19
chore: add autodoc_pydantic
theissenhelen Dec 4, 2024
de4f32f
doc: dosctrings to hardware schemas
theissenhelen Dec 4, 2024
f7fb892
fix: serialising Enums
theissenhelen Dec 4, 2024
9e5ef60
feat: add http_max_retries to config and basemodel
theissenhelen Dec 5, 2024
86a8a9a
feat: set default value of read_group_size
theissenhelen Dec 5, 2024
a9b64e7
feat: accelerator check moves to pydantic hardware schema
theissenhelen Dec 5, 2024
edaa60e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 5, 2024
091ca0b
refactor: replace target validation with Literal
theissenhelen Dec 5, 2024
f445c1b
feat: replace validators with enums
theissenhelen Dec 5, 2024
5ade973
feat: add model_validator to adjust the learning rate to hardware set…
theissenhelen Dec 5, 2024
844cd24
fix: missing configs
theissenhelen Dec 5, 2024
ee3f362
docs: adjust description format for data and dataloader schema
chebertpinard Dec 9, 2024
a9f0a3c
docs: add description to diagnostics schema
chebertpinard Dec 9, 2024
b6cbab2
Merge branch 'develop' into 1-feature-improved-configuration-and-data…
theissenhelen Dec 10, 2024
e3f2ecf
fix: adjust to changes from develop
theissenhelen Dec 12, 2024
6bd4fac
Merge branch '1-feature-improved-configuration-and-data-structures' o…
theissenhelen Dec 12, 2024
937536f
docs: allow Any plot callbacks in diagnostics
chebertpinard Dec 19, 2024
d7a8d93
docs: add description to models schema
chebertpinard Dec 19, 2024
e46a015
Merge commit 'd7a8d93d0ff49ab258c47cc0252f181a24c79ceb' into 1-featur…
theissenhelen Jan 6, 2025
16310f9
fix: missing grid indices
theissenhelen Jan 9, 2025
8e780dd
fix: missing output mask
theissenhelen Jan 9, 2025
2571f59
fix: now running
theissenhelen Jan 9, 2025
cd89e42
feat: add flexible validators for model and model schema
theissenhelen Jan 9, 2025
3e0be01
chore: pre-commit
theissenhelen Jan 9, 2025
80a5d4e
feat: warning instead of validation error if model not defined in anemoi
theissenhelen Jan 10, 2025
aab3e0b
fix: needed to access graph attribute in config
theissenhelen Jan 10, 2025
5490158
refactor: add type to dataset variable in graph TextNodes
chebertpinard Jan 9, 2025
65839ad
docs: Add descriptions to grid indices.
chebertpinard Jan 10, 2025
5fa2d61
docs: complete description to hardware config schema.
chebertpinard Jan 10, 2025
fe4dae9
docs: complete description to training config schema.
chebertpinard Jan 10, 2025
1297328
fix: add missing graph builder schema and description.
chebertpinard Jan 10, 2025
fc25fa2
Merge branch '1-feature-improved-configuration-and-data-structures' o…
theissenhelen Jan 13, 2025
cf3475f
refactor: streamline code
theissenhelen Jan 13, 2025
26a4340
fix: minor bugs
theissenhelen Jan 13, 2025
2524d78
feat: add pytorch activations
theissenhelen Jan 13, 2025
8425db9
refactor: consistent naming
theissenhelen Jan 13, 2025
6e0913f
fix: naming and plot callback initialisation
theissenhelen Jan 13, 2025
ecb6233
refactor: naming
theissenhelen Jan 13, 2025
6107d77
chore: remove AnyStr from Model
theissenhelen Jan 14, 2025
24257d7
docs: add documentation for pydantic
theissenhelen Jan 17, 2025
fc628ac
feat: add no-validate flag
theissenhelen Jan 20, 2025
f3e37e3
feat: check log paths provided for loggers
theissenhelen Jan 20, 2025
1cd4a04
chore(ruff): preserve types for supporting python 3.9
theissenhelen Jan 20, 2025
c435e6a
refafactor(config): no-validation flag
theissenhelen Jan 21, 2025
956e061
docs: add comment on no-validation flag
theissenhelen Jan 21, 2025
4625ed4
fix: dropout not implemented for GraphTransformerProcessor
theissenhelen Jan 21, 2025
87d781b
fix: missing logger custom validation error
theissenhelen Jan 22, 2025
3aa7247
fix: missing model parameters
theissenhelen Jan 23, 2025
98edf14
docs: add pydantic schemas to docs
theissenhelen Jan 23, 2025
74510e8
add more docs for pydantic
anaprietonem Jan 28, 2025
5bf4b27
add more docs for pydantic
anaprietonem Jan 28, 2025
4a7bbbb
add more docs for pydantic
anaprietonem Jan 28, 2025
2450d15
add more docs for pydantic
anaprietonem Jan 28, 2025
3da44eb
Merge branch 'main' into 1-feature-improved-configuration-and-data-st…
anaprietonem Jan 28, 2025
3be6a0d
update graph schemas (#92)
JPXKQX Jan 28, 2025
adbc3c6
update hardware paths to use Path
anaprietonem Jan 29, 2025
8e446e9
add warning to inform about validate command behaviour
anaprietonem Jan 29, 2025
573f249
updating defaults to examples
anaprietonem Jan 29, 2025
a69c4c9
remove defaults from graph schemas
anaprietonem Jan 30, 2025
017bb8d
wip to fix preprocessors, still need fix when multiple are defined at…
anaprietonem Jan 30, 2025
4c35659
Merge branch 'main' into 1-feature-improved-configuration-and-data-st…
anaprietonem Jan 31, 2025
ec1c59d
fix: simplify conversionto omegaconf
theissenhelen Jan 31, 2025
27ddb7c
chore: simplify model_configs and pydantic config
theissenhelen Jan 31, 2025
07157d3
feat: model_construct to skip validation
theissenhelen Jan 31, 2025
20cd3e1
feat: subclass from BaseModel to allow global use of same model_config
theissenhelen Jan 31, 2025
60b9a5c
Merge branch 'model_construct' into 1-feature-improved-configuration-…
theissenhelen Jan 31, 2025
6a5b96c
fix: PR comments
theissenhelen Jan 31, 2025
71f807c
fixes for graphs
anaprietonem Feb 3, 2025
87ff410
stetched grid update
anaprietonem Feb 3, 2025
05ee7da
fixes for defaults in models
anaprietonem Feb 3, 2025
aca728e
fix for missing defaults in dataloader
anaprietonem Feb 3, 2025
4c6c1cb
fixes for deafults in plots
anaprietonem Feb 3, 2025
17ada22
removing config validator for learning rate
anaprietonem Feb 3, 2025
f646da3
add no_validation flag to top-level hierarchical config
anaprietonem Feb 3, 2025
c8a22ef
correct type for load_weights_only
anaprietonem Feb 3, 2025
980debb
update graphs config
JPXKQX Feb 3, 2025
d19389c
remove repeated node_attributes schemas
JPXKQX Feb 3, 2025
17eb470
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 3, 2025
0f1e04a
Merge branch 'main' into 1-feature-improved-configuration-and-data-st…
anaprietonem Feb 3, 2025
6bd7b3a
Merge branch '1-feature-improved-configuration-and-data-structures' o…
theissenhelen Feb 3, 2025
5eec586
remove centre & radius
JPXKQX Feb 3, 2025
bf89a65
added entries for attention configuration
anaprietonem Feb 4, 2025
2dc4bf4
update nodes (gaussian grids)
JPXKQX Feb 4, 2025
b19e167
feat: normalizedReluBounding
theissenhelen Feb 4, 2025
c3baa42
fix: plots not working
theissenhelen Feb 4, 2025
1900b39
fix: normalizer schema working again
theissenhelen Feb 4, 2025
3837e4d
fix: missing trainable_size
theissenhelen Feb 4, 2025
4234d74
fix: hardware paths
theissenhelen Feb 4, 2025
5126b3b
feat: custom errors for missing, extra_forbidden
theissenhelen Feb 4, 2025
625595a
fix: graph schemas not working, rentroducing defaults where they were…
theissenhelen Feb 4, 2025
dcd019b
fix: typos in top-level are picked up
theissenhelen Feb 5, 2025
15bf0e4
fix: model_construct working with model_dump()
theissenhelen Feb 6, 2025
52f5641
Merge branch '1-feature-improved-configuration-and-data-structures' o…
theissenhelen Feb 6, 2025
ffbed46
fix: NPZfile config updated
theissenhelen Feb 6, 2025
fcfcca8
Merge remote-tracking branch 'origin/main' into 1-feature-improved-co…
theissenhelen Feb 6, 2025
d6baeb9
fix typo
JPXKQX Feb 7, 2025
979b672
remove grids from configs
JPXKQX Feb 7, 2025
0f4455c
Merge branch '1-feature-improved-configuration-and-data-structures' o…
theissenhelen Feb 7, 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
2 changes: 0 additions & 2 deletions graphs/src/anemoi/graphs/nodes/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ class NonmissingZarrVariable(BooleanBaseNodeAttribute):
----------
variable : str
Variable to read from the Zarr dataset.
norm : str
Normalization of the weights.
Methods
-------
Expand Down
6 changes: 3 additions & 3 deletions graphs/src/anemoi/graphs/nodes/builders/from_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ class TextNodes(BaseNodeBuilder):
Attributes
----------
dataset : str | DictConfig
The path to txt file containing the coordinates of the nodes.
dataset : str | Path
The path including filename to txt file containing the coordinates of the nodes.
idx_lon : int
The index of the longitude in the dataset.
idx_lat : int
The index of the latitude in the dataset.
"""

def __init__(self, dataset, name: str, idx_lon: int = 0, idx_lat: int = 1) -> None:
def __init__(self, dataset: str | Path, name: str, idx_lon: int = 0, idx_lat: int = 1) -> None:
LOGGER.info("Reading the dataset from %s.", dataset)
self.dataset = dataset
self.idx_lon = idx_lon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(
Graph definition
"""
super().__init__()

model_config = DotDict(model_config)
theissenhelen marked this conversation as resolved.
Show resolved Hide resolved
self._graph_data = graph_data
self._graph_name_data = model_config.graph.data
self._graph_name_hidden = model_config.graph.hidden
Expand Down
8 changes: 8 additions & 0 deletions training/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"sphinx.ext.napoleon",
"sphinxarg.ext",
"sphinx.ext.autosectionlabel",
"sphinxcontrib.autodoc_pydantic",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -133,3 +134,10 @@
todo_include_todos = not read_the_docs_build

autodoc_member_order = "bysource" # Keep file order


# https://autodoc-pydantic.readthedocs.io/en/stable/users/configuration.html

autodoc_pydantic_model_show_json = True
autodoc_pydantic_model_show_field_summary = False
autodoc_pydantic_model_member_order = "bysource"
73 changes: 69 additions & 4 deletions training/docs/dev/hydra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,64 @@
Configuration
###############

Anemoi Training uses Hydra for configuration management, allowing for
flexible and modular configuration of the training pipeline. This guide
explains how to use Hydra effectively in the project.
Anemoi Training uses Hydra and Pydantic for configuration management,
allowing for flexible and modular configuration of the training pipeline
while provide robustness through validation. This guide explains how to
use Hydra and Pydantic effectively in the project.

***************************************
Pydantic and Configuration Validation
***************************************

Pydantic is a package designed for data validation and settings
management. It provides a simple way to define schemas which can be used
to validate configuration files. For example, the following schema can
be used to validate a training configuration:

.. code:: python
from pydantic import BaseModel, Field, PositiveFloat, Literal
class TrainingSchema(BaseModel):
model: Literal{"AlexNet", "ResNet", "VGG"} = Field(default="AlexNet")
"""Model architecture to use for training."""
learning_rate: PositiveFloat = Field(default=0.01)
"""Learning rate."""
loss: str = Field(default="mse")
"""Loss function."""
To allow more complex configurations, Pydantic also supports nested
schemas. For example, the following schema can be used to validate a
configuration with a configurable model:

.. code:: python
from pydantic import BaseModel, Field, PositiveFloat, Literal
from enum import StrEnum
class ActivationFunctions(StrEnum):
relu = "relu"
sigmoid = "sigmoid"
tanh = "tanh"
class ModelSchema(BaseModel):
num_layers: PositiveInt = Field(default=3)
"""Number of layers in the model."""
activation: ActivationFunctions = Field(default="relu")
"""Activation function to use."""
class TrainingSchema(BaseModel):
model: ModelSchema
"""Model configuration."""
learning_rate: PositiveFloat = Field(default=0.01)
"""Learning rate."""
loss: str = Field(default="mse")
"""Loss function."""
If your new feature requires a new configuration parameter, you should
add it to the appropriate schemas and update the configuration files
accordingly.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this new section of the docs will be really useful Helen!

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should also have some documentation/explanation regarding how custom classes outside of anemoi should be suppported?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should be solved by the no-validation flag, but that needs clarification in the docs.


**************
Hydra Basics
Expand Down Expand Up @@ -48,13 +103,23 @@ Configuration in YAML:
algorithm: SGD
learning_rate: 0.01
Pydantic schema:

.. code:: python
from pydantic import BaseModel
class OptimizerSchema(BaseModel):
algorithm: str
learning_rate: float
Instantiating in code:

.. code:: python
from hydra.utils import instantiate
optimizer = instantiate(config.optimizer)
optimizer = instantiate(config.optimizer.model_dump())
********************************************
Configurable Components in Anemoi Training
Expand Down
67 changes: 67 additions & 0 deletions training/docs/modules/schemas.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#########
Schemas
#########

This module defines pydantic schemas, which are used to validate the
configuration before a training run is started. The top-level config
yaml matches the BaseSchema.

.. automodule:: anemoi.training.schemas.base_schema
:members:
:no-undoc-members:
:show-inheritance:

.. automodule:: anemoi.training.schemas.data
:members:
:no-undoc-members:
:show-inheritance:

.. automodule:: anemoi.training.schemas.dataloader
:members:
:no-undoc-members:
:show-inheritance:

.. automodule:: anemoi.training.schemas.hardware
:members:
:no-undoc-members:
:show-inheritance:

.. automodule:: anemoi.training.schemas.graphs.basegraph
:members:
:no-undoc-members:
:show-inheritance:

.. automodule:: anemoi.training.schemas.graphs.node_schemas
:members:
:no-undoc-members:
:show-inheritance:

.. automodule:: anemoi.training.schemas.graphs.edge_schemas
:members:
:no-undoc-members:
:show-inheritance:

.. automodule:: anemoi.training.schemas.models.models
:members:
:no-undoc-members:
:show-inheritance:

.. automodule:: anemoi.training.schemas.models.processor
:members:
:no-undoc-members:
:show-inheritance:

.. automodule:: anemoi.training.schemas.models.encoder
:members:
:no-undoc-members:
:show-inheritance:

.. automodule:: anemoi.training.schemas.models.decoder
:members:
:no-undoc-members:
:show-inheritance:

.. automodule:: anemoi.training.schemas.training
:members:
:no-undoc-members:
:show-inheritance:
8 changes: 8 additions & 0 deletions training/docs/start/hydra-intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,11 @@ The following missing config options which must be overridden by users:
- ``hardware.files.graph``: If you have pre-computed a specific graph,
specify its filename here. Otherwise, a new graph will be constructed
on the fly and written to the filename given.

*********************************
Validation of the Configuration
*********************************

The configuration is validated using `Pydantic` before a training run
starts. To turn this off, you can use the `--no-validation` flag in your
Copy link
Contributor

Choose a reason for hiding this comment

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

I think here I'd propose to have a short config example with the no_validation: True and no_validation: False to explain Pydantic behaviour (happy to help I you'd like)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could you add that example to the docs, please?

top-level config.
135 changes: 135 additions & 0 deletions training/docs/user-guide/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,138 @@ or combine everything together
.. code:: bash
anemoi-training train --config-name=debug.yaml model=transformer diagnostics.plot.enabled=False
********************
Cconfig validation
theissenhelen marked this conversation as resolved.
Show resolved Hide resolved
********************

It is possible to validate your configuration before starting a training
run using the following command:

.. code:: bash
anemoi-training validate --name debug.yaml
This will check that the configuration is valid and that all the
required fields are present. If your config is correctly defined then
the command will show an output similar to:

.. code:: bash
2025-01-28 09:37:23 INFO Validating configs.
2025-01-28 09:37:23 INFO Prepending Anemoi Home (/home_path/.config/anemoi/training/config) to the search path.
2025-01-28 09:37:23 INFO Prepending current user directory (/repos_path/config_anemoi_core) to the search path.
2025-01-28 09:37:23 INFO Search path is now: [provider=anemoi-cwd-searchpath-plugin, path=/repos_path/config_anemoi_core, provider=anemoi-home-searchpath-plugin, path=/home_path/.config/anemoi/training/config, provider=hydra, path=pkg://hydra.conf, provider=main, path=/repos_path/anemoi-core/training/src/anemoi/training/commands]
cfg = BaseSchema(**cfg)
2025-01-28 09:37:23 INFO Config files validated.
Otherwise if there is an issue with some of your configuration fields,
Pydantic will report an error message. See below example where we have a
`debug.yaml` file with a field not correctly indented (in this case the
`diagnostics.log` field):

.. code:: yaml
defaults:
- data: zarr
- dataloader: native_grid
- diagnostics: evaluation
- hardware: example
- graph: multi_scale
- model: transformer # Change from default group
- training: default
- _self_
diagnostics:
log:
mlflow:
enabled: True
offline: True
experiment_name: 'test'
project_name: 'AIFS'
run_name: 'test_anemoi_core'
tracking_uri: 'https://mlflow-server.int'
authentication: True
terminal: True
If we try to validate the above then the validate command will report
the following error:

.. code:: python
2025-01-28 09:37:23 INFO Validating configs.
2025-01-28 09:37:23 INFO Prepending Anemoi Home (/home_path/.config/anemoi/training/config) to the search path.
2025-01-28 09:37:23 INFO Prepending current user directory (/repos_path/config_anemoi_core) to the search path.
2025-01-28 09:37:23 INFO Search path is now: [provider=anemoi-cwd-searchpath-plugin, path=/repos_path/config_anemoi_core, provider=anemoi-home-searchpath-plugin, path=/home_path/.config/anemoi/training/config, provider=hydra, path=pkg://hydra.conf, provider=main, path=/repos_path/anemoi-core/training/src/anemoi/training/commands]
pydantic_core._pydantic_core.ValidationError: 1 validation error for BaseSchema
diagnostics.log
Input should be a valid dictionary or instance of LoggingSchema [type=model_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.10/v/model_type
2025-01-28 09:54:08 ERROR
💣 1 validation error for BaseSchema
diagnostics.log
Input should be a valid dictionary or instance of LoggingSchema [type=model_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.10/v/model_type
2025-01-28 09:54:08 ERROR 💣 Exiting
Which indicates that the `diagnostics.log` field is not correctly
defined as it should be a dictionary or instance of `LoggingSchema`.
Please note there might still be cases not captured by the current
schemas, so it is always good to double check the configuration file
before running the training. See below an example of a config with some
typos that might still need to be fixed manually:
.. code:: yaml
defaults:
- data: zarr
- dataloader: native_grid
- diagnostics: evaluation
- hardware: example
- graph: multi_scale
- model: transformer # Change from default group
- training: default
- _self_
diagnostics:
log:
mlflow:
enabled: True
ofline: True # this is a typo - should be offline
experiment_name: 'test'
project_name: 'AIFS'
run_name: 'test_anemoi_core'
tracking_uri: 'https://mlflow-server.int'
authentication: True
terminal: True
In the example above, if there is a default already defined for
`offline` under `diagnostics: evaluation` then the validation will be
successful, and in the high-level config (ie `debug`) `ofline` it will
just simply not be used, since it has a typo. Otherwise, if there is no
default for `offline` then the validation will fail, with the following
error:
.. code:: python
2025-01-28 09:37:23 INFO Validating configs.
2025-01-28 09:37:23 INFO Prepending Anemoi Home (/home_path/.config/anemoi/training/config) to the search path.
2025-01-28 09:37:23 INFO Prepending current user directory (/repos_path/config_anemoi_core) to the search path.
2025-01-28 09:37:23 INFO Search path is now: [provider=anemoi-cwd-searchpath-plugin, path=/repos_path/config_anemoi_core, provider=anemoi-home-searchpath-plugin, path=/home_path/.config/anemoi/training/config, provider=hydra, path=pkg://hydra.conf, provider=main, path=/repos_path/anemoi-core/training/src/anemoi/training/commands]
pydantic_core._pydantic_core.ValidationError: 1 validation error for BaseSchema
diagnostics.log.mlflow.offline
Field required [type=missing, input_value={'enabled': True, 'authen...onfig'], 'ofline': True}, input_type=DictConfig]
For further information visit https://errors.pydantic.dev/2.10/v/missing
2025-01-28 10:14:49 ERROR
💣 1 validation error for BaseSchema
diagnostics.log.mlflow.offline
Field required [type=missing, input_value={'enabled': True, 'authen...onfig'], 'ofline': True}, input_type=DictConfig]
For further information visit https://errors.pydantic.dev/2.10/v/missing
2025-01-28 10:14:49 ERROR 💣 Exiting
That will indicate that the `offline` field is required and it is
missing from the configuration file. If you identify any issues with the
schemas or missing functionality, please raise an issue on the `Anemoi
Core repository`.
5 changes: 5 additions & 0 deletions training/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies = [
"matplotlib>=3.7.1",
"mlflow>=2.11.1",
"numpy<2", # Pinned until we can confirm it works with anemoi graphs
"pydantic>=2.9",
"pynvml>=11.5",
"pyshtools>=4.10.4",
"pytorch-lightning>=2.1",
Expand All @@ -68,6 +69,7 @@ optional-dependencies.dev = [
"pre-commit>=3.3.3",
]
optional-dependencies.docs = [
"autodoc-pydantic",
"nbsphinx",
"pandoc",
"sphinx",
Expand Down Expand Up @@ -112,6 +114,9 @@ exclude = [ "docs/" ]
preview = true
lint.flake8-import-conventions.extend-aliases."pytorch_lightning" = "pl"
lint.pydocstyle.convention = "numpy"
# Preserve types, even if a file imports `from __future__ import annotations`.
# Necessary for supporting PEP 604 and pydantic with python 3.9
lint.pyupgrade.keep-runtime-typing = true
select = [
"A", # flake8 builtins
# "ANN", # flake8-annotations
Expand Down
Loading
Loading