Skip to content

Commit

Permalink
Merge branch 'main' into lazy-extract-levels
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriupredoi committed May 26, 2023
2 parents 6f5f6d2 + 83b12a2 commit efbb7e3
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 42 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/install-from-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ name: Install from conda-forge

# runs on a push on main and at the end of every day
on:
# triggering on push without branch name will run tests everytime
# triggering on push without branch name will run tests every time
# there is a push on any branch
# turn it on only if needed
push:
branches:
- main
- main
# run the test only if the PR is to main
# turn it on if required
# pull_request:
Expand All @@ -35,9 +35,9 @@ jobs:
strategy:
matrix:
# TODO add "3.11" once we have the package built
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10"]
# fail-fast set to False allows all other tests
# in the worflow to run regardless of any fail
# in the workflow to run regardless of any fail
fail-fast: false
name: Linux Python ${{ matrix.python-version }}
steps:
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
runs-on: "macos-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10"]
fail-fast: false
name: OSX Python ${{ matrix.python-version }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/install-from-condalock-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: Conda-lock Install
on:
push:
branches:
- main
- main
# run the test only if the PR is to main
# turn it on if required
#pull_request:
Expand All @@ -24,7 +24,7 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
fail-fast: false
name: Linux Python ${{ matrix.python-version }}
steps:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/install-from-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
# turn it on only if needed
push:
branches:
- main
- main
# run the test only if the PR is to main
# turn it on if required
#pull_request:
Expand All @@ -35,7 +35,7 @@ jobs:
strategy:
matrix:
# TODO add "3.11" once we have the package built
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10"]
# fail-fast set to False allows all other tests
# in the workflow to run regardless of any fail
fail-fast: false
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
runs-on: "macos-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10"]
fail-fast: false
name: OSX Python ${{ matrix.python-version }}
steps:
Expand All @@ -103,8 +103,8 @@ jobs:
run: pip install esmvalcore 2>&1 | tee pip_install_osx_artifacts_python_${{ matrix.python-version }}/install.txt
- name: Verify installation
shell: bash -l {0}
run: |
esmvaltool --help
run: |
esmvaltool --help
esmvaltool version 2>&1 | tee pip_install_osx_artifacts_python_${{ matrix.python-version }}/version.txt
- name: Upload artifacts
if: ${{ always() }} # upload artifacts even if fail
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/install-from-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ name: Install from Source

# runs on a push on main and at the end of every day
on:
# triggering on push without branch name will run tests everytime
# triggering on push without branch name will run tests every time
# there is a push on any branch
# turn it on only if needed
push:
branches:
- main
- main
# run the test only if the PR is to main
# turn it on if required
#pull_request:
Expand All @@ -32,7 +32,7 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
fail-fast: false
name: Linux Python ${{ matrix.python-version }}
steps:
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
runs-on: "macos-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
fail-fast: false
name: OSX Python ${{ matrix.python-version }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10"]
fail-fast: false
name: Linux Python ${{ matrix.python-version }}
if: ${{ github.event.issue.pull_request && github.event.comment.body == '@runGAtests' }}
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
runs-on: "macos-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10"]
fail-fast: false
name: OSX Python ${{ matrix.python-version }}
if: ${{ github.event.issue.pull_request && github.event.comment.body == '@runGAtests' }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests-monitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
fail-fast: false
name: Linux Python ${{ matrix.python-version }}
steps:
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
runs-on: "macos-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
fail-fast: false
name: OSX Python ${{ matrix.python-version }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
fail-fast: false
name: Linux Python ${{ matrix.python-version }}
steps:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
runs-on: "macos-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
fail-fast: false
name: OSX Python ${{ matrix.python-version }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[![Github Actions Test](https://github.com/ESMValGroup/ESMValCore/actions/workflows/run-tests.yml/badge.svg)](https://github.com/ESMValGroup/ESMValCore/actions/workflows/run-tests.yml)
[![Github Actions Dashboard](https://api.meercode.io/badge/ESMValGroup/ESMValCore?type=ci-success-rate&branch=main&lastDay=14)](https://meercode.io)

![esmvaltoollogo](https://github.com/ESMValGroup/ESMValCore/blob/main/doc/figures/ESMValTool-logo-2.png)
![esmvaltoollogo](https://raw.githubusercontent.com/ESMValGroup/ESMValCore/main/doc/figures/ESMValTool-logo-2.png)

ESMValCore: core functionalities for the ESMValTool, a community diagnostic
and performance metrics tool for routine evaluation of Earth System Models
Expand Down
1 change: 1 addition & 0 deletions doc/api/esmvalcore.cmor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Checking compliance
-------------------

.. automodule:: esmvalcore.cmor.check
:no-inherited-members:
:member-order: bysource

Automatically fixing issues
Expand Down
2 changes: 0 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
# github.com/readthedocs/sphinx_rtd_theme/issues/1451
'sphinxcontrib.jquery',
]

autodoc_default_options = {
Expand Down
11 changes: 11 additions & 0 deletions doc/develop/fixing_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ called by the preprocessor functions
:py:func:`esmvalcore.preprocessor.fix_metadata`, and
:py:func:`esmvalcore.preprocessor.fix_data`.

The :class:`~esmvalcore.cmor._fixes.fix.Fix` class provides the following
attributes:

- :attr:`Fix.vardef`: :class:`~esmvalcore.cmor.table.VariableInfo` object that
corresponds to the variable fixed by the fix.
- :attr:`Fix.extra_facets`: :obj:`dict` that contains all facets of the
corresponding dataset fixed by the fix (see
:attr:`esmvalcore.dataset.Dataset.facets`).
- :attr:`Fix.session`: :class:`~esmvalcore.config.Session` object that includes
configuration and directory information.

Fixing a dataset
================

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies:
- psutil
- py-cordex
- pybtex
- python>=3.8
- python>=3.9
- python-stratify>=0.3
- pyyaml
- requests
Expand Down
44 changes: 35 additions & 9 deletions esmvalcore/cmor/_fixes/fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,43 @@
import inspect
import tempfile
from pathlib import Path
from typing import TYPE_CHECKING, Optional

from ..table import CMOR_TABLES

if TYPE_CHECKING:
from ...config import Session
from ..table import VariableInfo


class Fix:
"""Base class for dataset fixes."""

def __init__(self, vardef, extra_facets=None):
def __init__(
self,
vardef: VariableInfo,
extra_facets: Optional[dict] = None,
session: Optional[Session] = None,
):
"""Initialize fix object.
Parameters
----------
vardef: str
vardef: VariableInfo
CMOR table entry.
extra_facets: dict, optional
Extra facets are mainly used for data outside of the big projects
like CMIP, CORDEX, obs4MIPs. For details, see :ref:`extra_facets`.
session: Session, optional
Current session which includes configuration and directory
information.
"""
self.vardef = vardef
if extra_facets is None:
extra_facets = {}
self.extra_facets = extra_facets
self.session = session

def fix_file(
self,
Expand Down Expand Up @@ -136,7 +150,14 @@ def __ne__(self, other):
return not self.__eq__(other)

@staticmethod
def get_fixes(project, dataset, mip, short_name, extra_facets=None):
def get_fixes(
project: str,
dataset: str,
mip: str,
short_name: str,
extra_facets: Optional[dict] = None,
session: Optional[Session] = None,
) -> list:
"""Get the fixes that must be applied for a given dataset.
It will look for them at the module
Expand All @@ -163,6 +184,9 @@ def get_fixes(project, dataset, mip, short_name, extra_facets=None):
extra_facets: dict, optional
Extra facets are mainly used for data outside of the big projects
like CMIP, CORDEX, obs4MIPs. For details, see :ref:`extra_facets`.
session: Session, optional
Current session which includes configuration and directory
information.
Returns
-------
Expand Down Expand Up @@ -202,13 +226,15 @@ def get_fixes(project, dataset, mip, short_name, extra_facets=None):
pass

for fixes_module in fixes_modules:
classes = inspect.getmembers(fixes_module, inspect.isclass)
classes = dict((name.lower(), value) for name, value in classes)
classes = dict(
(name.lower(), value) for (name, value) in
inspect.getmembers(fixes_module, inspect.isclass)
)
for fix_name in (short_name, mip.lower(), 'allvars'):
try:
fixes.append(classes[fix_name](vardef, extra_facets))
except KeyError:
pass
if fix_name in classes:
fixes.append(classes[fix_name](
vardef, extra_facets=extra_facets, session=session
))

return fixes

Expand Down
Loading

0 comments on commit efbb7e3

Please sign in to comment.