Skip to content

Commit

Permalink
Merge branch 'develop' into feature/hierarchical-graph
Browse files Browse the repository at this point in the history
  • Loading branch information
JPXKQX committed Oct 23, 2024
2 parents 692865f + 8770ce3 commit 9e40ab8
Show file tree
Hide file tree
Showing 38 changed files with 587 additions and 172 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ jobs:
skip-hooks: "no-commit-to-branch"

checks:
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}

deploy:
needs: [checks, quality]
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/python-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ jobs:
skip-hooks: "no-commit-to-branch"

checks:
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@ Keep it human-readable, your future self will thank you!
## [Unreleased](https://github.com/ecmwf/anemoi-training/compare/0.2.0...HEAD)

### Added
- Mlflow-sync to include new tag for server to server syncing [#83] (https://github.com/ecmwf/anemoi-training/pull/83)
- Mlflow-sync to include functionality to resume and fork server2server runs [#83] (https://github.com/ecmwf/anemoi-training/pull/83)
- Rollout training for Limited Area Models. [#79](https://github.com/ecmwf/anemoi-training/pulls/79)
- Feature: New `Boolean1DMask` class. Enables rollout training for limited area models. [#79](https://github.com/ecmwf/anemoi-training/pulls/79)

### Fixed
- Mlflow-sync to handle creation of new experiments in the remote server [#83] (https://github.com/ecmwf/anemoi-training/pull/83)
- ci: fix pyshtools install error (#100) https://github.com/ecmwf/anemoi-training/pull/100

### Changed
- Update copyright notice

## [0.2.0 - Feature release](https://github.com/ecmwf/anemoi-training/compare/0.1.0...0.2.0) - 2024-10-16

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $ pip install anemoi-training
## License

```
Copyright 2022, European Centre for Medium Range Weather Forecasts.
Copyright 2024, Anemoi contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 4 additions & 1 deletion src/anemoi/training/commands/checkpoint.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
# (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

Expand Down
5 changes: 4 additions & 1 deletion src/anemoi/training/commands/config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
# (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.


from __future__ import annotations

import importlib.resources as pkg_resources
Expand Down
5 changes: 4 additions & 1 deletion src/anemoi/training/commands/mlflow.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
# (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

from anemoi.training.commands import Command
Expand Down
4 changes: 3 additions & 1 deletion src/anemoi/training/commands/train.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# (C) Copyright 2024 ECMWF.
# (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.


from __future__ import annotations

import logging
Expand Down
5 changes: 4 additions & 1 deletion src/anemoi/training/data/datamodule.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
# (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 logging
import os
from functools import cached_property
Expand Down
5 changes: 4 additions & 1 deletion src/anemoi/training/data/dataset.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
# (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.

from __future__ import annotations

import logging
Expand Down
5 changes: 4 additions & 1 deletion src/anemoi/training/data/scaling.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
# (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 logging
from abc import ABC
from abc import abstractmethod
Expand Down
23 changes: 19 additions & 4 deletions src/anemoi/training/diagnostics/callbacks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ def teardown(self, trainer: pl.Trainer, pl_module: pl.LightningModule, stage: st
if self._executor is not None:
self._executor.shutdown(wait=True)

def apply_output_mask(self, pl_module: pl.LightningModule, data: torch.Tensor) -> torch.Tensor:
if hasattr(pl_module, "output_mask") and pl_module.output_mask is not None:
# Fill with NaNs values where the mask is False
data[:, :, ~pl_module.output_mask, :] = np.nan

return data

@abstractmethod
@rank_zero_only
def _plot(
Expand Down Expand Up @@ -682,12 +689,16 @@ def _plot(
...,
pl_module.data_indices.internal_data.output.full,
].cpu()
data = self.post_processors(input_tensor).numpy()
data = self.post_processors(input_tensor)

output_tensor = self.post_processors(
torch.cat(tuple(x[self.sample_idx : self.sample_idx + 1, ...].cpu() for x in outputs[1])),
in_place=False,
).numpy()
)

output_tensor = pl_module.output_mask.apply(output_tensor, dim=2, fill_value=np.nan).numpy()
data[1:, ...] = pl_module.output_mask.apply(data[1:, ...], dim=2, fill_value=np.nan)
data = data.numpy()

for rollout_step in range(pl_module.rollout):
fig = plot_predicted_multilevel_flat_sample(
Expand Down Expand Up @@ -776,11 +787,15 @@ def _plot(
...,
pl_module.data_indices.internal_data.output.full,
].cpu()
data = self.post_processors(input_tensor).numpy()
data = self.post_processors(input_tensor)
output_tensor = self.post_processors(
torch.cat(tuple(x[self.sample_idx : self.sample_idx + 1, ...].cpu() for x in outputs[1])),
in_place=False,
).numpy()
)

output_tensor = pl_module.output_mask.apply(output_tensor, dim=2, fill_value=np.nan).numpy()
data[1:, ...] = pl_module.output_mask.apply(data[1:, ...], dim=2, fill_value=np.nan)
data = data.numpy()

for rollout_step in range(pl_module.rollout):
if self.config.diagnostics.plot.parameters_histogram is not None:
Expand Down
16 changes: 10 additions & 6 deletions src/anemoi/training/diagnostics/logger.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
# (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.

from __future__ import annotations

import logging
Expand All @@ -25,7 +28,6 @@ def get_mlflow_logger(config: DictConfig) -> None:
return None

from anemoi.training.diagnostics.mlflow.logger import AnemoiMLflowLogger
from anemoi.training.diagnostics.mlflow.logger import get_mlflow_run_params

resumed = config.training.run_id is not None
forked = config.training.fork_run_id is not None
Expand All @@ -39,7 +41,6 @@ def get_mlflow_logger(config: DictConfig) -> None:
tracking_uri = save_dir
# create directory if it does not exist
Path(config.hardware.paths.logs.mlflow).mkdir(parents=True, exist_ok=True)
run_id, run_name, tags = get_mlflow_run_params(config, tracking_uri)

log_hyperparams = True
if resumed and not config.diagnostics.log.mlflow.on_resume_create_child:
Expand All @@ -53,19 +54,22 @@ def get_mlflow_logger(config: DictConfig) -> None:
)
log_hyperparams = False

LOGGER.info("AnemoiMLFlow logging to %s", tracking_uri)
logger = AnemoiMLflowLogger(
experiment_name=config.diagnostics.log.mlflow.experiment_name,
project_name=config.diagnostics.log.mlflow.project_name,
tracking_uri=tracking_uri,
save_dir=save_dir,
run_name=run_name,
run_id=run_id,
run_name=config.diagnostics.log.mlflow.run_name,
run_id=config.training.run_id,
fork_run_id=config.training.fork_run_id,
log_model=config.diagnostics.log.mlflow.log_model,
offline=offline,
tags=tags,
resumed=resumed,
forked=forked,
log_hyperparams=log_hyperparams,
authentication=config.diagnostics.log.mlflow.authentication,
on_resume_create_child=config.diagnostics.log.mlflow.on_resume_create_child,
)
config_params = OmegaConf.to_container(config, resolve=True)

Expand Down
5 changes: 4 additions & 1 deletion src/anemoi/training/diagnostics/maps.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
# (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 copy
import json
import logging
Expand Down
5 changes: 4 additions & 1 deletion src/anemoi/training/diagnostics/mlflow/auth.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
# (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.


from __future__ import annotations

import logging
Expand Down
5 changes: 4 additions & 1 deletion src/anemoi/training/diagnostics/mlflow/client.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
# (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.


from __future__ import annotations

from typing import Any
Expand Down
Loading

0 comments on commit 9e40ab8

Please sign in to comment.