From a3005041a4491830ef2d41c160e8c4b5729ed75f Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 12:27:42 +1000 Subject: [PATCH 01/29] some messing around with tests --- test/test_env.yaml | 19 ++++ test/test_mesh/test_rof_weights.py | 153 +++++++++++++++++++++++++++++ test/test_requirements.txt | 9 -- 3 files changed, 172 insertions(+), 9 deletions(-) create mode 100644 test/test_env.yaml create mode 100644 test/test_mesh/test_rof_weights.py delete mode 100644 test/test_requirements.txt diff --git a/test/test_env.yaml b/test/test_env.yaml new file mode 100644 index 00000000..220694fb --- /dev/null +++ b/test/test_env.yaml @@ -0,0 +1,19 @@ +name: om3-scripts-test +channels: + - conda-forge + - accessnri + - defaults +dependencies: + - esmpy + - pip + - pip: + - ocean_model_grid_generator@git+https://github.com/ACCESS-NRI/ocean_model_grid_generator@d17ee7af8d5690153dc54d9c55077de5e21b2211 + - numpy<2 + - pytest + - xarray + - pandas + - netCDF4<1.7 + - dask + - access-nri-intake + - setuptools + - ruamel.yaml \ No newline at end of file diff --git a/test/test_mesh/test_rof_weights.py b/test/test_mesh/test_rof_weights.py new file mode 100644 index 00000000..9bf38933 --- /dev/null +++ b/test/test_mesh/test_rof_weights.py @@ -0,0 +1,153 @@ +# Copyright 2026 ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details. +# SPDX-License-Identifier: Apache-2.0. + +import pytest +from unittest.mock import patch +from mesh_generation.generate_mesh import mom6_mask_detection, MomSuperGrid +from pathlib import Path +from subprocess import run +import xarray as xr +import numpy as np +import esmpy + +# create test grids at 4 degrees and 0.1 degrees +# 4 degress is the lowest tested in ocean_model_grid_generator +# going higher resolution than 0.1 has too much computational cost +_test_resolutions = [4] # , 0.1] + + +# so that our fixtures are only created once in this pytest module, we need this special version of 'tmp_path' +@pytest.fixture(scope="module") +def tmp_path(tmp_path_factory: pytest.TempdirFactory) -> Path: + return tmp_path_factory.mktemp("temp") + + +# ---------------- +# test data: +class MomGridFixture: + """Generate a sample tripole grid to use as test data""" + + def __init__(self, res, tmp_path): + self.path = str(tmp_path) + "/ocean_hgrid.nc" + self.mask_path = str(tmp_path) + "/ocean_mask.nc" + + # generate a tripolar grid as test data + run( + [ + "ocean_grid_generator.py", + "-r", + str(1 / res), + "--no_south_cap", + "--ensure_nj_even", + "-f", + self.path, + ] + ) + + # open ocean_hgrid.nc + self.ds = xr.open_dataset(self.path) + + # an ocean mask with a arbitrary mask + self.mask_ds = xr.Dataset() + self.mask_ds["mask"] = ( + self.ds.area.coarsen(ny=2).sum().coarsen(nx=2).sum() + ) > 5e9 + self.mask_ds.to_netcdf(self.mask_path) + + +# pytest doesn't support class fixtures, so we need this constructor +@pytest.fixture(scope="module", params=_test_resolutions) +def mom_grid(request, tmp_path): + return MomGridFixture(request.param, tmp_path) + + +@pytest.fixture() +def esmf_mask_mesh(mom_grid): + """ + Patch the mom6_mask_detection function, and just return the mask from the mom_grid fixture + """ + with patch( + "mesh_generation.generate_mesh.mom6_mask_detection", + return_value=mom_grid.mask_ds.mask.values, + ): + test_mesh = MomSuperGrid(mom_grid.path, topog_filename=mom_grid.mask_path) + + test_mesh.create_mesh() + + test_mesh.write(str(tmp_path) + "/esmf_mask_mesh.nc") + + return test_mesh + + +@pytest.fixture +def weights_file(esmf_mask_mesh, mom_grid): + drof_remapping_weights( + str(tmp_path) + "/esmf_mask_mesh.nc", + str(tmp_path) + "/drof_remap_weights.nc", + len(mom_grid.ds.n1) / 2, + len(mom_grid.ds.ny) / 2, + ) + + # check str(tmp_path) + "/drof_remap_weights.nc" exists ? + + return str(tmp_path) + "/drof_remap_weights.nc" + + +def test_generate_mask(esmf_mask_mesh, mom_grid): + """ + This test just convinces us we can patch the mom6_mask_detection needing a + topography file, and instead provide an arbitrary mask when making a mesh + """ + + assert np.all(esmf_mask_mesh.mask == mom_grid.mask_ds.mask.values.flatten()) + + assert ( + len(esmf_mask_mesh.mesh.elementCount.values) + == len(mom_grid.ds.ny) / 2 * len(mom_grid.ds.nx) / 2 + ) + + +# def test_generate_rof_weights(esmf_mask_mesh): + + +@pytest.mark.parametrize("data", [1, 0]) +def test_regrid_conservation(data, esmf_mask_mesh, weights_file): + + mesh_filename_in = str(tmp_path) + "/esmf_mask_mesh.nc" + mesh_filename_out = str(tmp_path) + "/esmf_mask_mesh.nc" + + model_mesh_in = esmpy.Mesh( + filename=mesh_filename_in, + filetype=esmpy.FileFormat.ESMFMESH, + ) + + fld_in = esmpy.Field(model_mesh_in, meshloc=esmpy.MeshLoc.ELEMENT) + + fld_in.get_area() + area_in = copy(fld_in.data) + + model_mesh_out = esmpy.Mesh( + filename=mesh_filename_out, + filetype=esmpy.FileFormat.ESMFMESH, + ) + + fld_out = esmpy.Field(model_mesh_out, meshloc=esmpy.MeshLoc.ELEMENT) + + fld_out.get_area() + area_out = copy(fld_out.data) + + fld_in.data[:] = data + + # for unclear reasons, we need to zero the output field before populating it + # it looks like cells which are not destinations in remapping can introduce rounding error + + fld_out.data[:] = 0 + + esmpy.RegridFromFile(fld_in, fld_out, filename=weights_file) + + print(f"Total before Regrid : {np.sum(fld_in.data*area_in)}") + print(f"Total after Regrid : {np.sum(fld_out.data*area_out)}") + + assert np.sum(fld_in.data * area_in) == pytest.approx( + np.sum(fld_out.data * area_out), rel=1e-7 + ) diff --git a/test/test_requirements.txt b/test/test_requirements.txt deleted file mode 100644 index 45573c37..00000000 --- a/test/test_requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -numpy -pytest -xarray -pandas -netCDF4 -dask -access-nri-intake -setuptools -ruamel.yaml \ No newline at end of file From 4057f06725d8ca45f77c74effc685a1e51f8819e Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 15:41:24 +1000 Subject: [PATCH 02/29] First pass a test to show conservation --- .github/workflows/ci.yml | 38 ++++---- test/test_env.yaml | 4 +- test/test_mesh/test_rof_weights.py | 139 ++++++++++++++++++----------- 3 files changed, 111 insertions(+), 70 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb99ba6a..d863dafb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,23 +30,31 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + - name: Setup conda environment + uses: conda-incubator/setup-miniconda@v3 with: + miniconda-version: "latest" python-version: ${{ matrix.python-version }} - - name: Install sys dependencies - run: | - sudo apt-get update - sudo apt-get -y install nco - sudo apt-get -y install ncal - - name: Install python dependencies - run: | - python -m pip install --upgrade pip - pip install -r test/test_requirements.txt + environment-file: test/test_env.yml + activate-environment: om3-scripts-test + auto-activate-base: false + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v3 + # with: + # python-version: ${{ matrix.python-version }} + # - name: Install sys dependencies + # run: | + # sudo apt-get update + # sudo apt-get -y install nco + # sudo apt-get -y install ncal + # - name: Install python dependencies + # run: | + # python -m pip install --upgrade pip + # pip install -r test/test_requirements.txt - name: Test with pytest run: | python -m pytest -m "not broken" -v -s - - name: Upload coverage reports to Codecov with GitHub Action - uses: codecov/codecov-action@v3 - env: - CODEOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + # - name: Upload coverage reports to Codecov with GitHub Action + # uses: codecov/codecov-action@v3 + # env: + # CODEOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/test/test_env.yaml b/test/test_env.yaml index 220694fb..de0bc3ee 100644 --- a/test/test_env.yaml +++ b/test/test_env.yaml @@ -5,6 +5,7 @@ channels: - defaults dependencies: - esmpy + # - nco - pip - pip: - ocean_model_grid_generator@git+https://github.com/ACCESS-NRI/ocean_model_grid_generator@d17ee7af8d5690153dc54d9c55077de5e21b2211 @@ -16,4 +17,5 @@ dependencies: - dask - access-nri-intake - setuptools - - ruamel.yaml \ No newline at end of file + - ruamel.yaml + - scikit-learn \ No newline at end of file diff --git a/test/test_mesh/test_rof_weights.py b/test/test_mesh/test_rof_weights.py index 9bf38933..ea6fdadc 100644 --- a/test/test_mesh/test_rof_weights.py +++ b/test/test_mesh/test_rof_weights.py @@ -3,25 +3,27 @@ import pytest from unittest.mock import patch -from mesh_generation.generate_mesh import mom6_mask_detection, MomSuperGrid from pathlib import Path from subprocess import run + import xarray as xr import numpy as np import esmpy +from copy import copy + +from mesh_generation.generate_mesh import mom6_mask_detection, MomSuperGrid +from mesh_generation.generate_rof_weights import drof_remapping_weights # create test grids at 4 degrees and 0.1 degrees # 4 degress is the lowest tested in ocean_model_grid_generator # going higher resolution than 0.1 has too much computational cost _test_resolutions = [4] # , 0.1] - # so that our fixtures are only created once in this pytest module, we need this special version of 'tmp_path' @pytest.fixture(scope="module") -def tmp_path(tmp_path_factory: pytest.TempdirFactory) -> Path: +def grid_path(tmp_path_factory: pytest.TempdirFactory) -> Path: return tmp_path_factory.mktemp("temp") - # ---------------- # test data: class MomGridFixture: @@ -54,18 +56,55 @@ def __init__(self, res, tmp_path): ) > 5e9 self.mask_ds.to_netcdf(self.mask_path) + self.ny = int(len(self.ds.ny)/2) + self.nx = int(len(self.ds.nx)/2) -# pytest doesn't support class fixtures, so we need this constructor + +# pytest doesn't support class fixtures, so we need these constructor @pytest.fixture(scope="module", params=_test_resolutions) -def mom_grid(request, tmp_path): - return MomGridFixture(request.param, tmp_path) +def mom_grid(request, grid_path): + return MomGridFixture(request.param, grid_path) + +def mesh_creator(filename): + """ + Create esmpy flield object from a mesh file + """ + mesh = esmpy.Mesh( + filename=filename, + filetype=esmpy.FileFormat.ESMFMESH, + ) + + fld = esmpy.Field(mesh, meshloc=esmpy.MeshLoc.ELEMENT) + + fld.get_area() + area = copy(fld.data) + + return {'fld':fld,'area': area} + +@pytest.fixture() +def mesh_in(mom_grid, tmp_path): + """ + For the input mesh, use an unmasked mesh + """ + mesh_filename_in = str(tmp_path) + "/mesh_in.nc" + + test_mesh = MomSuperGrid(mom_grid.path, topog_filename=None) + test_mesh.create_mesh() + test_mesh.write(mesh_filename_in) + + result = mesh_creator(mesh_filename_in) + result['mom_super_grid'] = test_mesh + return result @pytest.fixture() -def esmf_mask_mesh(mom_grid): +def mesh_out(mom_grid, tmp_path): """ - Patch the mom6_mask_detection function, and just return the mask from the mom_grid fixture + Patch the mom6_mask_detection function, and use the mask from the mom_grid fixture, + rather than need a topog file """ + mesh_filename_out = str(tmp_path) + "/mesh_out.nc" + with patch( "mesh_generation.generate_mesh.mom6_mask_detection", return_value=mom_grid.mask_ds.mask.values, @@ -73,74 +112,66 @@ def esmf_mask_mesh(mom_grid): test_mesh = MomSuperGrid(mom_grid.path, topog_filename=mom_grid.mask_path) test_mesh.create_mesh() + test_mesh.write(mesh_filename_out) - test_mesh.write(str(tmp_path) + "/esmf_mask_mesh.nc") - - return test_mesh + result = mesh_creator(mesh_filename_out) + result['mom_super_grid'] = test_mesh + return result @pytest.fixture -def weights_file(esmf_mask_mesh, mom_grid): +def weights_file(mesh_out, mom_grid, tmp_path): + drof_remapping_weights( - str(tmp_path) + "/esmf_mask_mesh.nc", + str(tmp_path) + "/mesh_out.nc", str(tmp_path) + "/drof_remap_weights.nc", - len(mom_grid.ds.n1) / 2, - len(mom_grid.ds.ny) / 2, + mom_grid.nx, + mom_grid.ny, ) - # check str(tmp_path) + "/drof_remap_weights.nc" exists ? + if not Path(str(tmp_path) + "/drof_remap_weights.nc").exists(): + raise RuntimeError("drof remap weights not created") return str(tmp_path) + "/drof_remap_weights.nc" +# ---------------- +# the actual tests: -def test_generate_mask(esmf_mask_mesh, mom_grid): +def test_generate_mask(mesh_out, mom_grid): """ - This test just convinces us we can patch the mom6_mask_detection needing a - topography file, and instead provide an arbitrary mask when making a mesh + This test just convinces us the patch mom6_mask_detection in mesh_out works """ - assert np.all(esmf_mask_mesh.mask == mom_grid.mask_ds.mask.values.flatten()) + assert np.all(mesh_out['mom_super_grid'].mask == mom_grid.mask_ds.mask.values.flatten()) assert ( - len(esmf_mask_mesh.mesh.elementCount.values) - == len(mom_grid.ds.ny) / 2 * len(mom_grid.ds.nx) / 2 + len(mesh_out['mom_super_grid'].mesh.elementCount.values) + == (mom_grid.ny * mom_grid.nx) ) +@pytest.mark.parametrize("data", ['All', 'None', 'Ocean', 'Land']) +def test_regrid_conservation(data, mesh_in, mesh_out, weights_file, tmp_path): + """ + For some provided meshes, and weights file, confirm that the weights are conservative + """ -# def test_generate_rof_weights(esmf_mask_mesh): - - -@pytest.mark.parametrize("data", [1, 0]) -def test_regrid_conservation(data, esmf_mask_mesh, weights_file): - - mesh_filename_in = str(tmp_path) + "/esmf_mask_mesh.nc" - mesh_filename_out = str(tmp_path) + "/esmf_mask_mesh.nc" - - model_mesh_in = esmpy.Mesh( - filename=mesh_filename_in, - filetype=esmpy.FileFormat.ESMFMESH, - ) - - fld_in = esmpy.Field(model_mesh_in, meshloc=esmpy.MeshLoc.ELEMENT) - - fld_in.get_area() - area_in = copy(fld_in.data) - - model_mesh_out = esmpy.Mesh( - filename=mesh_filename_out, - filetype=esmpy.FileFormat.ESMFMESH, - ) - - fld_out = esmpy.Field(model_mesh_out, meshloc=esmpy.MeshLoc.ELEMENT) - - fld_out.get_area() - area_out = copy(fld_out.data) - - fld_in.data[:] = data + fld_in = mesh_in['fld'] + area_in = mesh_in['area'] + fld_out = mesh_out['fld'] + area_out = mesh_out['area'] + + match data: + case 'All': + fld_in.data[:] = 1e10 + case 'None': + fld_in.data[:] = 0 + case 'Ocean': + fld_in.data[:] = mesh_out['mom_super_grid'].mesh.elementMask*1e20 + case 'Land': + fld_in.data[:] = 1e-20*(mesh_out['mom_super_grid'].mesh.elementMask==0).astype(int) # for unclear reasons, we need to zero the output field before populating it # it looks like cells which are not destinations in remapping can introduce rounding error - fld_out.data[:] = 0 esmpy.RegridFromFile(fld_in, fld_out, filename=weights_file) From 4e9aee25d3c78527d9c17c5daf813fc13d8f5605 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 15:46:25 +1000 Subject: [PATCH 03/29] black --- test/test_mesh/test_rof_weights.py | 52 ++++++++++++++++++------------ 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/test/test_mesh/test_rof_weights.py b/test/test_mesh/test_rof_weights.py index ea6fdadc..3edd8037 100644 --- a/test/test_mesh/test_rof_weights.py +++ b/test/test_mesh/test_rof_weights.py @@ -19,11 +19,13 @@ # going higher resolution than 0.1 has too much computational cost _test_resolutions = [4] # , 0.1] + # so that our fixtures are only created once in this pytest module, we need this special version of 'tmp_path' @pytest.fixture(scope="module") def grid_path(tmp_path_factory: pytest.TempdirFactory) -> Path: return tmp_path_factory.mktemp("temp") + # ---------------- # test data: class MomGridFixture: @@ -56,8 +58,8 @@ def __init__(self, res, tmp_path): ) > 5e9 self.mask_ds.to_netcdf(self.mask_path) - self.ny = int(len(self.ds.ny)/2) - self.nx = int(len(self.ds.nx)/2) + self.ny = int(len(self.ds.ny) / 2) + self.nx = int(len(self.ds.nx) / 2) # pytest doesn't support class fixtures, so we need these constructor @@ -65,6 +67,7 @@ def __init__(self, res, tmp_path): def mom_grid(request, grid_path): return MomGridFixture(request.param, grid_path) + def mesh_creator(filename): """ Create esmpy flield object from a mesh file @@ -79,7 +82,8 @@ def mesh_creator(filename): fld.get_area() area = copy(fld.data) - return {'fld':fld,'area': area} + return {"fld": fld, "area": area} + @pytest.fixture() def mesh_in(mom_grid, tmp_path): @@ -93,10 +97,11 @@ def mesh_in(mom_grid, tmp_path): test_mesh.write(mesh_filename_in) result = mesh_creator(mesh_filename_in) - result['mom_super_grid'] = test_mesh + result["mom_super_grid"] = test_mesh return result + @pytest.fixture() def mesh_out(mom_grid, tmp_path): """ @@ -115,10 +120,11 @@ def mesh_out(mom_grid, tmp_path): test_mesh.write(mesh_filename_out) result = mesh_creator(mesh_filename_out) - result['mom_super_grid'] = test_mesh + result["mom_super_grid"] = test_mesh return result + @pytest.fixture def weights_file(mesh_out, mom_grid, tmp_path): @@ -134,41 +140,47 @@ def weights_file(mesh_out, mom_grid, tmp_path): return str(tmp_path) + "/drof_remap_weights.nc" + # ---------------- # the actual tests: + def test_generate_mask(mesh_out, mom_grid): """ This test just convinces us the patch mom6_mask_detection in mesh_out works """ - assert np.all(mesh_out['mom_super_grid'].mask == mom_grid.mask_ds.mask.values.flatten()) + assert np.all( + mesh_out["mom_super_grid"].mask == mom_grid.mask_ds.mask.values.flatten() + ) - assert ( - len(mesh_out['mom_super_grid'].mesh.elementCount.values) - == (mom_grid.ny * mom_grid.nx) + assert len(mesh_out["mom_super_grid"].mesh.elementCount.values) == ( + mom_grid.ny * mom_grid.nx ) -@pytest.mark.parametrize("data", ['All', 'None', 'Ocean', 'Land']) + +@pytest.mark.parametrize("data", ["All", "None", "Ocean", "Land"]) def test_regrid_conservation(data, mesh_in, mesh_out, weights_file, tmp_path): """ For some provided meshes, and weights file, confirm that the weights are conservative """ - fld_in = mesh_in['fld'] - area_in = mesh_in['area'] - fld_out = mesh_out['fld'] - area_out = mesh_out['area'] + fld_in = mesh_in["fld"] + area_in = mesh_in["area"] + fld_out = mesh_out["fld"] + area_out = mesh_out["area"] match data: - case 'All': + case "All": fld_in.data[:] = 1e10 - case 'None': + case "None": fld_in.data[:] = 0 - case 'Ocean': - fld_in.data[:] = mesh_out['mom_super_grid'].mesh.elementMask*1e20 - case 'Land': - fld_in.data[:] = 1e-20*(mesh_out['mom_super_grid'].mesh.elementMask==0).astype(int) + case "Ocean": + fld_in.data[:] = mesh_out["mom_super_grid"].mesh.elementMask * 1e20 + case "Land": + fld_in.data[:] = 1e-20 * ( + mesh_out["mom_super_grid"].mesh.elementMask == 0 + ).astype(int) # for unclear reasons, we need to zero the output field before populating it # it looks like cells which are not destinations in remapping can introduce rounding error From b3eac998afa1d050a80c13568f8ecd8ac365ba1d Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 15:55:00 +1000 Subject: [PATCH 04/29] ci testing --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d863dafb..adb933f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,8 @@ jobs: steps: - uses: actions/checkout@v3 + - run: pwd + - run: ls -R - name: Setup conda environment uses: conda-incubator/setup-miniconda@v3 with: From b33afd18802f7b8f1b78c2fd91b03ab48b6efade Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 15:56:48 +1000 Subject: [PATCH 05/29] ci testing --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index adb933f4..742cbac2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: with: miniconda-version: "latest" python-version: ${{ matrix.python-version }} - environment-file: test/test_env.yml + environment-file: test/test_env.yaml activate-environment: om3-scripts-test auto-activate-base: false # - name: Set up Python ${{ matrix.python-version }} From e72d0f21af4bfdaabc990de886568e4e33336821 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 15:59:34 +1000 Subject: [PATCH 06/29] ci testing --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 742cbac2..24dc4952 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: python-version: ['3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 - run: pwd - run: ls -R - name: Setup conda environment @@ -53,6 +53,8 @@ jobs: # run: | # python -m pip install --upgrade pip # pip install -r test/test_requirements.txt + - run: which python + - run: which python3 - name: Test with pytest run: | python -m pytest -m "not broken" -v -s From 59848359c3f99d2368cdd844e14c02dcad7c8da2 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:02:09 +1000 Subject: [PATCH 07/29] ci testing --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24dc4952..750212cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,10 +40,10 @@ jobs: environment-file: test/test_env.yaml activate-environment: om3-scripts-test auto-activate-base: false - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@v3 - # with: - # python-version: ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} # - name: Install sys dependencies # run: | # sudo apt-get update From 07a9fa07260434e6826243eb220617c92eba72ef Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:04:48 +1000 Subject: [PATCH 08/29] ci testing --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 750212cf..fc26d2c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,6 +53,7 @@ jobs: # run: | # python -m pip install --upgrade pip # pip install -r test/test_requirements.txt + - run: conda env list - run: which python - run: which python3 - name: Test with pytest From 7b934797d3ae79066a5da08addaa3d969fcc5075 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:07:26 +1000 Subject: [PATCH 09/29] ci testing --- .github/workflows/ci.yml | 4 ++-- test/test_env.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc26d2c8..9134a005 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: formatting: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Code formatting uses: psf/black@stable with: @@ -29,7 +29,7 @@ jobs: python-version: ['3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - run: pwd - run: ls -R - name: Setup conda environment diff --git a/test/test_env.yaml b/test/test_env.yaml index de0bc3ee..0b2b4e14 100644 --- a/test/test_env.yaml +++ b/test/test_env.yaml @@ -7,10 +7,10 @@ dependencies: - esmpy # - nco - pip + - pytest - pip: - ocean_model_grid_generator@git+https://github.com/ACCESS-NRI/ocean_model_grid_generator@d17ee7af8d5690153dc54d9c55077de5e21b2211 - numpy<2 - - pytest - xarray - pandas - netCDF4<1.7 From 2357d40cc1c3f9db4fb250a48cea6683cc81d6c8 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:11:20 +1000 Subject: [PATCH 10/29] ci testing --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9134a005..5683a785 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,6 @@ jobs: python-version: ${{ matrix.python-version }} environment-file: test/test_env.yaml activate-environment: om3-scripts-test - auto-activate-base: false - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: From bb067e739c8d73563985add7b9171edb0f3fa097 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:15:32 +1000 Subject: [PATCH 11/29] ci testing --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5683a785..a2932223 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,12 +33,12 @@ jobs: - run: pwd - run: ls -R - name: Setup conda environment - uses: conda-incubator/setup-miniconda@v3 + uses: conda-incubator/setup-miniconda@v7 with: miniconda-version: "latest" python-version: ${{ matrix.python-version }} - environment-file: test/test_env.yaml activate-environment: om3-scripts-test + environment-file: test/test_env.yaml - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: From 82dbe0cb34cc6e349abe3a4f09540b478de6522a Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:16:46 +1000 Subject: [PATCH 12/29] ci testing --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2932223..22fc6f88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - run: pwd - run: ls -R - name: Setup conda environment - uses: conda-incubator/setup-miniconda@v7 + uses: conda-incubator/setup-miniconda@v6 with: miniconda-version: "latest" python-version: ${{ matrix.python-version }} @@ -53,6 +53,8 @@ jobs: # python -m pip install --upgrade pip # pip install -r test/test_requirements.txt - run: conda env list + - name: List installed packages + run: conda list - run: which python - run: which python3 - name: Test with pytest From c79bef958bad97d67893023cbcb86d6ecdcccf23 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:18:32 +1000 Subject: [PATCH 13/29] ci testing --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22fc6f88..7fe0a192 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - run: pwd - run: ls -R - name: Setup conda environment - uses: conda-incubator/setup-miniconda@v6 + uses: conda-incubator/setup-miniconda@v4 with: miniconda-version: "latest" python-version: ${{ matrix.python-version }} From 8f8419746c49bf67e5400d95767fbad0da0c9727 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:23:38 +1000 Subject: [PATCH 14/29] ci testing --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fe0a192..ae698d83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,7 @@ jobs: python-version: ${{ matrix.python-version }} activate-environment: om3-scripts-test environment-file: test/test_env.yaml + auto-activate: false - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: @@ -52,8 +53,8 @@ jobs: # run: | # python -m pip install --upgrade pip # pip install -r test/test_requirements.txt - - run: conda env list - name: List installed packages + run: conda env list run: conda list - run: which python - run: which python3 From 6bfc6e0a81039b5ced17cf6a29fca8bf9bb4c756 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:25:14 +1000 Subject: [PATCH 15/29] ci testing --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae698d83..bdb2017d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,10 +40,10 @@ jobs: activate-environment: om3-scripts-test environment-file: test/test_env.yaml auto-activate: false - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v3 + # with: + # python-version: ${{ matrix.python-version }} # - name: Install sys dependencies # run: | # sudo apt-get update From b88b0475460de4ccf53a7adb6939a3522bf649e6 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:25:50 +1000 Subject: [PATCH 16/29] ci testing --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdb2017d..74528fbb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: python-version: ${{ matrix.python-version }} activate-environment: om3-scripts-test environment-file: test/test_env.yaml - auto-activate: false + auto-activate: "false" # - name: Set up Python ${{ matrix.python-version }} # uses: actions/setup-python@v3 # with: From 937b72112564e29d9d39c5db4d8d21e93f1afcdd Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:26:19 +1000 Subject: [PATCH 17/29] ci testing --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74528fbb..2feed8a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,6 @@ jobs: python-version: ${{ matrix.python-version }} activate-environment: om3-scripts-test environment-file: test/test_env.yaml - auto-activate: "false" # - name: Set up Python ${{ matrix.python-version }} # uses: actions/setup-python@v3 # with: From 7632ab3f3ae7663a3c0a31eae5e27d66b65c2cdc Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:27:55 +1000 Subject: [PATCH 18/29] ci testing --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2feed8a2..bdb2017d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,7 @@ jobs: python-version: ${{ matrix.python-version }} activate-environment: om3-scripts-test environment-file: test/test_env.yaml + auto-activate: false # - name: Set up Python ${{ matrix.python-version }} # uses: actions/setup-python@v3 # with: From 89b1895667cb954de2e2dfca1c349d17cc8a77ae Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:28:28 +1000 Subject: [PATCH 19/29] ci testing --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdb2017d..36bbec77 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,8 +54,8 @@ jobs: # python -m pip install --upgrade pip # pip install -r test/test_requirements.txt - name: List installed packages - run: conda env list - run: conda list + run|: conda env list + conda list - run: which python - run: which python3 - name: Test with pytest From 3326a0b763ce91b7409bc61ee078351a25a2e67a Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:28:57 +1000 Subject: [PATCH 20/29] ci testing --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36bbec77..7adc9fc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,8 +54,9 @@ jobs: # python -m pip install --upgrade pip # pip install -r test/test_requirements.txt - name: List installed packages - run|: conda env list - conda list + run: | + conda env list + conda list - run: which python - run: which python3 - name: Test with pytest From 54c4f0151e0458e77ff0532ca1cb9925acc55852 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:33:25 +1000 Subject: [PATCH 21/29] ci testing --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7adc9fc4..cf2874de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,11 +35,11 @@ jobs: - name: Setup conda environment uses: conda-incubator/setup-miniconda@v4 with: - miniconda-version: "latest" + # miniconda-version: "latest" python-version: ${{ matrix.python-version }} - activate-environment: om3-scripts-test + # activate-environment: om3-scripts-test environment-file: test/test_env.yaml - auto-activate: false + # auto-activate: false # - name: Set up Python ${{ matrix.python-version }} # uses: actions/setup-python@v3 # with: From 5b711d2af8e99ba837703d966f277688a4246260 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:37:28 +1000 Subject: [PATCH 22/29] ci testing --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf2874de..e1cf1e17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,7 @@ jobs: # pip install -r test/test_requirements.txt - name: List installed packages run: | + conda env activate test conda env list conda list - run: which python From d84f58d4e71dbe4a8609f03c00e7fcbf86f4351c Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:39:38 +1000 Subject: [PATCH 23/29] ci testing --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1cf1e17..e36723f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,10 +20,14 @@ jobs: uses: psf/black@stable with: options: "--check --verbose --diff" + test: needs: formatting runs-on: ubuntu-latest + defaults: + run: + shell: bash -el {0} strategy: matrix: python-version: ['3.10', '3.11', '3.12'] @@ -37,7 +41,7 @@ jobs: with: # miniconda-version: "latest" python-version: ${{ matrix.python-version }} - # activate-environment: om3-scripts-test + activate-environment: om3-scripts-test environment-file: test/test_env.yaml # auto-activate: false # - name: Set up Python ${{ matrix.python-version }} @@ -54,6 +58,7 @@ jobs: # python -m pip install --upgrade pip # pip install -r test/test_requirements.txt - name: List installed packages + shell: bash -l run: | conda env activate test conda env list From 5db8e826ad808f9602eb94f73818731f5acd806d Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:43:11 +1000 Subject: [PATCH 24/29] ci testing --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e36723f2..61a49ef4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,6 @@ jobs: # python -m pip install --upgrade pip # pip install -r test/test_requirements.txt - name: List installed packages - shell: bash -l run: | conda env activate test conda env list From 3245292cacc2b168fe303a66b816bfec7050efe6 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:46:05 +1000 Subject: [PATCH 25/29] ci testing --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61a49ef4..d95e0946 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,6 @@ jobs: # pip install -r test/test_requirements.txt - name: List installed packages run: | - conda env activate test conda env list conda list - run: which python From 95293eb4cd9271fa0fde575774ab982b2f6a6bb5 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:50:33 +1000 Subject: [PATCH 26/29] ci testing --- .github/workflows/ci.yml | 25 +------------------------ test/test_env.yaml | 19 +++++++++---------- 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d95e0946..df2d742b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: uses: psf/black@stable with: options: "--check --verbose --diff" - + test: needs: formatting @@ -34,39 +34,16 @@ jobs: steps: - uses: actions/checkout@v6 - - run: pwd - - run: ls -R - name: Setup conda environment uses: conda-incubator/setup-miniconda@v4 with: - # miniconda-version: "latest" python-version: ${{ matrix.python-version }} activate-environment: om3-scripts-test environment-file: test/test_env.yaml - # auto-activate: false - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@v3 - # with: - # python-version: ${{ matrix.python-version }} - # - name: Install sys dependencies - # run: | - # sudo apt-get update - # sudo apt-get -y install nco - # sudo apt-get -y install ncal - # - name: Install python dependencies - # run: | - # python -m pip install --upgrade pip - # pip install -r test/test_requirements.txt - name: List installed packages run: | conda env list conda list - - run: which python - - run: which python3 - name: Test with pytest run: | python -m pytest -m "not broken" -v -s - # - name: Upload coverage reports to Codecov with GitHub Action - # uses: codecov/codecov-action@v3 - # env: - # CODEOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/test/test_env.yaml b/test/test_env.yaml index 0b2b4e14..9359675f 100644 --- a/test/test_env.yaml +++ b/test/test_env.yaml @@ -5,17 +5,16 @@ channels: - defaults dependencies: - esmpy - # - nco - pip - pytest + - numpy<2 + - xarray + - pandas + - netCDF4<1.7 + - dask + - access-nri-intake + - setuptools + - ruamel.yaml + - scikit-learn - pip: - ocean_model_grid_generator@git+https://github.com/ACCESS-NRI/ocean_model_grid_generator@d17ee7af8d5690153dc54d9c55077de5e21b2211 - - numpy<2 - - xarray - - pandas - - netCDF4<1.7 - - dask - - access-nri-intake - - setuptools - - ruamel.yaml - - scikit-learn \ No newline at end of file From 384b416f3fda421d1e10fe342dc38b90c2eff8aa Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:55:14 +1000 Subject: [PATCH 27/29] ci testing --- test/test_env.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/test_env.yaml b/test/test_env.yaml index 9359675f..aa3cb42a 100644 --- a/test/test_env.yaml +++ b/test/test_env.yaml @@ -6,15 +6,15 @@ channels: dependencies: - esmpy - pip - - pytest - - numpy<2 - - xarray - - pandas - - netCDF4<1.7 - - dask - - access-nri-intake - - setuptools - - ruamel.yaml - - scikit-learn - pip: - ocean_model_grid_generator@git+https://github.com/ACCESS-NRI/ocean_model_grid_generator@d17ee7af8d5690153dc54d9c55077de5e21b2211 + - numpy<2 + - pytest + - xarray + - pandas + - netCDF4<1.7 + - dask + - access-nri-intake + - setuptools + - ruamel.yaml + - scikit-learn \ No newline at end of file From aab91c7a3ba1bb58a276c94c49cc4a17896ef670 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:58:35 +1000 Subject: [PATCH 28/29] longer --- test/test_mesh/test_rof_weights.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_mesh/test_rof_weights.py b/test/test_mesh/test_rof_weights.py index 3edd8037..e275d135 100644 --- a/test/test_mesh/test_rof_weights.py +++ b/test/test_mesh/test_rof_weights.py @@ -17,7 +17,7 @@ # create test grids at 4 degrees and 0.1 degrees # 4 degress is the lowest tested in ocean_model_grid_generator # going higher resolution than 0.1 has too much computational cost -_test_resolutions = [4] # , 0.1] +_test_resolutions = [4 , 0.1] # so that our fixtures are only created once in this pytest module, we need this special version of 'tmp_path' From 9671a927e39382f4b8dece9019a1f319897d1d64 Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Thu, 2 Jul 2026 16:59:54 +1000 Subject: [PATCH 29/29] longer --- test/test_mesh/test_rof_weights.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_mesh/test_rof_weights.py b/test/test_mesh/test_rof_weights.py index e275d135..d84ce8f7 100644 --- a/test/test_mesh/test_rof_weights.py +++ b/test/test_mesh/test_rof_weights.py @@ -17,7 +17,7 @@ # create test grids at 4 degrees and 0.1 degrees # 4 degress is the lowest tested in ocean_model_grid_generator # going higher resolution than 0.1 has too much computational cost -_test_resolutions = [4 , 0.1] +_test_resolutions = [4, 0.1] # so that our fixtures are only created once in this pytest module, we need this special version of 'tmp_path'