Skip to content

Commit a6c869d

Browse files
authored
Merge pull request #227 from ESMValGroup/fix_nightly_build
Fix nightly tests
2 parents 4c4ecc3 + 61ccf91 commit a6c869d

File tree

11 files changed

+53
-27
lines changed

11 files changed

+53
-27
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
conda update -y conda > /logs/conda.txt 2>&1
5252
conda env update >> /logs/conda.txt 2>&1
5353
set +x; conda activate esmvaltool; set -x
54-
conda install -yS r-base r-yaml julia ncl -c conda-forge
54+
conda install -yS r-base r-yaml ncl -c conda-forge
5555
pip install . > /logs/install.txt 2>&1
5656
# Log versions
5757
dpkg -l > /logs/versions.txt
@@ -120,6 +120,7 @@ jobs:
120120
conda update -y conda > /logs/conda.txt 2>&1
121121
conda env update >> /logs/conda.txt 2>&1
122122
set +x; conda activate esmvaltool; set -x
123+
conda install -yS r-base r-yaml ncl -c conda-forge
123124
pip install -e .[develop] > /logs/install.txt 2>&1
124125
# Log versions
125126
dpkg -l > /logs/versions.txt

conda_build_config.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ channels:
55

66
dependencies:
77
- esmpy
8-
- iris>=2.2
8+
- iris>=2.2.1
99
- graphviz
1010
- gcc_linux-64
1111
- libunwind # Needed for Python3.7+

esmvalcore/preprocessor/_derive/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def derive(cubes,
107107
"'%s' not found", fx_var, short_name)
108108

109109
# Derive variable
110-
DerivedVariable = ALL_DERIVED_VARIABLES[short_name] # noqa: N806
110+
DerivedVariable = ALL_DERIVED_VARIABLES[short_name.lower()] # noqa: N806
111111
cube = DerivedVariable().calculate(cubes)
112112

113113
# Set standard attributes

meta.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ build:
2222
# Increment the build number when building a new conda package of the same
2323
# esmvalcore version, reset to 0 when building a new version.
2424
number: 0
25+
noarch: python
2526
script: |
2627
python setup.py install --single-version-externally-managed --record=/tmp/record.txt
2728
2829
requirements:
2930
build:
3031
- git
31-
- python {{ python }}
32+
- python>=3.6
3233
# Normally installed via pip:
3334
- pytest-runner
3435
- setuptools_scm
3536
run:
3637
# esmvaltool
37-
- python
38+
- python>=3.6
3839
- libunwind # specifically for Python3.7+
3940
- graphviz
40-
- iris>=2.2
41-
- matplotlib<3,>=2 # required by iris
41+
- iris>=2.2.1
4242
- python-stratify
4343
# Normally installed via pip:
4444
- cf-units
@@ -52,7 +52,7 @@ requirements:
5252
- psutil
5353
- pydot
5454
- pyyaml
55-
- yamale # in esmvalgroup and birdhouse channel
55+
- yamale # in esmvalgroup channel
5656

5757
test:
5858
# TODO: add unit tests? This seems to require installing the tests
@@ -68,5 +68,5 @@ about:
6868
home: https://www.esmvaltool.org
6969
license: Apache License, Version 2.0
7070
license_file: LICENSE
71-
summary: "ESMValCore: core functionalities for the ESMValTool, a community diagnostic and performance metrics tool for routine evaluation of Earth system models in CMIP."
72-
description: "ESMValCore: core functionalities for the ESMValTool, a community diagnostic and performance metrics tool for routine evaluation of Earth system models in CMIP."
71+
summary: "ESMValCore: A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts."
72+
description: "ESMValCore: A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts."

tests/integration/preprocessor/_derive/test_interface.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import iris
12
from iris.cube import Cube, CubeList
23

34
from esmvalcore.preprocessor import derive
45
from esmvalcore.preprocessor._derive import get_required
6+
from esmvalcore.preprocessor._derive.csoil_grid import DerivedVariable
57

68

79
def test_get_required():
@@ -67,3 +69,32 @@ def test_derive_noop():
6769

6870
print(cube)
6971
assert cube is alb
72+
73+
74+
def test_derive_mixed_case_with_fx(tmp_path, monkeypatch):
75+
76+
short_name = 'cSoil_grid'
77+
long_name = 'Carbon Mass in Soil Pool relative to grid cell area'
78+
units = 'kg m-2'
79+
80+
csoil_cube = Cube([])
81+
fx_cube = Cube([])
82+
fx_cube.var_name = 'sftlf'
83+
fx_file = str(tmp_path / 'sftlf_file.nc')
84+
iris.save(fx_cube, target=fx_file)
85+
86+
def mock_calculate(self, cubes):
87+
assert len(cubes) == 2
88+
assert cubes[0] == csoil_cube
89+
assert cubes[1].var_name == fx_cube.var_name
90+
return Cube([])
91+
92+
monkeypatch.setattr(DerivedVariable, 'calculate', mock_calculate)
93+
94+
derive(
95+
[csoil_cube],
96+
short_name,
97+
long_name,
98+
units,
99+
fx_files={'sftlf': fx_file},
100+
)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
"""Test derivation of `cSoil_grid`."""
22
import mock
33

4-
import esmvalcore.preprocessor._derive.cSoil_grid as cSoil_grid
4+
from esmvalcore.preprocessor._derive import csoil_grid
55

66
CUBES = 'mocked cubes'
77
STD_NAME = 'soil_carbon_content'
88

99

10-
@mock.patch.object(cSoil_grid, 'grid_area_correction', autospec=True)
11-
def test_cSoil_grid_calculation(mock_grid_area_correction):
10+
@mock.patch.object(csoil_grid, 'grid_area_correction', autospec=True)
11+
def test_csoil_grid_calculation(mock_grid_area_correction):
1212
"""Test calculation of `cSoil_grid."""
13-
derived_var = cSoil_grid.DerivedVariable()
13+
derived_var = csoil_grid.DerivedVariable()
1414
derived_var.calculate(CUBES)
1515
mock_grid_area_correction.assert_called_once_with(CUBES, STD_NAME)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
"""Test derivation of `cVeg_grid`."""
22
import mock
33

4-
import esmvalcore.preprocessor._derive.cVeg_grid as cVeg_grid
4+
from esmvalcore.preprocessor._derive import cveg_grid
55

66
CUBES = 'mocked cubes'
77
STD_NAME = 'vegetation_carbon_content'
88

99

10-
@mock.patch.object(cVeg_grid, 'grid_area_correction', autospec=True)
11-
def test_cVeg_grid_calculation(mock_grid_area_correction):
10+
@mock.patch.object(cveg_grid, 'grid_area_correction', autospec=True)
11+
def test_cveg_grid_calculation(mock_grid_area_correction):
1212
"""Test calculation of `cVeg_grid."""
13-
derived_var = cVeg_grid.DerivedVariable()
13+
derived_var = cveg_grid.DerivedVariable()
1414
derived_var.calculate(CUBES)
1515
mock_grid_area_correction.assert_called_once_with(CUBES, STD_NAME)

0 commit comments

Comments
 (0)