Skip to content

Commit

Permalink
Merge pull request #13 from ecmwf/develop
Browse files Browse the repository at this point in the history
preparing to release
  • Loading branch information
JesperDramsch authored Sep 30, 2024
2 parents 7451df2 + 4f59e35 commit 3e1ded5
Show file tree
Hide file tree
Showing 28 changed files with 489 additions and 154 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGELOG.md merge=union
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# CODEOWNERS file

# Protect workflow files
/.github/ @theissenhelen @jesperdramsch @gmertes
/.pre-commit-config.yaml @theissenhelen @jesperdramsch @gmertes
/pyproject.toml @theissenhelen @jesperdramsch @gmertes
8 changes: 8 additions & 0 deletions .github/ci-hpc-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build:
python: '3.10'
modules:
- ninja
parallel: 64

pytest_cmd: |
python -m pytest -vv -m 'not notebook and not no_cache_init' --cov=. --cov-report=xml
3 changes: 3 additions & 0 deletions .github/workflows/changelog-pr-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches:
- main
- develop
paths-ignore:
- .pre-commit-config.yaml
- .readthedocs.yaml
jobs:
Check-Changelog:
name: Check Changelog Action
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/changelog-release-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# .github/workflows/update-changelog.yaml
name: "Update Changelog"

on:
release:
types: [released]
workflow_dispatch: ~

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
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- 'develop'
tags-ignore:
- '**'
paths:
- "src/**"
- "tests/**"

# Trigger the workflow on pull request
pull_request: ~
Expand All @@ -34,7 +37,7 @@ jobs:
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
uses: ecmwf-actions/downstream-ci/.github/workflows/downstream-ci-hpc.yml@main
with:
anemoi-utils: ecmwf/anemoi-utils@${{ github.event.pull_request.head.sha || github.sha }}
secrets: inherit
41 changes: 7 additions & 34 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,24 @@
name: Upload Python Package

on:

push: {}
pull_request:
release:
types: [created]

jobs:
quality:
name: Code QA
runs-on: ubuntu-latest
steps:
- run: sudo apt-get install -y pandoc # Needed by sphinx for notebooks
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: pre-commit/[email protected]
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-precommit-run.yml@v2
with:
skip-hooks: "no-commit-to-branch"

checks:
strategy:
fail-fast: false
matrix:
platform: ["ubuntu-latest", "macos-latest"]
python-version: ["3.10"]

name: Python ${{ matrix.python-version }} on ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install
run: |
pip install -e .[all,tests]
pip freeze
- name: Tests
run: pytest
python-version: ["3.9", "3.10"]
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}

deploy:

needs: [checks, quality]
uses: ecmwf-actions/reusable-workflows/.github/workflows/cd-pypi.yml@v2
secrets: inherit
23 changes: 23 additions & 0 deletions .github/workflows/python-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Code Quality checks for PRs

on:
push:
pull_request:
types: [opened, synchronize, reopened]

jobs:
quality:
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-precommit-run.yml@v2
with:
skip-hooks: "no-commit-to-branch"

checks:
strategy:
matrix:
python-version: ["3.9", "3.10"]
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ celerybeat.pid

# Environments
.env
.envrc
.venv
env/
venv/
Expand Down
35 changes: 26 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ repos:
- id: no-commit-to-branch # Prevent committing to main / master
- 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/pre-commit/pygrep-hooks
rev: v1.10.0 # Use the ref you want to point at
hooks:
- id: python-use-type-annotations # Check for missing type annotations
- id: python-check-blanket-noqa # Check for # noqa: all
- id: python-no-log-warn # Check for log.warn
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
rev: 24.8.0
hooks:
- id: black
args: [--line-length=120]
Expand All @@ -34,7 +40,7 @@ repos:
- --force-single-line-imports
- --profile black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.6
rev: v0.6.4
hooks:
- id: ruff
# Next line if for documenation cod snippets
Expand All @@ -45,7 +51,7 @@ repos:
- --exit-non-zero-on-fix
- --preview
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v0.9.1
rev: v1.0.0
hooks:
- id: sphinx-lint
# For now, we use it. But it does not support a lot of sphinx features
Expand All @@ -59,12 +65,23 @@ repos:
hooks:
- id: docconvert
args: ["numpy"]
- repo: https://github.com/b8raoult/optional-dependencies-all
rev: "0.0.6"
hooks:
- 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.3"
hooks:
- id: pyproject-fmt
- repo: https://github.com/jshwi/docsig # Check docstrings against function sig
rev: v0.60.1
hooks:
- id: docsig
args:
- --ignore-no-params # Allow docstrings without parameters
- --check-dunders # Check dunder methods
- --check-overridden # Check overridden methods
- --check-protected # Check protected methods
- --check-class # Check class docstrings
- --disable=E113 # Disable empty docstrings
- --summary # Print a summary
ci:
autoupdate_schedule: monthly
ci:
autoupdate_schedule: monthly
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]

### Added
- Codeowners file
- Pygrep precommit hooks
- Docsig precommit hooks
- Changelog merge strategy- Codeowners file
- Create dependency on wcwidth. MIT licence.
- Add anonimize() function.

### Changed
- downstream-ci should only runs for changes in src and tests
- bugfixes for CI
- python3.9 support

### Removed

Expand Down
62 changes: 14 additions & 48 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@
# https://packaging.python.org/en/latest/guides/writing-pyproject-toml/

[build-system]
requires = [
"setuptools>=60",
"setuptools-scm>=8",
]
requires = [ "setuptools>=60", "setuptools-scm>=8" ]

[project]
name = "anemoi-utils"

description = "A package to hold various functions to support training of ML models on ECMWF data."
keywords = [
"ai",
"tools",
]
keywords = [ "ai", "tools" ]

license = { file = "LICENSE" }
authors = [
Expand All @@ -45,35 +39,16 @@ classifiers = [
"Programming Language :: Python :: Implementation :: PyPy",
]

dynamic = [
"version",
]
dynamic = [ "version" ]
dependencies = [
"isodate",

"aniso8601",
"pyyaml",
"tomli", # Only needed before 3.11
"tomli", # Only needed before 3.11
"tqdm",
]

optional-dependencies.all = [
"gitpython",
"nvsmi",
"requests",
"termcolor",
]
optional-dependencies.dev = [
"gitpython",
"nbsphinx",
"nvsmi",
"pandoc",
"pytest",
"requests",
"sphinx",
"sphinx-argparse<0.5",
"sphinx-rtd-theme",
"termcolor",
]
optional-dependencies.all = [ "anemoi-utils[grib,provenance,text]" ]
optional-dependencies.dev = [ "anemoi-utils[all,docs,tests]" ]

optional-dependencies.docs = [
"nbsphinx",
Expand All @@ -85,21 +60,14 @@ optional-dependencies.docs = [
"termcolor",
]

optional-dependencies.grib = [
"requests",
]
optional-dependencies.grib = [ "requests" ]

optional-dependencies.provenance = [
"gitpython",
"nvsmi",
]
optional-dependencies.tests = [
"pytest",
]
optional-dependencies.provenance = [ "gitpython", "nvsmi" ]

optional-dependencies.tests = [ "pytest" ]

optional-dependencies.text = [ "termcolor", "wcwidth" ]

optional-dependencies.text = [
"termcolor",
]
urls.Documentation = "https://anemoi-utils.readthedocs.io/"
urls.Homepage = "https://github.com/ecmwf/anemoi-utils/"
urls.Issues = "https://github.com/ecmwf/anemoi-utils/issues"
Expand All @@ -108,9 +76,7 @@ urls.Repository = "https://github.com/ecmwf/anemoi-utils/"
scripts.anemoi-utils = "anemoi.utils.__main__:main"

[tool.setuptools.package-data]
"anemoi.utils.mars" = [
"*.yaml",
]
"anemoi.utils.mars" = [ "*.yaml" ]

[tool.setuptools_scm]
version_file = "src/anemoi/utils/_version.py"
1 change: 1 addition & 0 deletions src/anemoi/utils/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def cache(key, proc, collection="default", expires=None):


class cached:
"""Decorator to cache the result of a function."""

def __init__(self, collection="default", expires=None):
self.collection = collection
Expand Down
Loading

0 comments on commit 3e1ded5

Please sign in to comment.