Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Comment thread
havogt marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- main
types: [opened, reopened, synchronize]
jobs:
test-tools:
test-bindings:
Comment thread
havogt marked this conversation as resolved.
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -28,10 +28,10 @@ jobs:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: ${{ matrix.python-version }}
- name: run nox session - tools
- name: run nox session - tools and bindings
env:
NUM_PROCESSES: auto
PYTEST_ADDOPTS: "--durations=0"
shell: bash
run: |
uv run nox -s "test_tools-${{matrix.python-version}}(unittest)" --
uv run nox -s "test_tools_and_bindings-${{matrix.python-version}}(unittest)" --
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ repos:
args: [--unsafe]
- id: debug-statements
- id: end-of-file-fixer
exclude: ^tools/tests/tools/py2fgen/wrappers/references/
exclude: ^bindings/tests/bindings/references/
- id: pretty-format-json
args: [--autofix, --indent, "2"]

Expand All @@ -55,7 +55,7 @@ repos:
name: add license for all ICON4Py Python source files
types: [python]
args: [--comment-style, "|#|", --license-filepath, ./HEADER.txt, --fuzzy-match-generates-todo]
exclude: ^tools/tests/tools/py2fgen/wrappers/references/
exclude: ^bindings/tests/bindings/references/

# The following hooks use development tools which are already managed by 'uv'.
# To avoid inconsistencies between the development and the pre-commit
Expand Down
93 changes: 93 additions & 0 deletions bindings/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# -- Build system requirements (PEP 518) --

[build-system]
build-backend = 'setuptools.build_meta'
requires = ['setuptools>=61.0', 'wheel>=0.40.0']

# -- Standard project description options (PEP 621) --
[project]
authors = [{email = 'gridtools@cscs.ch', name = 'ETH Zurich'}]
classifiers = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Scientific/Engineering :: Atmospheric Science',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Scientific/Engineering :: Physics'
]
dependencies = [
# workspace members
'icon4py-atmosphere-diffusion~=0.1.0',
'icon4py-atmosphere-dycore~=0.1.0',
'icon4py-atmosphere-muphys~=0.1.0',
'icon4py-common~=0.1.0',
'icon4py-tools~=0.1.0',
# external dependencies
'cffi>=1.5',
'gt4py==1.1.9',
"numpy>=1.23.3",
'packaging>=20.0'
]
description = 'Fortran bindings for icon4py model components.'
license = {text = "BSD-3 License"}
name = 'icon4py-bindings'
Comment thread
havogt marked this conversation as resolved.
readme = 'README.md'
requires-python = '>=3.10'
# managed by bump-my-version:
version = "0.1.0"

[project.optional-dependencies]
cuda11 = ['cupy-cuda11x>=13.0', 'gt4py[cuda11]']
cuda12 = ['cupy-cuda12x>=13.0', 'gt4py[cuda12]']
profiling = ['viztracer>=1.1.0']

[project.urls]
Homepage = 'https://github.com/C2SM/icon4py'

# -- bumpversion --
[tool.bumpversion]
allow_dirty = false
commit = false
current_version = "0.1.0"
ignore_missing_version = false
message = 'Bump icon4py-bindings version: {current_version} → {new_version}'
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)?"
serialize = ["{major}.{minor}.{patch}"]
tag = false

[[tool.bumpversion.files]]
filename = "pyproject.toml"
replace = '''
# managed by bump-my-version:
version = "{new_version}"
'''
search = '''
# managed by bump-my-version:
version = "{current_version}"
'''

[[tool.bumpversion.files]]
filename = "src/icon4py/bindings/__init__.py"

# -- ruff --
[tool.ruff]
extend = "../pyproject.toml"
extend-exclude = ["tests/bindings/references/*"]

[tool.ruff.lint.isort]
known-first-party = ['icon4py']
known-third-party = ['gt4py']

# -- setuptools --
[tool.setuptools.package-data]
'*' = ['*.in', '*.md', '*.rst', '*.txt', 'LICENSE', 'py.typed']

[tool.setuptools.packages]
find = {namespaces = true, where = ['src']}
29 changes: 29 additions & 0 deletions bindings/src/icon4py/bindings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ICON4Py - ICON inspired code in Python and GT4Py
#
# Copyright (c) 2022-2024, ETH Zurich and MeteoSwiss
# All rights reserved.
#
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause

"""Package metadata: version, authors, license and copyright."""

from typing import Final

from packaging import version as pkg_version


__all__ = [
"__author__",
"__copyright__",
"__license__",
"__version__",
"__version_info__",
]

__author__: Final = "ETH Zurich, MeteoSwiss and individual contributors"
__copyright__: Final = "Copyright (c) 2022-2024 ETH Zurich and MeteoSwiss"
__license__: Final = "BSD-3-Clause"

__version__: Final = "0.1.0"
__version_info__: Final = pkg_version.parse(__version__)
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
TODO(havogt): refactor py2fgen to generate a single module from functions in different files.
"""

from icon4py.tools.py2fgen.wrappers.diffusion_wrapper import diffusion_init, diffusion_run
from icon4py.tools.py2fgen.wrappers.dycore_wrapper import solve_nh_init, solve_nh_run
from icon4py.tools.py2fgen.wrappers.grid_wrapper import grid_init
from icon4py.bindings.diffusion_wrapper import diffusion_init, diffusion_run
from icon4py.bindings.dycore_wrapper import solve_nh_init, solve_nh_run
from icon4py.bindings.grid_wrapper import grid_init


__all__ = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
import numpy as np

import icon4py.model.common.utils.data_allocation as data_alloc
from icon4py.bindings import (
common as wrapper_common,
config as wrapper_config,
grid_wrapper,
icon4py_export,
)
from icon4py.model.atmosphere.diffusion.diffusion import (
Diffusion,
DiffusionConfig,
Expand All @@ -38,12 +44,6 @@
from icon4py.model.common import dimension as dims, field_type_aliases as fa, model_backends
from icon4py.model.common.states.prognostic_state import PrognosticState
from icon4py.model.common.type_alias import wpfloat
from icon4py.tools.py2fgen.wrappers import (
common as wrapper_common,
config as wrapper_config,
grid_wrapper,
icon4py_export,
)


logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
from gt4py.next.instrumentation import metrics as gtx_metrics
from gt4py.next.type_system import type_specifications as ts

from icon4py.model.atmosphere.dycore import dycore_states, solve_nonhydro
from icon4py.model.common import dimension as dims, model_backends, utils as common_utils
from icon4py.model.common.states.prognostic_state import PrognosticState
from icon4py.model.common.utils import data_allocation as data_alloc, field_utils
from icon4py.tools import py2fgen
from icon4py.tools.py2fgen.wrappers import (
from icon4py.bindings import (
common as wrapper_common,
config as wrapper_config,
grid_wrapper,
icon4py_export,
)
from icon4py.model.atmosphere.dycore import dycore_states, solve_nonhydro
from icon4py.model.common import dimension as dims, model_backends, utils as common_utils
from icon4py.model.common.states.prognostic_state import PrognosticState
from icon4py.model.common.utils import data_allocation as data_alloc, field_utils
from icon4py.tools import py2fgen


logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
from gt4py.next.type_system import type_specifications as ts

import icon4py.model.common.grid.states as grid_states
from icon4py.bindings import (
common as wrapper_common,
debug_utils as wrapper_debug_utils,
icon4py_export,
)
from icon4py.model.common import dimension as dims, field_type_aliases as fa, model_backends
from icon4py.model.common.decomposition import definitions as decomposition_defs
from icon4py.model.common.grid import icon as icon_grid, vertical
from icon4py.model.common.type_alias import wpfloat
from icon4py.tools import py2fgen
from icon4py.tools.py2fgen.wrappers import (
common as wrapper_common,
debug_utils as wrapper_debug_utils,
icon4py_export,
)


logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from gt4py import next as gtx
from gt4py.next.instrumentation import metrics as gtx_metrics

from icon4py.bindings import icon4py_export
from icon4py.model.atmosphere.subgrid_scale_physics.muphys.driver import run_graupel_only
from icon4py.model.atmosphere.subgrid_scale_physics.muphys.implementations import graupel
from icon4py.model.common import dimension as dims, model_backends, type_alias as ta
from icon4py.tools.py2fgen.wrappers import icon4py_export


graupel_program = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
# mypy: ignore-errors
import gt4py.next as gtx

from icon4py.bindings.icon4py_export import export
from icon4py.model.common import dimension as dims
from icon4py.model.common.grid.simple import simple_grid
from icon4py.tools.py2fgen.wrappers.icon4py_export import export


grid = simple_grid()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

To enable this plugin
- install `viztracer` ('pip install viztracer') or `icon4py-tools[profiling]`
- set the environment variable `PY2FGEN_EXTRA_CALLABLES=icon4py.tools.py2fgen.wrappers.viztracer_plugin:init`
- set the environment variable `PY2FGEN_EXTRA_CALLABLES=icon4py.bindings.viztracer_plugin:init`
- set the environment variable
- `ICON4PY_TRACING_RANGE` in the format 'start:stop' to define the range of calls to be traced, and
- `ICON4PY_TRACING_NAMES` to specify the names of the functions to be traced (comma-separated)
Expand All @@ -27,8 +27,8 @@

import viztracer # type: ignore[import-not-found]

from icon4py.bindings import grid_wrapper
from icon4py.tools.py2fgen import runtime_config
from icon4py.tools.py2fgen.wrappers import grid_wrapper


@dataclasses.dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@


# embedded function imports
from icon4py.tools.py2fgen.wrappers.diffusion_wrapper import diffusion_run
from icon4py.tools.py2fgen.wrappers.diffusion_wrapper import diffusion_init
from icon4py.bindings.diffusion_wrapper import diffusion_run
from icon4py.bindings.diffusion_wrapper import diffusion_init


@ffi.def_extern()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@


# embedded function imports
from icon4py.tools.py2fgen.wrappers.dycore_wrapper import solve_nh_run
from icon4py.tools.py2fgen.wrappers.dycore_wrapper import solve_nh_init
from icon4py.bindings.dycore_wrapper import solve_nh_run
from icon4py.bindings.dycore_wrapper import solve_nh_init


@ffi.def_extern()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


# embedded function imports
from icon4py.tools.py2fgen.wrappers.grid_wrapper import grid_init
from icon4py.bindings.grid_wrapper import grid_init


@ffi.def_extern()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ def check_generated_files(bindings_name: str) -> None:
[
(
"diffusion",
"icon4py.tools.py2fgen.wrappers.diffusion_wrapper",
"icon4py.bindings.diffusion_wrapper",
"diffusion_run, diffusion_init",
),
(
"dycore",
"icon4py.tools.py2fgen.wrappers.dycore_wrapper",
"icon4py.bindings.dycore_wrapper",
"solve_nh_run, solve_nh_init",
),
(
"grid",
"icon4py.tools.py2fgen.wrappers.grid_wrapper",
"icon4py.bindings.grid_wrapper",
"grid_init",
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import numpy as np
import pytest

from icon4py.bindings import common as wrapper_common, diffusion_wrapper
from icon4py.model.atmosphere.diffusion import diffusion, diffusion_states
from icon4py.model.common import dimension as dims
from icon4py.model.common.grid import states as grid_states, vertical as v_grid
from icon4py.model.testing import definitions, test_utils as testing_test_utils
from icon4py.tools import py2fgen
from icon4py.tools.py2fgen import test_utils
from icon4py.tools.py2fgen.wrappers import common as wrapper_common, diffusion_wrapper

from . import utils
from .test_grid_init import grid_init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import numpy as np
import pytest

from icon4py.bindings import common as wrapper_common, dycore_wrapper
from icon4py.model.atmosphere.dycore import dycore_states, solve_nonhydro as solve_nh
from icon4py.model.common import constants, dimension as dims, utils as common_utils
from icon4py.model.common.grid import horizontal as h_grid, vertical as v_grid
Expand All @@ -23,7 +24,6 @@
from icon4py.model.testing import definitions, test_utils as testing_test_utils
from icon4py.tools import py2fgen
from icon4py.tools.py2fgen import test_utils
from icon4py.tools.py2fgen.wrappers import common as wrapper_common, dycore_wrapper

from . import utils
from .test_grid_init import grid_init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import numpy as np
import pytest

from icon4py.bindings import common as wrapper_common, grid_wrapper
from icon4py.model.common import dimension as dims
from icon4py.tools.py2fgen import test_utils
from icon4py.tools.py2fgen.wrappers import common as wrapper_common, grid_wrapper


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from gt4py import next as gtx
from gt4py.next.type_system import type_specifications as ts

from icon4py.bindings import icon4py_export
from icon4py.tools import py2fgen
from icon4py.tools.py2fgen.wrappers import icon4py_export


export_with_mapping_hook = py2fgen.export(
Expand Down
Loading
Loading