Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into itir_temporaries_heur…
Browse files Browse the repository at this point in the history
…istics2
  • Loading branch information
tehrengruber committed Oct 23, 2023
2 parents 83577d2 + d11246e commit fdad59b
Show file tree
Hide file tree
Showing 42 changed files with 1,299 additions and 852 deletions.
22 changes: 11 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ repos:
## version = re.search('black==([0-9\.]*)', open("constraints.txt").read())[1]
## print(f"rev: '{version}' # version from constraints.txt")
##]]]
rev: '23.7.0' # version from constraints.txt
rev: '23.9.1' # version from constraints.txt
##[[[end]]]
hooks:
- id: black
Expand Down Expand Up @@ -97,7 +97,7 @@ repos:
## print(f"- {pkg}==" + str(re.search(f'\n{pkg}==([0-9\.]*)', constraints)[1]))
##]]]
- darglint==1.8.1
- flake8-bugbear==23.7.10
- flake8-bugbear==23.9.16
- flake8-builtins==2.1.0
- flake8-debugger==4.1.2
- flake8-docstrings==1.7.0
Expand Down Expand Up @@ -146,9 +146,9 @@ repos:
## version = re.search('mypy==([0-9\.]*)', open("constraints.txt").read())[1]
## print(f"#========= FROM constraints.txt: v{version} =========")
##]]]
#========= FROM constraints.txt: v1.5.0 =========
#========= FROM constraints.txt: v1.5.1 =========
##[[[end]]]
rev: v1.5.0 # MUST match version ^^^^ in constraints.txt (if the mirror is up-to-date)
rev: v1.5.1 # MUST match version ^^^^ in constraints.txt (if the mirror is up-to-date)
hooks:
- id: mypy
additional_dependencies: # versions from constraints.txt
Expand All @@ -162,26 +162,26 @@ repos:
##]]]
- astunparse==1.6.3
- attrs==23.1.0
- black==23.7.0
- black==23.9.1
- boltons==23.0.0
- cached-property==1.5.2
- click==8.1.6
- cmake==3.27.2
- click==8.1.7
- cmake==3.27.5
- cytoolz==0.12.2
- deepdiff==6.3.1
- devtools==0.11.0
- deepdiff==6.5.0
- devtools==0.12.2
- frozendict==2.3.8
- gridtools-cpp==2.3.1
- importlib-resources==6.0.1
- jinja2==3.1.2
- lark==1.1.7
- mako==1.2.4
- nanobind==1.5.0
- nanobind==1.5.2
- ninja==1.11.1
- numpy==1.24.4
- packaging==23.1
- pybind11==2.11.1
- setuptools==68.1.0
- setuptools==68.2.2
- tabulate==0.9.0
- typing-extensions==4.5.0
- xxhash==3.0.0
Expand Down
78 changes: 39 additions & 39 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
#
aenum==3.1.15 # via dace
alabaster==0.7.13 # via sphinx
asttokens==2.2.1 # via devtools
asttokens==2.4.0 # via devtools
astunparse==1.6.3 ; python_version < "3.9" # via dace, gt4py (pyproject.toml)
attrs==23.1.0 # via flake8-bugbear, flake8-eradicate, gt4py (pyproject.toml), hypothesis, jsonschema, referencing
babel==2.12.1 # via sphinx
black==23.7.0 # via gt4py (pyproject.toml)
black==23.9.1 # via gt4py (pyproject.toml)
blinker==1.6.2 # via flask
boltons==23.0.0 # via gt4py (pyproject.toml)
build==0.10.0 # via pip-tools
build==1.0.3 # via pip-tools
cached-property==1.5.2 # via gt4py (pyproject.toml)
cachetools==5.3.1 # via tox
certifi==2023.7.22 # via requests
Expand All @@ -22,17 +22,17 @@ cfgv==3.4.0 # via pre-commit
chardet==5.2.0 # via tox
charset-normalizer==3.2.0 # via requests
clang-format==16.0.6 # via -r requirements-dev.in, gt4py (pyproject.toml)
click==8.1.6 # via black, flask, gt4py (pyproject.toml), pip-tools
cmake==3.27.2 # via gt4py (pyproject.toml)
click==8.1.7 # via black, flask, gt4py (pyproject.toml), pip-tools
cmake==3.27.5 # via gt4py (pyproject.toml)
cogapp==3.3.0 # via -r requirements-dev.in
colorama==0.4.6 # via tox
coverage==7.3.0 # via -r requirements-dev.in, pytest-cov
coverage==7.3.1 # via -r requirements-dev.in, pytest-cov
cryptography==41.0.3 # via types-paramiko, types-pyopenssl, types-redis
cytoolz==0.12.2 # via gt4py (pyproject.toml)
dace==0.14.4 # via gt4py (pyproject.toml)
darglint==1.8.1 # via -r requirements-dev.in
deepdiff==6.3.1 # via gt4py (pyproject.toml)
devtools==0.11.0 # via gt4py (pyproject.toml)
deepdiff==6.5.0 # via gt4py (pyproject.toml)
devtools==0.12.2 # via gt4py (pyproject.toml)
dill==0.3.7 # via dace
distlib==0.3.7 # via virtualenv
docutils==0.18.1 # via restructuredtext-lint, sphinx, sphinx-rtd-theme
Expand All @@ -41,26 +41,26 @@ exceptiongroup==1.1.3 # via hypothesis, pytest
execnet==2.0.2 # via pytest-cache, pytest-xdist
executing==1.2.0 # via devtools
factory-boy==3.3.0 # via -r requirements-dev.in, pytest-factoryboy
faker==19.3.0 # via factory-boy
faker==19.6.1 # via factory-boy
fastjsonschema==2.18.0 # via nbformat
filelock==3.12.2 # via tox, virtualenv
filelock==3.12.4 # via tox, virtualenv
flake8==6.1.0 # via -r requirements-dev.in, flake8-bugbear, flake8-builtins, flake8-debugger, flake8-docstrings, flake8-eradicate, flake8-mutable, flake8-pyproject, flake8-rst-docstrings
flake8-bugbear==23.7.10 # via -r requirements-dev.in
flake8-bugbear==23.9.16 # via -r requirements-dev.in
flake8-builtins==2.1.0 # via -r requirements-dev.in
flake8-debugger==4.1.2 # via -r requirements-dev.in
flake8-docstrings==1.7.0 # via -r requirements-dev.in
flake8-eradicate==1.5.0 # via -r requirements-dev.in
flake8-mutable==1.2.0 # via -r requirements-dev.in
flake8-pyproject==1.2.3 # via -r requirements-dev.in
flake8-rst-docstrings==0.3.0 # via -r requirements-dev.in
flask==2.3.2 # via dace
flask==2.3.3 # via dace
frozendict==2.3.8 # via gt4py (pyproject.toml)
gridtools-cpp==2.3.1 # via gt4py (pyproject.toml)
hypothesis==6.82.4 # via -r requirements-dev.in, gt4py (pyproject.toml)
identify==2.5.26 # via pre-commit
hypothesis==6.86.1 # via -r requirements-dev.in, gt4py (pyproject.toml)
identify==2.5.29 # via pre-commit
idna==3.4 # via requests
imagesize==1.4.1 # via sphinx
importlib-metadata==6.8.0 # via flask, sphinx
importlib-metadata==6.8.0 # via build, flask, sphinx
importlib-resources==6.0.1 ; python_version < "3.9" # via gt4py (pyproject.toml), jsonschema, jsonschema-specifications
inflection==0.5.1 # via pytest-factoryboy
iniconfig==2.0.0 # via pytest
Expand All @@ -70,7 +70,7 @@ jinja2==3.1.2 # via flask, gt4py (pyproject.toml), sphinx
jsonschema==4.19.0 # via nbformat
jsonschema-specifications==2023.7.1 # via jsonschema
jupyter-core==5.3.1 # via nbformat
jupytext==1.15.0 # via -r requirements-dev.in
jupytext==1.15.2 # via -r requirements-dev.in
lark==1.1.7 # via gt4py (pyproject.toml)
mako==1.2.4 # via gt4py (pyproject.toml)
markdown-it-py==3.0.0 # via jupytext, mdit-py-plugins
Expand All @@ -79,9 +79,9 @@ mccabe==0.7.0 # via flake8
mdit-py-plugins==0.4.0 # via jupytext
mdurl==0.1.2 # via markdown-it-py
mpmath==1.3.0 # via sympy
mypy==1.5.0 # via -r requirements-dev.in
mypy==1.5.1 # via -r requirements-dev.in
mypy-extensions==1.0.0 # via black, mypy
nanobind==1.5.0 # via gt4py (pyproject.toml)
nanobind==1.5.2 # via gt4py (pyproject.toml)
nbformat==5.9.2 # via jupytext
networkx==3.1 # via dace
ninja==1.11.1 # via gt4py (pyproject.toml)
Expand All @@ -94,36 +94,36 @@ pip-tools==7.3.0 # via -r requirements-dev.in
pipdeptree==2.13.0 # via -r requirements-dev.in
pkgutil-resolve-name==1.3.10 # via jsonschema
platformdirs==3.10.0 # via black, jupyter-core, tox, virtualenv
pluggy==1.2.0 # via pytest, tox
pluggy==1.3.0 # via pytest, tox
ply==3.11 # via dace
pre-commit==3.3.3 # via -r requirements-dev.in
pre-commit==3.4.0 # via -r requirements-dev.in
psutil==5.9.5 # via -r requirements-dev.in, pytest-xdist
pybind11==2.11.1 # via gt4py (pyproject.toml)
pycodestyle==2.11.0 # via flake8, flake8-debugger
pycparser==2.21 # via cffi
pydocstyle==6.3.0 # via flake8-docstrings
pyflakes==3.1.0 # via flake8
pygments==2.16.1 # via -r requirements-dev.in, flake8-rst-docstrings, sphinx
pyproject-api==1.5.3 # via tox
pygments==2.16.1 # via -r requirements-dev.in, devtools, flake8-rst-docstrings, sphinx
pyproject-api==1.6.1 # via tox
pyproject-hooks==1.0.0 # via build
pytest==7.4.0 # via -r requirements-dev.in, gt4py (pyproject.toml), pytest-cache, pytest-cov, pytest-factoryboy, pytest-xdist
pytest==7.4.2 # via -r requirements-dev.in, gt4py (pyproject.toml), pytest-cache, pytest-cov, pytest-factoryboy, pytest-xdist
pytest-cache==1.0 # via -r requirements-dev.in
pytest-cov==4.1.0 # via -r requirements-dev.in
pytest-factoryboy==2.5.1 # via -r requirements-dev.in
pytest-xdist==3.3.1 # via -r requirements-dev.in
python-dateutil==2.8.2 # via faker
pytz==2023.3 # via babel
pytz==2023.3.post1 # via babel
pyyaml==6.0.1 # via dace, jupytext, pre-commit
referencing==0.30.2 # via jsonschema, jsonschema-specifications
requests==2.31.0 # via dace, sphinx
restructuredtext-lint==1.4.0 # via flake8-rst-docstrings
rpds-py==0.9.2 # via jsonschema, referencing
ruff==0.0.284 # via -r requirements-dev.in
rpds-py==0.10.3 # via jsonschema, referencing
ruff==0.0.290 # via -r requirements-dev.in
six==1.16.0 # via asttokens, astunparse, python-dateutil
snowballstemmer==2.2.0 # via pydocstyle, sphinx
sortedcontainers==2.4.0 # via hypothesis
sphinx==6.2.1 # via -r requirements-dev.in, sphinx-rtd-theme, sphinxcontrib-jquery
sphinx-rtd-theme==1.2.2 # via -r requirements-dev.in
sphinx==7.1.2 # via -r requirements-dev.in, sphinx-rtd-theme, sphinxcontrib-jquery
sphinx-rtd-theme==1.3.0 # via -r requirements-dev.in
sphinxcontrib-applehelp==1.0.4 # via sphinx
sphinxcontrib-devhelp==1.0.2 # via sphinx
sphinxcontrib-htmlhelp==2.0.1 # via sphinx
Expand All @@ -136,8 +136,8 @@ tabulate==0.9.0 # via gt4py (pyproject.toml)
toml==0.10.2 # via jupytext
tomli==2.0.1 # via -r requirements-dev.in, black, build, coverage, flake8-pyproject, mypy, pip-tools, pyproject-api, pyproject-hooks, pytest, tox
toolz==0.12.0 # via cytoolz
tox==4.9.0 # via -r requirements-dev.in
traitlets==5.9.0 # via jupyter-core, nbformat
tox==4.11.3 # via -r requirements-dev.in
traitlets==5.10.0 # via jupyter-core, nbformat
types-aiofiles==23.2.0.0 # via types-all
types-all==1.0.0 # via -r requirements-dev.in
types-annoy==1.17.8.4 # via types-all
Expand Down Expand Up @@ -182,14 +182,14 @@ types-kazoo==0.1.3 # via types-all
types-markdown==3.4.2.10 # via types-all
types-markupsafe==1.1.10 # via types-all, types-jinja2
types-maxminddb==1.5.0 # via types-all, types-geoip2
types-mock==5.1.0.1 # via types-all
types-mock==5.1.0.2 # via types-all
types-mypy-extensions==1.0.0.5 # via types-all
types-nmap==0.1.6 # via types-all
types-openssl-python==0.1.3 # via types-all
types-orjson==3.6.2 # via types-all
types-paramiko==3.3.0.0 # via types-all, types-pysftp
types-pathlib2==2.3.0 # via types-all
types-pillow==10.0.0.2 # via types-all
types-pillow==10.0.0.3 # via types-all
types-pkg-resources==0.1.3 # via types-all
types-polib==1.2.0.1 # via types-all
types-protobuf==4.24.0.1 # via types-all
Expand All @@ -205,17 +205,17 @@ types-pysftp==0.2.17.6 # via types-all
types-python-dateutil==2.8.19.14 # via types-all, types-datetimerange
types-python-gflags==3.1.7.3 # via types-all
types-python-slugify==8.0.0.3 # via types-all
types-pytz==2023.3.0.1 # via types-all, types-tzlocal
types-pytz==2023.3.1.0 # via types-all, types-tzlocal
types-pyvmomi==8.0.0.6 # via types-all
types-pyyaml==6.0.12.11 # via types-all
types-redis==4.6.0.4 # via types-all
types-redis==4.6.0.6 # via types-all
types-requests==2.31.0.2 # via types-all
types-retry==0.9.9.4 # via types-all
types-routes==2.5.0 # via types-all
types-scribe==2.0.0 # via types-all
types-setuptools==68.1.0.0 # via types-cffi
types-setuptools==68.2.0.0 # via types-cffi
types-simplejson==3.19.0.2 # via types-all
types-singledispatch==4.0.0.2 # via types-all
types-singledispatch==4.1.0.0 # via types-all
types-six==1.16.21.9 # via types-all
types-tabulate==0.9.0.3 # via types-all
types-termcolor==1.1.6.2 # via types-all
Expand All @@ -230,13 +230,13 @@ types-werkzeug==1.0.9 # via types-all, types-flask
types-xxhash==3.0.5.2 # via types-all
typing-extensions==4.5.0 # via black, faker, gt4py (pyproject.toml), mypy, pytest-factoryboy
urllib3==2.0.4 # via requests
virtualenv==20.24.3 # via pre-commit, tox
virtualenv==20.24.5 # via pre-commit, tox
websockets==11.0.3 # via dace
werkzeug==2.3.7 # via flask
wheel==0.41.1 # via astunparse, pip-tools
wheel==0.41.2 # via astunparse, pip-tools
xxhash==3.0.0 # via gt4py (pyproject.toml)
zipp==3.16.2 # via importlib-metadata, importlib-resources

# The following packages are considered to be unsafe in a requirements file:
pip==23.2.1 # via pip-tools
setuptools==68.1.0 # via gt4py (pyproject.toml), nodeenv, pip-tools
setuptools==68.2.2 # via gt4py (pyproject.toml), nodeenv, pip-tools
80 changes: 80 additions & 0 deletions docs/development/ADRs/0015-Test_Exclusion_Matrices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
tags: []
---

# Test-Exclusion Matrices

- **Status**: valid
- **Authors**: Edoardo Paone (@edopao), Enrique G. Paredes (@egparedes)
- **Created**: 2023-09-21
- **Updated**: 2023-09-21

In the context of Field View testing, lacking support for specific ITIR features while a certain backend
is being developed, we decided to use `pytest` fixtures to exclude unsupported tests.

## Context

It should be possible to run Field View tests on different backends. However, specific tests could be unsupported
on a certain backend, or the backend implementation could be only partially ready.
Therefore, we need a mechanism to specify the features required by each test and selectively enable
the supported backends, while keeping the test code clean.

## Decision

It was decided to apply fixtures and markers from `pytest` module. The fixture is the same used to execute the test
on different backends (`fieldview_backend` and `program_processor`), but it is extended with a check on the available feature markers.
If a test is annotated with a feature marker, the fixture will check if this feature is supported on the selected backend.
If no marker is specified, the test is supposed to run on all backends.

In the example below, `test_offset_field` requires the backend to support dynamic offsets in the translation from ITIR:

```python
@pytest.mark.uses_dynamic_offsets
def test_offset_field(cartesian_case):
```

In order to selectively enable the backends, the dictionary `next_tests.exclusion_matrices.BACKEND_SKIP_TEST_MATRIX`
lists for each backend the features that are not supported.
The fixture will check if the annotated feature is present in the exclusion-matrix for the selected backend.
If so, the exclusion matrix will also specify the action `pytest` should take (e.g. `SKIP` or `XFAIL`).

The test-exclusion matrix is a dictionary, where `key` is the backend name and each entry is a tuple with the following fields:

`(<marker[str]>, <skip_definition[SKIP,XFAIL]>, <skip_message(format keys: 'marker', 'backend')>)`

The backend string, used both as dictionary key and as string formatter in the skip message, is retrieved
by calling `next_tests.get_processor_id()`, which returns the so-called processor name.
The following backend processors are defined:

```python
DACE = "dace_iterator.run_dace_iterator"
GTFN_CPU = "otf_compile_executor.run_gtfn"
GTFN_CPU_IMPERATIVE = "otf_compile_executor.run_gtfn_imperative"
GTFN_CPU_WITH_TEMPORARIES = "otf_compile_executor.run_gtfn_with_temporaries"
```

Following the previous example, the GTFN backend with temporaries does not support yet dynamic offsets in ITIR:

```python
BACKEND_SKIP_TEST_MATRIX = {
GTFN_CPU_WITH_TEMPORARIES: [
("uses_dynamic_offsets", pytest.XFAIL, "'{marker}' tests not supported by '{backend}' backend"),
]
}
```

## Consequences

Positive outcomes of this decision:

- The solution provides a central place to specify test exclusion.
- The test code remains clean from if-statements for backend exclusion.
- The exclusion matrix gives an overview of the feature-readiness of different backends.

Negative outcomes:

- There is not (yet) any code-style check to enforce this solution, so code reviews should be aware of the ADR.

## References <!-- optional -->

- [pytest - Using markers to pass data to fixtures](https://docs.pytest.org/en/6.2.x/fixture.html#using-markers-to-pass-data-to-fixtures)
4 changes: 2 additions & 2 deletions docs/development/ADRs/Index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ _None_
- [0011 - On The Fly Compilation](0011-On_The_Fly_Compilation.md)
- [0012 - GridTools C++ OTF](0011-_GridTools_Cpp_OTF.md)

### Miscellanea
### Testing

_None_
- [0015 - Exclusion Matrices](0015-Test_Exclusion_Matrices.md)

### Superseded

Expand Down
22 changes: 19 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,25 @@ module = 'gt4py.next.iterator.runtime'

[tool.pytest.ini_options]
markers = [
'requires_atlas', # mark tests that require 'atlas4py' bindings package
'requires_dace', # mark tests that require 'dace' package
'requires_gpu:' # mark tests that require a NVidia GPU (assume 'cupy' and 'cudatoolkit' are installed)
'requires_atlas: tests that require `atlas4py` bindings package',
'requires_dace: tests that require `dace` package',
'requires_gpu: tests that require a NVidia GPU (`cupy` and `cudatoolkit` are required)',
'uses_applied_shifts: tests that require backend support for applied-shifts',
'uses_can_deref: tests that require backend support for can_deref',
'uses_constant_fields: tests that require backend support for constant fields',
'uses_dynamic_offsets: tests that require backend support for dynamic offsets',
'uses_if_stmts: tests that require backend support for if-statements',
'uses_index_fields: tests that require backend support for index fields',
'uses_lift_expressions: tests that require backend support for lift expressions',
'uses_negative_modulo: tests that require backend support for modulo on negative numbers',
'uses_origin: tests that require backend support for domain origin',
'uses_reduction_over_lift_expressions: tests that require backend support for reduction over lift expressions',
'uses_scan_in_field_operator: tests that require backend support for scan in field operator',
'uses_sparse_fields: tests that require backend support for sparse fields',
'uses_strided_neighbor_offset: tests that require backend support for strided neighbor offset',
'uses_tuple_args: tests that require backend support for tuple arguments',
'uses_tuple_returns: tests that require backend support for tuple results',
'uses_zero_dimensional_fields: tests that require backend support for zero-dimensional fields'
]
norecursedirs = ['dist', 'build', 'cpp_backend_tests/build*', '_local/*', '.*']
testpaths = 'tests'
Expand Down
Loading

0 comments on commit fdad59b

Please sign in to comment.