diff --git a/.github/ci-config.yml b/.github/ci-config.yml new file mode 100644 index 0000000..f712f26 --- /dev/null +++ b/.github/ci-config.yml @@ -0,0 +1,3 @@ +dependency_branch: develop +parallelism_factor: 8 +self_build: false # Only for python packages diff --git a/.github/workflows/changelog-release-update.yml b/.github/workflows/changelog-release-update.yml new file mode 100644 index 0000000..79b85ad --- /dev/null +++ b/.github/workflows/changelog-release-update.yml @@ -0,0 +1,34 @@ +# .github/workflows/update-changelog.yaml +name: "Update Changelog" + +on: + release: + types: [released] + +permissions: + pull-requests: write + contents: write + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.target_commitish }} + + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@v1 + with: + latest-version: ${{ github.event.release.tag_name }} + heading-text: ${{ github.event.release.name }} + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + branch: docs/changelog-update-${{ github.event.release.tag_name }} + title: '[Changelog] Update to ${{ github.event.release.tag_name }}' + add-paths: | + CHANGELOG.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5867ee0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: ci + +on: + # Trigger the workflow on push to master or develop, except tag creation + push: + branches: + - 'main' + - 'develop' + tags-ignore: + - '**' + paths: + - "src/**" + - "tests/**" + + # Trigger the workflow on pull request + pull_request: ~ + + # Trigger the workflow manuallyp instals + workflow_dispatch: ~ + + # Trigger after public PR approved for CI + pull_request_target: + types: [labeled] + +jobs: + # Run CI including downstream packages on self-hosted runners + downstream-ci: + name: downstream-ci + if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }} + uses: ecmwf-actions/downstream-ci/.github/workflows/downstream-ci.yml@main + with: + anemoi-models: ecmwf/anemoi-models@${{ github.event.pull_request.head.sha || github.sha }} + codecov_upload: true + secrets: inherit + + # Build downstream packages on HPC + downstream-ci-hpc: + name: downstream-ci-hpc + if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }} + uses: ecmwf-actions/downstream-ci/.github/workflows/downstream-ci.yml@main + with: + anemoi-models: ecmwf/anemoi-models@${{ github.event.pull_request.head.sha || github.sha }} + secrets: inherit diff --git a/.github/workflows/label-public-pr.yml b/.github/workflows/label-public-pr.yml new file mode 100644 index 0000000..59b2bfa --- /dev/null +++ b/.github/workflows/label-public-pr.yml @@ -0,0 +1,10 @@ +# Manage labels of pull requests that originate from forks +name: label-public-pr + +on: + pull_request_target: + types: [opened, synchronize] + +jobs: + label: + uses: ecmwf-actions/reusable-workflows/.github/workflows/label-pr.yml@v2 diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 666f65d..de01bf6 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -35,7 +35,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -48,27 +48,6 @@ jobs: run: pytest deploy: - - if: ${{ github.event_name == 'release' }} - runs-on: ubuntu-latest needs: [checks, quality] - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build wheel twine - - name: Build and publish - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} - run: | - python -m build - twine upload dist/* + uses: ecmwf-actions/reusable-workflows/.github/workflows/cd-pypi.yml@v2 + secrets: inherit diff --git a/.github/workflows/readthedocs-pr-update.yml b/.github/workflows/readthedocs-pr-update.yml new file mode 100644 index 0000000..264c405 --- /dev/null +++ b/.github/workflows/readthedocs-pr-update.yml @@ -0,0 +1,22 @@ +name: Read the Docs PR Preview +on: + pull_request_target: + types: + - opened + - synchronize + - reopened + # Execute this action only on PRs that touch + # documentation files. + paths: + - "docs/**" + +permissions: + pull-requests: write + +jobs: + documentation-links: + runs-on: ubuntu-latest + steps: + - uses: readthedocs/actions/preview@v1 + with: + project-slug: "anemoi-models" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4b6367..9dc25d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: - id: check-added-large-files # Check for large files added to git - id: check-merge-conflict # Check for files that contain merge conflict - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.2 + rev: 24.8.0 hooks: - id: black args: [--line-length=120] @@ -34,7 +34,7 @@ repos: - --force-single-line-imports - --profile black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.6 + rev: v0.6.2 hooks: - id: ruff # Next line if for documenation cod snippets @@ -65,6 +65,6 @@ repos: - id: optional-dependencies-all args: ["--inplace", "--exclude-keys=dev,docs,tests", "--group=dev=all,docs,tests"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "2.1.3" + rev: "2.2.1" hooks: - id: pyproject-fmt diff --git a/CHANGELOG.md b/CHANGELOG.md index 661ed93..73713be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,12 +11,28 @@ Keep it human-readable, your future self will thank you! ## [Unreleased] ### Added + - CI workflow to update the changelog on release ### Changed + - Update CI to inherit from common infrastructue reusable workflows + - run downstream-ci only when src and tests folders have changed + - New error messages for wrongs graphs. + +### Removed + +## [0.2.1] - Dependency update + +### Added + +- downstream-ci pipeline +- readthedocs PR update check action + ### Removed -## 0.2.0 +- anemoi-datasets dependency + +## [0.2.0] - Support Heterodata ### Added @@ -26,18 +42,15 @@ Keep it human-readable, your future self will thank you! - Updated to support new PyTorch Geometric HeteroData structure (defined by `anemoi-graphs` package). -### Removed - -## 0.1.0 Initial Release +## [0.1.0] - Initial Release ### Added - Documentation - Initial code release with models, layers, distributed, preprocessing, and data_indices - Added Changelog -### Changed - -### Removed - -## Git Diffs: + +[unreleased]: https://github.com/ecmwf/anemoi-models/compare/0.2.1...HEAD +[0.2.1]: https://github.com/ecmwf/anemoi-models/compare/0.2.0...0.2.1 +[0.2.0]: https://github.com/ecmwf/anemoi-models/compare/0.1.0...0.2.0 [0.1.0]: https://github.com/ecmwf/anemoi-models/releases/tag/0.1.0 diff --git a/pyproject.toml b/pyproject.toml index 66e617b..05a99c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,6 @@ dynamic = [ "version", ] dependencies = [ - "anemoi-datasets>=0.2.1", "anemoi-utils>=0.1.9", "einops>=0.6.1", "hydra-core>=1.3", diff --git a/src/anemoi/models/layers/mapper.py b/src/anemoi/models/layers/mapper.py index 04efdf0..0967041 100644 --- a/src/anemoi/models/layers/mapper.py +++ b/src/anemoi/models/layers/mapper.py @@ -134,8 +134,8 @@ def _register_edges( trainable_size : int Trainable tensor size """ - if edge_attributes is None: - raise ValueError("Edge attributes must be provided") + assert sub_graph, f"{self.__class__.__name__} needs a valid sub_graph to register edges." + assert edge_attributes is not None, "Edge attributes must be provided" edge_attr_tensor = torch.cat([sub_graph[attr] for attr in edge_attributes], axis=1)