diff --git a/model/common/src/icon4py/model/common/utils/__init__.py b/model/common/src/icon4py/model/common/utils/__init__.py index 0e651cc3a..c77b6ecd5 100644 --- a/model/common/src/icon4py/model/common/utils/__init__.py +++ b/model/common/src/icon4py/model/common/utils/__init__.py @@ -8,7 +8,6 @@ from __future__ import annotations -from . import fields from ._common import ( DoubleBuffering, Pair, @@ -17,6 +16,7 @@ chainable, named_property, ) +from . import fields, serialbox __all__ = [ @@ -30,4 +30,5 @@ "chainable", # Modules "fields", + "serialbox", ] diff --git a/model/common/src/icon4py/model/common/utils/fields.py b/model/common/src/icon4py/model/common/utils/fields.py index 9fc763a8c..76fcb3689 100644 --- a/model/common/src/icon4py/model/common/utils/fields.py +++ b/model/common/src/icon4py/model/common/utils/fields.py @@ -5,8 +5,11 @@ # # Please, refer to the LICENSE file in the root directory. # SPDX-License-Identifier: BSD-3-Clause + +from __future__ import annotations + import logging as log -from typing import Optional, TypeAlias, Union +from typing import Optional, TypeAlias, Union, TYPE_CHECKING import gt4py._core.definitions as gt_core_defs import gt4py.next as gtx @@ -14,13 +17,16 @@ import numpy as np import numpy.typing as npt -from icon4py.model.common import dimension, type_alias as ta -from icon4py.model.common.grid.base import BaseGrid +from icon4py.model.common import type_alias as ta + +if TYPE_CHECKING: + from icon4py.model.common import dimension + from icon4py.model.common.grid import base as grid_base -""" Enum values from Enum values taken from DLPack reference implementation at: - https://github.com/dmlc/dlpack/blob/main/include/dlpack/dlpack.h - via GT4Py -""" + +#: Enum values from Enum values taken from DLPack reference implementation at: +#: https://github.com/dmlc/dlpack/blob/main/include/dlpack/dlpack.h +#: via GT4Py CUDA_DEVICE_TYPES = ( gt_core_defs.DeviceType.CUDA, gt_core_defs.DeviceType.CUDA_MANAGED, @@ -129,7 +135,7 @@ def random_field( return as_field(dims, arr) def zero_field( - grid: BaseGrid, + grid: grid_base.BaseGrid, *dims: gtx.Dimension, dtype=ta.wpfloat, extend: Optional[dict[gtx.Dimension, int]] = None, @@ -138,7 +144,7 @@ def zero_field( def constant_field( - grid: BaseGrid, value: float, *dims: gtx.Dimension, dtype=ta.wpfloat + grid: grid_base.BaseGrid, value: float, *dims: gtx.Dimension, dtype=ta.wpfloat ) -> gtx.Field: return as_field( dims, @@ -157,7 +163,7 @@ def _shape( def random_mask( - grid: BaseGrid, + grid: grid_base.BaseGrid, *dims: gtx.Dimension, dtype: Optional[npt.DTypeLike] = None, extend: Optional[dict[gtx.Dimension, int]] = None, @@ -196,5 +202,3 @@ def allocate_indices( xp = import_array_ns(backend) shapex = _size(grid, dim, is_halfdim) return gtx.as_field((dim,), xp.arange(shapex, dtype=dtype), allocator=backend) - - diff --git a/noxfile.py b/noxfile.py index 53a207926..f592748b8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -9,7 +9,7 @@ import nox nox.options.default_venv_backend = "uv" -nox.options.sessions = ["lint", "test"] +#nox.options.sessions = ["lint", "test"] def session_install( diff --git a/pyproject.toml b/pyproject.toml index f9c2b14d1..2dd3be97a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,6 +65,9 @@ docs = [ ] lint = ["pre-commit>=4.0.1", "ruff>=0.8.0", "tach>=0.16.0"] test = [ + # workspace members + "icon4py-testing>=0.0.6", + # external dependencies "coverage[toml]>=7.5.0", "nox @ git+https://github.com/wntrblm/nox.git@aa09595437608dfe21eb776d8a4bcc0bd5f9916b", # TODO: remove once next version is released "pytest>=8.0.1", diff --git a/tach.toml b/tach.toml index 3ac439c0f..860035697 100644 --- a/tach.toml +++ b/tach.toml @@ -1,4 +1,7 @@ +exact = true exclude = [] +forbid_circular_dependencies = true +interfaces = [] source_roots = [ "model/atmosphere/advection/src", "model/atmosphere/diffusion/src", @@ -6,6 +9,7 @@ source_roots = [ "model/atmosphere/subgrid_scale_physics/microphysics/src", "model/common/src", "model/driver/src", + "model/testing/src", "tools/src", ] @@ -45,6 +49,12 @@ depends_on = [ { path = "icon4py.model.common" }, ] +[[modules]] +path = "icon4py.model.testing" +depends_on = [ + { path = "icon4py.model.common" }, +] + [[modules]] path = "icon4pytools" depends_on = [] diff --git a/tools/pyproject.toml b/tools/pyproject.toml index b0e5c35d7..fd8a56625 100644 --- a/tools/pyproject.toml +++ b/tools/pyproject.toml @@ -102,8 +102,6 @@ parallel = true source_pkgs = ['icon4pytools'] # -- pytest -- -[tool.pytest] - [tool.pytest.ini_options] addopts = ['-p icon4py.model.testing.pytest_config'] markers = [ diff --git a/uv.lock b/uv.lock index e7895f0c4..e18d28ffe 100644 --- a/uv.lock +++ b/uv.lock @@ -2,16 +2,40 @@ version = 1 requires-python = ">=3.10" resolution-markers = [ "python_full_version < '3.11' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version < '3.11' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version < '3.11' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.11.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.11.*' and implementation_name == 'cpython' and sys_platform != 'windows'", "python_full_version == '3.11.*' and implementation_name == 'cpython' and sys_platform != 'windows'", "python_full_version == '3.12.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.12.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.12.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version >= '3.13' and implementation_name == 'cpython' and sys_platform != 'windows'", "python_full_version >= '3.13' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version >= '3.13' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version < '3.11' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version < '3.11' and implementation_name == 'cpython' and sys_platform != 'windows'", "python_full_version < '3.11' and implementation_name == 'cpython' and sys_platform != 'windows'", "python_full_version == '3.11.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.11.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.11.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.12.*' and implementation_name == 'cpython' and sys_platform != 'windows'", "python_full_version == '3.12.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.12.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version >= '3.13' and implementation_name == 'cpython' and sys_platform != 'windows'", "python_full_version >= '3.13' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version >= '3.13' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version < '3.11' and implementation_name == 'cpython' and sys_platform != 'windows'", "python_full_version < '3.11' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version < '3.11' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.11.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.11.*' and implementation_name == 'cpython' and sys_platform != 'windows'", "python_full_version == '3.11.*' and implementation_name == 'cpython' and sys_platform != 'windows'", "python_full_version == '3.12.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.12.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version == '3.12.*' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version >= '3.13' and implementation_name == 'cpython' and sys_platform != 'windows'", + "python_full_version >= '3.13' and implementation_name == 'cpython' and sys_platform != 'windows'", "python_full_version >= '3.13' and implementation_name == 'cpython' and sys_platform != 'windows'", ] supported-markers = [ @@ -1538,6 +1562,7 @@ build = [ dev = [ { name = "bump-my-version", marker = "implementation_name == 'cpython' and sys_platform != 'windows'" }, { name = "coverage", extra = ["toml"], marker = "implementation_name == 'cpython' and sys_platform != 'windows'" }, + { name = "icon4py-testing", marker = "implementation_name == 'cpython' and sys_platform != 'windows'" }, { name = "mypy", extra = ["faster-cache"], marker = "implementation_name == 'cpython' and sys_platform != 'windows'" }, { name = "myst-parser", marker = "implementation_name == 'cpython' and sys_platform != 'windows'" }, { name = "nox", marker = "implementation_name == 'cpython' and sys_platform != 'windows'" }, @@ -1579,6 +1604,7 @@ lint = [ ] test = [ { name = "coverage", extra = ["toml"], marker = "implementation_name == 'cpython' and sys_platform != 'windows'" }, + { name = "icon4py-testing", marker = "implementation_name == 'cpython' and sys_platform != 'windows'" }, { name = "nox", marker = "implementation_name == 'cpython' and sys_platform != 'windows'" }, { name = "pytest", marker = "implementation_name == 'cpython' and sys_platform != 'windows'" }, { name = "pytest-benchmark", marker = "implementation_name == 'cpython' and sys_platform != 'windows'" }, @@ -1623,6 +1649,7 @@ build = [ dev = [ { name = "bump-my-version", specifier = ">=0.16.0" }, { name = "coverage", extras = ["toml"], specifier = ">=7.5.0" }, + { name = "icon4py-testing", editable = "model/testing" }, { name = "mypy", extras = ["faster-cache"], specifier = ">=1.13.0" }, { name = "myst-parser", specifier = ">=4.0.0" }, { name = "nox", git = "https://github.com/wntrblm/nox.git?rev=aa09595437608dfe21eb776d8a4bcc0bd5f9916b#aa09595437608dfe21eb776d8a4bcc0bd5f9916b" }, @@ -1664,6 +1691,7 @@ lint = [ ] test = [ { name = "coverage", extras = ["toml"], specifier = ">=7.5.0" }, + { name = "icon4py-testing", editable = "model/testing" }, { name = "nox", git = "https://github.com/wntrblm/nox.git?rev=aa09595437608dfe21eb776d8a4bcc0bd5f9916b#aa09595437608dfe21eb776d8a4bcc0bd5f9916b" }, { name = "pytest", specifier = ">=8.0.1" }, { name = "pytest-benchmark", specifier = ">=5.0.0" },