Skip to content

Commit

Permalink
Merge branch 'master' into mobt802_lightning_cell_method_consistency …
Browse files Browse the repository at this point in the history
…to resolve Github action failures folowing known bug fix
  • Loading branch information
maxwhitemet committed Dec 17, 2024
2 parents 94c632f + 9b2db98 commit 41b7f5c
Show file tree
Hide file tree
Showing 13 changed files with 450 additions and 160 deletions.
75 changes: 27 additions & 48 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: CI Tests
on:
pull_request:
push:
branches:
- master # Run tests only when changes are pushed to 'default'
workflow_dispatch:
jobs:
Sphinx-Pytest-Coverage:
Expand All @@ -14,56 +16,44 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
id: cache
with:
path: /usr/share/miniconda/envs/im${{ matrix.env }}
key: ${{ format('{0}-conda-improver-{1}-{2}', runner.os, matrix.env, hashFiles(format('envs/{0}.yml', matrix.env))) }}

- name: conda env update
if: steps.cache.outputs.cache-hit != 'true'
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda update -q -n base -c defaults conda
conda install -q -n base -c conda-forge -c nodefaults mamba
rm -f /usr/share/miniconda/pkgs/cache/*.json # workaround for mamba-org/mamba#488
mamba env create -q --file envs/${{ matrix.env }}.yml --name im${{ matrix.env }}
- name: Environment creation
uses: mamba-org/setup-micromamba@v2
with:
environment-file: envs/${{ matrix.env }}.yml
init-shell: bash
cache-environment: true

- name: conda info
- name: Environment info
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
conda info
conda list
micromamba info
micromamba list
shell: bash -el {0}

- name: sphinx documentation
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
make -C doc html SPHINXOPTS="-W --keep-going"
shell: micromamba-shell {0}

- name: pytest without coverage
if: matrix.env == 'conda-forge'
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
pytest
shell: micromamba-shell {0}

- name: pytest with coverage
if: matrix.env != 'conda-forge'
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
pytest --cov=improver --cov-report xml:coverage.xml
shell: micromamba-shell {0}

- name: codacy upload
if: env.CODACY_PROJECT_TOKEN && matrix.env == 'environment_a'
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
python-codacy-coverage -v -r coverage.xml
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
shell: micromamba-shell {0}

- name: codecov upload
uses: codecov/codecov-action@v5
Expand Down Expand Up @@ -133,36 +123,25 @@ jobs:

- uses: actions/checkout@v4

- uses: actions/cache@v4
id: cache
- name: Environment creation
uses: mamba-org/setup-micromamba@v2
with:
path: /usr/share/miniconda/envs/im${{ matrix.env }}
key: ${{ format('{0}-conda-improver-{1}-{2}', runner.os, matrix.env, hashFiles(format('envs/{0}.yml', matrix.env))) }}

- name: conda env update
if: steps.cache.outputs.cache-hit != 'true'
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda update -q -n base -c defaults conda
conda install -q -n base -c conda-forge mamba
rm -f /usr/share/miniconda/pkgs/cache/*.json # workaround for mamba-org/mamba#488
mamba env create -q --file envs/${{ matrix.env }}.yml --name im${{ matrix.env }}
environment-file: envs/${{ matrix.env }}.yml
init-shell: bash
cache-environment: true

- name: conda info
- name: Environment info
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
conda info
conda list
micromamba info
micromamba list
shell: bash -el {0}

- name: safety
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
safety check || true
shell: micromamba-shell {0}

- name: bandit
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
bandit -r improver
shell: micromamba-shell {0}
119 changes: 55 additions & 64 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,113 +6,104 @@ on:
schedule:
- cron: '7 4 * * *'
workflow_dispatch:

jobs:
Sphinx-Pytest-Coverage:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
env: [latest]

if: github.repository_owner == 'metoppv'
steps:

- uses: actions/checkout@v4
- name: conda env update
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda update -q -n base -c defaults conda
conda install -q -n base -c conda-forge -c nodefaults mamba
rm -f /usr/share/miniconda/pkgs/cache/*.json # workaround for mamba-org/mamba#488
mamba env create -q --file envs/${{ matrix.env }}.yml --name im${{ matrix.env }}
- name: conda info

- name: Environment creation
uses: mamba-org/setup-micromamba@v2
with:
environment-file: envs/${{ matrix.env }}.yml
init-shell: bash
cache-environment: true

- name: Environment info
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
conda info
conda list
micromamba info
micromamba list
shell: bash -el {0}

- name: sphinx documentation
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
make -C doc html SPHINXOPTS="-W --keep-going"
shell: micromamba-shell {0}

- name: pytest without coverage
if: matrix.env != 'environment_a'
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
pytest
- name: pytest with coverage
if: matrix.env == 'environment_a'
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
pytest --cov=improver --cov-report xml:coverage.xml
- name: codacy upload
if: env.CODACY_PROJECT_TOKEN && matrix.env == 'environment_a'
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
python-codacy-coverage -v -r coverage.xml
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
- name: codecov upload
uses: codecov/codecov-action@v5
if: matrix.env == 'environment_a'
shell: micromamba-shell {0}

Safety-Bandit:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
env: [latest]

if: github.repository_owner == 'metoppv'
steps:

- uses: actions/checkout@v4
- name: conda env update
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda update -q -n base -c defaults conda
conda install -q -n base -c conda-forge -c nodefaults mamba
rm -f /usr/share/miniconda/pkgs/cache/*.json # workaround for mamba-org/mamba#488
mamba env create -q --file envs/${{ matrix.env }}.yml --name im${{ matrix.env }}
- name: conda info

- name: Environment creation
uses: mamba-org/setup-micromamba@v2
with:
environment-file: envs/${{ matrix.env }}.yml
init-shell: bash
cache-environment: true

- name: Environment info
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
conda info
conda list
micromamba info
micromamba list
shell: bash -el {0}

- name: safety
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
safety check || true
shell: micromamba-shell {0}

- name: bandit
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
bandit -r improver
shell: micromamba-shell {0}

Type-checking:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
env: [latest]

if: github.repository_owner == 'metoppv'
steps:

- uses: actions/checkout@v4
- name: conda env update
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda update -q -n base -c defaults conda
conda install -q -n base -c conda-forge -c nodefaults mamba
rm -f /usr/share/miniconda/pkgs/cache/*.json # workaround for mamba-org/mamba#488
mamba env create -q --file envs/${{ matrix.env }}.yml --name im${{ matrix.env }}
- name: conda info

- name: Environment creation
uses: mamba-org/setup-micromamba@v2
with:
environment-file: envs/${{ matrix.env }}.yml
init-shell: bash
cache-environment: true

- name: Environment info
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
conda info
conda list
micromamba info
micromamba list
shell: bash -el {0}

- name: mypy
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate im${{ matrix.env }}
mypy improver || true
shell: micromamba-shell {0}
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Meabh NicGuidhir <[email protected]> <meabh.nicguidhir@metoffice
Neil Crosswaite <[email protected]> <[email protected]>
Paul Abernethy <[email protected]> <[email protected]>
Peter Jordan <[email protected]> <[email protected]>
Phil Relton <[email protected]> <[email protected]>
Phoebe Lambert <[email protected]> <[email protected]>
Sam Griffiths <[email protected]> <[email protected]>
Shafiat Dewan <[email protected]> <[email protected]>
Shubhendra Singh Chauhan <[email protected]> <[email protected]>
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ below:
- Caroline Jones (Met Office, UK)
- Peter Jordan (Met Office, UK)
- Bruno P. Kinoshita (NIWA, NZ)
- Phoebe Lambert (Met Office, UK)
- Lucy Liu (Bureau of Meteorology, Australia)
- Daniel Mentiplay (Bureau of Meteorology, Australia)
- Stephen Moseley (Met Office, UK)
- Meabh NicGuidhir (Met Office, UK)
- Benjamin Owen (Bureau of Meteorology, Australia)
- Carwyn Pelley (Met Office, UK)
- Tim Pillinger (Met Office, UK)
- Phil Relton (Met Office, UK)
- Fiona Rust (Met Office, UK)
- Chris Sampson (Met Office, UK)
- Caroline Sandford (Met Office, UK)
Expand Down
1 change: 1 addition & 0 deletions envs/conda-forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
- bandit
- filelock
- pytest
- setuptools
- sphinx-autodoc-typehints
- sphinx_rtd_theme
- threadpoolctl
Expand Down
3 changes: 2 additions & 1 deletion envs/environment_a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: improver_a
channels:
- conda-forge
- main
dependencies:
- python=3.7
# Required
Expand Down Expand Up @@ -37,4 +38,4 @@ dependencies:
- safety
- sphinx-autodoc-typehints
- sphinx_rtd_theme
- threadpoolctl
- threadpoolctl
10 changes: 10 additions & 0 deletions improver/standardise.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@ def _discard_redundant_cell_methods(cube: Cube) -> None:

cube.cell_methods = updated_cms

@staticmethod
def _remove_long_name_if_standard_name(cube: Cube) -> None:
"""
Remove the long_name attribute from cubes if the cube also has a standard_name defined
"""

if cube.standard_name and cube.long_name:
cube.long_name = None

def process(self, cube: Cube) -> Cube:
"""
Perform compulsory and user-configurable metadata adjustments. The
Expand Down Expand Up @@ -269,6 +278,7 @@ def process(self, cube: Cube) -> Cube:
if self._attributes_dict:
amend_attributes(cube, self._attributes_dict)
self._discard_redundant_cell_methods(cube)
self._remove_long_name_if_standard_name(cube)

# this must be done after unit conversion as if the input is an integer
# field, unit conversion outputs the new data as float64
Expand Down
Loading

0 comments on commit 41b7f5c

Please sign in to comment.