diff --git a/.github/workflows/unit_tests.yaml b/.github/workflows/unit_tests.yaml new file mode 100644 index 0000000..d7a9250 --- /dev/null +++ b/.github/workflows/unit_tests.yaml @@ -0,0 +1,59 @@ +name: "pySHiELD tests" + +# Run these these whenever ... +on: + pull_request: # ... a PR is opened / updated + merge_group: # ... the PR is added to the merge queue + push: + branches: + - main # ... when merging into the main branch + +# cancel running jobs if theres a newer push +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + integration-tests: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + submodules: 'recursive' + + - name: Setup Python 3.11 + uses: actions/setup-python@v6 + with: + python-version: '3.11' + + - name: Install mpi (MPICH flavor) + run: pip install mpich + + - name: Install Python packages + run: pip install .[ndsl,pyfv3,test] + + - name: Run integration tests + run: pytest tests/integration + + radiation-tests: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + submodules: 'recursive' + + - name: Setup Python 3.11 + uses: actions/setup-python@v6 + with: + python-version: '3.11' + + - name: Install mpi (MPICH flavor) + run: pip install mpich + + - name: Install Python packages + run: pip install .[ndsl,pyfv3,test] + + - name: Run radiation tests + run: pytest tests/rte_rrtmgp diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/examples/notebook/test_rad.ipynb b/examples/notebook/test_rad.ipynb index 0fa4797..4a0a53f 100644 --- a/examples/notebook/test_rad.ipynb +++ b/examples/notebook/test_rad.ipynb @@ -10,7 +10,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "e2411282-0778-4af1-83d3-4e3d372ab519", "metadata": {}, "outputs": [ @@ -37,7 +37,7 @@ "source": [ "import xarray as xr\n", "import ndsl.dsl.gt4py_utils as gt_utils\n", - "from ndsl import GridSizer, Quantity, QuantityFactory, TileCommunicator, TilePartitioner, NullComm, SubtileGridSizer\n", + "from ndsl import GridSizer, Quantity, QuantityFactory, TileCommunicator, TilePartitioner, LocalComm, SubtileGridSizer\n", "import ndsl.constants as constants\n", "\n", "from pyshield.radiation.state import RTE_RRTMGPState\n", @@ -90,7 +90,7 @@ "rank = 0\n", "backend = \"numpy\"\n", "\n", - "comm = NullComm(rank, 1)\n", + "comm = LocalComm(rank, total_ranks=1, buffer_dict={})\n", "communicator = TileCommunicator.from_layout(comm=comm, layout=(1,1))\n", "\n", "sizer = SubtileGridSizer.from_tile_params(\n", diff --git a/examples/notebook/test_raddriver.ipynb b/examples/notebook/test_raddriver.ipynb index 9caa47e..3235e2a 100644 --- a/examples/notebook/test_raddriver.ipynb +++ b/examples/notebook/test_raddriver.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "ea4d7298-a2bc-4283-a038-b2f5c96d9c20", "metadata": {}, "outputs": [ @@ -29,7 +29,7 @@ "source": [ "import xarray as xr\n", "import ndsl.dsl.gt4py_utils as gt_utils\n", - "from ndsl import GridSizer, Quantity, QuantityFactory, TileCommunicator, TilePartitioner, NullComm, SubtileGridSizer\n", + "from ndsl import GridSizer, Quantity, QuantityFactory, TileCommunicator, TilePartitioner, LocalComm, SubtileGridSizer\n", "import ndsl.constants as constants\n", "\n", "from pyshield.radiation import RTE_RRTMGPState, RTE_RRTMGPConfig, RTE_RRTMGPDriver\n", @@ -76,7 +76,7 @@ "rank = 0\n", "backend = \"numpy\"\n", "\n", - "comm = NullComm(rank, 1)\n", + "comm = LocalComm(rank, total_ranks=1, buffer_dict={})\n", "communicator = TileCommunicator.from_layout(comm=comm, layout=(1,1))\n", "\n", "sizer = SubtileGridSizer.from_tile_params(\n", diff --git a/examples/notebook/utilities.py b/examples/notebook/utilities.py index 4cfe99c..54af229 100644 --- a/examples/notebook/utilities.py +++ b/examples/notebook/utilities.py @@ -3,7 +3,7 @@ import numpy as np import xarray as xr -from ndsl import NullComm, Quantity, QuantityFactory, TileCommunicator +from ndsl import LocalComm, Quantity, QuantityFactory, TileCommunicator from ndsl.boilerplate import get_factories_single_tile from ndsl.grid import ( AngleGridData, @@ -102,7 +102,7 @@ def setup_infrastructure( nx=nx, ny=ny, nz=nz, nhalo=nhalo, backend=backend ) rank = 0 - comm = NullComm(rank, 1) + comm = LocalComm(rank, total_ranks=1, buffer_dict={}) communicator = TileCommunicator.from_layout(comm=comm, layout=(1, 1)) metric_terms = MetricTerms( diff --git a/test_data/RESTART/eta91.nc b/test_data/RESTART/eta91.nc new file mode 100644 index 0000000..10efe21 Binary files /dev/null and b/test_data/RESTART/eta91.nc differ diff --git a/tests/integration/test_all.py b/tests/integration/test_all.py index 80850ad..827a2d2 100644 --- a/tests/integration/test_all.py +++ b/tests/integration/test_all.py @@ -7,7 +7,7 @@ import ndsl.constants as constants import pyshield.constants as physcons -from ndsl import NullComm, Quantity, QuantityFactory, StencilFactory, TileCommunicator +from ndsl import LocalComm, Quantity, QuantityFactory, StencilFactory, TileCommunicator from ndsl.boilerplate import get_factories_single_tile from ndsl.grid import ( AngleGridData, @@ -41,7 +41,7 @@ def setup_infrastructure( nx=nx, ny=ny, nz=nzsoil, nhalo=nhalo, backend=backend ) rank = 0 - comm = NullComm(rank, 1) + comm = LocalComm(rank, total_ranks=1, buffer_dict={}) communicator = TileCommunicator.from_layout(comm=comm, layout=(1, 1)) metric_terms = MetricTerms( diff --git a/tests/integration/test_gfdl_cld_mp.py b/tests/integration/test_gfdl_cld_mp.py index d8f6e61..ac9f091 100644 --- a/tests/integration/test_gfdl_cld_mp.py +++ b/tests/integration/test_gfdl_cld_mp.py @@ -6,7 +6,7 @@ import ndsl.constants as constants import pyshield.constants as physcons -from ndsl import NullComm, Quantity, QuantityFactory, StencilFactory, TileCommunicator +from ndsl import LocalComm, Quantity, QuantityFactory, StencilFactory, TileCommunicator from ndsl.boilerplate import get_factories_single_tile from ndsl.grid import ( AngleGridData, @@ -27,7 +27,7 @@ def setup_infrastructure( nx=nx, ny=ny, nz=nz, nhalo=nhalo, backend=backend ) rank = 0 - comm = NullComm(rank, 1) + comm = LocalComm(rank, total_ranks=1, buffer_dict={}) communicator = TileCommunicator.from_layout(comm=comm, layout=(1, 1)) metric_terms = MetricTerms( diff --git a/tests/integration/test_gfs_mp.py b/tests/integration/test_gfs_mp.py index 148ca65..7945b95 100644 --- a/tests/integration/test_gfs_mp.py +++ b/tests/integration/test_gfs_mp.py @@ -6,7 +6,7 @@ import ndsl.constants as constants import pyshield.constants as physcons -from ndsl import NullComm, Quantity, QuantityFactory, StencilFactory, TileCommunicator +from ndsl import LocalComm, Quantity, QuantityFactory, StencilFactory, TileCommunicator from ndsl.boilerplate import get_factories_single_tile from ndsl.grid import ( AngleGridData, @@ -26,7 +26,7 @@ def setup_infrastructure( nx=nx, ny=ny, nz=nz, nhalo=nhalo, backend=backend ) rank = 0 - comm = NullComm(rank, 1) + comm = LocalComm(rank, total_ranks=1, buffer_dict={}) communicator = TileCommunicator.from_layout(comm=comm, layout=(1, 1)) metric_terms = MetricTerms( diff --git a/tests/integration/test_radiation_driver.py b/tests/integration/test_radiation_driver.py index 547a118..7239b43 100644 --- a/tests/integration/test_radiation_driver.py +++ b/tests/integration/test_radiation_driver.py @@ -5,7 +5,7 @@ import pytest import xarray as xr -from ndsl import NullComm, Quantity, QuantityFactory, TileCommunicator +from ndsl import LocalComm, Quantity, QuantityFactory, TileCommunicator from ndsl.boilerplate import get_factories_single_tile from ndsl.grid import ( AngleGridData, @@ -29,7 +29,7 @@ def setup_infrastructure( nx=nx, ny=ny, nz=nz, nhalo=nhalo, backend=backend ) rank = 0 - comm = NullComm(rank, 1) + comm = LocalComm(rank, total_ranks=1, buffer_dict={}) communicator = TileCommunicator.from_layout(comm=comm, layout=(1, 1)) metric_terms = MetricTerms( diff --git a/tests/integration/test_samfshalconv.py b/tests/integration/test_samfshalconv.py index 9f43368..0564e48 100644 --- a/tests/integration/test_samfshalconv.py +++ b/tests/integration/test_samfshalconv.py @@ -6,7 +6,7 @@ import ndsl.constants as constants import pyshield.constants as physcons -from ndsl import NullComm, Quantity, QuantityFactory, StencilFactory, TileCommunicator +from ndsl import LocalComm, Quantity, QuantityFactory, StencilFactory, TileCommunicator from ndsl.boilerplate import get_factories_single_tile from ndsl.grid import ( AngleGridData, @@ -27,7 +27,7 @@ def setup_infrastructure( nx=nx, ny=ny, nz=nz, nhalo=nhalo, backend=backend ) rank = 0 - comm = NullComm(rank, 1) + comm = LocalComm(rank, total_ranks=1, buffer_dict={}) communicator = TileCommunicator.from_layout(comm=comm, layout=(1, 1)) metric_terms = MetricTerms( diff --git a/tests/integration/test_satmedmf.py b/tests/integration/test_satmedmf.py index e9468e8..7ea47ef 100644 --- a/tests/integration/test_satmedmf.py +++ b/tests/integration/test_satmedmf.py @@ -6,7 +6,7 @@ import ndsl.constants as constants import pyshield.constants as physcons -from ndsl import NullComm, Quantity, QuantityFactory, StencilFactory, TileCommunicator +from ndsl import LocalComm, Quantity, QuantityFactory, StencilFactory, TileCommunicator from ndsl.boilerplate import get_factories_single_tile from ndsl.grid import ( AngleGridData, @@ -27,7 +27,7 @@ def setup_infrastructure( nx=nx, ny=ny, nz=nz, nhalo=nhalo, backend=backend ) rank = 0 - comm = NullComm(rank, 1) + comm = LocalComm(rank, total_ranks=1, buffer_dict={}) communicator = TileCommunicator.from_layout(comm=comm, layout=(1, 1)) metric_terms = MetricTerms( diff --git a/tests/integration/test_sfc.py b/tests/integration/test_sfc.py index 43005a9..8904f6d 100644 --- a/tests/integration/test_sfc.py +++ b/tests/integration/test_sfc.py @@ -9,7 +9,7 @@ from ndsl import ( CompilationConfig, GridIndexing, - NullComm, + LocalComm, Quantity, QuantityFactory, StencilConfig, @@ -115,7 +115,7 @@ def setup_infrastructure(nx: Int, ny: Int, nz: Int, nzsoil: Int, etafile: Path): rank = 0 backend = "numpy" - comm = NullComm(rank, 1) + comm = LocalComm(rank, total_ranks=1, buffer_dict={}) communicator = TileCommunicator.from_layout(comm=comm, layout=(1, 1)) sizer = SubtileGridSizer.from_tile_params(