Skip to content

Commit

Permalink
Merge pull request #4 from ecmwf/chore/multiple-fixes-ci-precommit
Browse files Browse the repository at this point in the history
Chore/multiple fixes ci precommit
  • Loading branch information
theissenhelen authored Nov 20, 2024
2 parents fa4f186 + 5447402 commit def5b0c
Show file tree
Hide file tree
Showing 18 changed files with 125 additions and 56 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
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
36 changes: 36 additions & 0 deletions .github/workflows/changelog-release-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# .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
42 changes: 6 additions & 36 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,26 @@
---
# 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: 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/action@v3.0.1
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: |
# disable tests on github to avoid giving away the token
# cd tests && python3 test_all.py
python-version: ["3.9", "3.10"]
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2

deploy:

needs: [checks, quality]
uses: ecmwf-actions/reusable-workflows/.github/workflows/cd-pypi.yml@v2
secrets: inherit
19 changes: 19 additions & 0 deletions .github/workflows/python-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
# This workflow will upload a Python Package using Twine when a release is created from main
# 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:
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
5 changes: 5 additions & 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 Expand Up @@ -186,3 +187,7 @@ _build/
*.sync
_version.py
*.code-workspace


# Environments
.envrc
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ 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.10.0
hooks:
Expand Down Expand Up @@ -62,3 +68,17 @@ repos:
rev: "v2.5.0"
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
25 changes: 5 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@
# nor does it submit to any jurisdiction.

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

[project]
name = "anemoi-registry"

description = "A package to manage a registry or data-driven forecasts."
keywords = [
"ai",
"registry",
"tools",
]
keywords = [ "ai", "registry", "tools" ]

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

dynamic = [
"version",
]
dynamic = [ "version" ]

dependencies = [
"anemoi-datasets",
"jsonpatch",
"requests",
]
dependencies = [ "anemoi-datasets", "jsonpatch", "requests" ]

optional-dependencies.all = [
"boto3",
Expand Down Expand Up @@ -92,9 +79,7 @@ urls.Repository = "https://github.com/ecmwf/anemoi-registry/"
scripts.anemoi-registry = "anemoi.registry.__main__:main_PYTHON_ARGCOMPLETE_OK"

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

[tool.setuptools_scm]
version_file = "src/anemoi/registry/_version.py"
2 changes: 2 additions & 0 deletions src/anemoi/registry/entry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class CatalogueEntryNotFound(Exception):


class CatalogueEntry:
"""Base class for a Anemoi catalogue entry."""

record = None
path = None
key = None
Expand Down
4 changes: 4 additions & 0 deletions src/anemoi/registry/entry/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@


class DatasetCatalogueEntryList(RestItemList):
"""List of dataset catalogue entries."""

def __init__(self, **kwargs):
super().__init__(COLLECTION, **kwargs)

Expand All @@ -37,6 +39,8 @@ def __iter__(self):


class DatasetCatalogueEntry(CatalogueEntry):
"""A dataset catalogue entry."""

collection = COLLECTION
main_key = "name"

Expand Down
4 changes: 4 additions & 0 deletions src/anemoi/registry/entry/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@


class ExperimentCatalogueEntryList(RestItemList):
"""List of ExperimentCatalogueEntry objects."""

def __init__(self, **kwargs):
super().__init__(COLLECTION, **kwargs)

Expand All @@ -40,6 +42,8 @@ def __iter__(self):


class ExperimentCatalogueEntry(CatalogueEntry):
"""Catalogue entry for an experiment."""

collection = COLLECTION
main_key = "expver"

Expand Down
2 changes: 2 additions & 0 deletions src/anemoi/registry/entry/weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@


class WeightsCatalogueEntryList(RestItemList):
"""List of weights catalogue entries."""

def __init__(self, **kwargs):
super().__init__(COLLECTION, **kwargs)

Expand Down
6 changes: 6 additions & 0 deletions src/anemoi/registry/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def trace_info():


class Rest:
"""REST API client."""

def __init__(self):
self.session = requests.Session()
self.session.headers.update({"Authorization": f"Bearer {self.token}"})
Expand Down Expand Up @@ -154,6 +156,8 @@ def raise_for_status(self, r, errors={}):


class RestItem:
"""Single catalogue entry from REST API."""

def __init__(self, collection, key):
self.collection = collection
self.key = key
Expand Down Expand Up @@ -188,6 +192,8 @@ def __repr__(self):


class RestItemList:
"""List of catalogue entries from REST API."""

def __init__(self, collection):
self.collection = collection
self.rest = Rest()
Expand Down
2 changes: 2 additions & 0 deletions src/anemoi/registry/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@


class TaskCatalogueEntryList:
"""List of task catalogue entries."""

collection = "tasks"
main_key = "uuid"

Expand Down
2 changes: 2 additions & 0 deletions src/anemoi/registry/workers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@


class Worker:
"""Base class for a worker that processes tasks in the queue."""

name = None

def __init__(
Expand Down
2 changes: 2 additions & 0 deletions src/anemoi/registry/workers/delete_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@


class DeleteDatasetWorker(Worker):
"""Worker to delete a dataset from a platform."""

name = "delete-dataset"

def __init__(
Expand Down
2 changes: 2 additions & 0 deletions src/anemoi/registry/workers/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@


class DummyWorker(Worker):
"""A debug worker that logs the task it receives."""

name = "dummy"

def __init__(self, arg, **kwargs):
Expand Down
4 changes: 4 additions & 0 deletions src/anemoi/registry/workers/transfer_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@


class Progress:
"""Progress reporter for transfer tasks."""

latest = None

def __init__(self, task, frequency=60):
Expand Down Expand Up @@ -65,6 +67,8 @@ def __call__(self, number_of_files, total_size, total_transferred, transfering,


class TransferDatasetWorker(Worker):
"""Worker to transfer a dataset from one platform to another."""

name = "transfer-dataset"

def __init__(
Expand Down

0 comments on commit def5b0c

Please sign in to comment.