Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
16 changes: 16 additions & 0 deletions src/gt4py/next/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import enum
import os
import pathlib
import warnings
from typing import Final


Expand Down Expand Up @@ -124,6 +125,21 @@ def env_flag_to_int(name: str, default: int) -> int:
DUMP_METRICS_AT_EXIT: str | None = None


#: Filter out DaCe related warnings. If not set warnings will be suppressed if the
#: code runs in no debug mode.
SKIP_DACE_WARNINGS: bool = env_flag_to_bool("GT4PY_SKIP_DACE_WARNINGS", default=not __debug__)


if SKIP_DACE_WARNINGS:
# NOTE: Ideally we would suppress the warnings using context managers directly in
# the backend. However, because this is not thread safe in Python versions before
# 3.14, we have to do it here.
warnings.filterwarnings(action="ignore", module="^dace(\..+)?")
warnings.filterwarnings(
action="ignore", module="^gt4py.next.program_processors.runners.dace(\..+)?"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
action="ignore", module="^gt4py.next.program_processors.runners.dace(\..+)?"
action="ignore", module="^gt4py.next.program_processors.runners.dace.transformations(\..+)?"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are also warnings in workflow that would still be active.
If the new flag (which might be badly named) should have the meaning "I know what I am doing with DaCe do not bother me" then we should keep the current pattern, I would say.

I have nothing against the changes, I just would like to point that out.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked the warnings and they look like real warnings, that should not appear in ICON-blueline.

Copy link
Copy Markdown
Contributor

@edopao edopao Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, I would only skip the warnings in dace.transformations.

)


def _init_dump_metrics_filename() -> str:
return f"gt4py_metrics_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.json"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1353,18 +1353,16 @@ def _handle_special_case_of_gt4py_scan_point(
if _handle_special_case_of_gt4py_scan_point_impl(
state, descending_point, concat_node, consumed_subset
):
if __debug__:
warnings.warn(
f"Special rule applied to `concat_where`-inline `{concat_node.data}` into `{nsdfg.label}`.",
stacklevel=1,
)
warnings.warn(
f"Special rule applied to `concat_where`-inline `{concat_node.data}` into `{nsdfg.label}`.",
stacklevel=1,
)
return True
else:
if __debug__:
warnings.warn(
f"Special rule applied to `concat_where`-inline `{concat_node.data}` into `{nsdfg.label}` was rejected.",
stacklevel=1,
)
warnings.warn(
f"Special rule applied to `concat_where`-inline `{concat_node.data}` into `{nsdfg.label}` was rejected.",
stacklevel=1,
)
return False


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@


#: Attribute defining package-level marks used by a custom pytest hook.
package_pytestmarks = [pytest.mark.usefixtures("common_dace_config")]
package_pytestmarks = [pytest.mark.requires_dace, pytest.mark.usefixtures("common_dace_config")]
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

from . import util

import dace


def _make_strides_propagation_level3_sdfg() -> dace.SDFG:
"""Generates the level 3 SDFG (nested-nested) SDFG for `test_strides_propagation()`."""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# GT4Py - GridTools Framework
#
# Copyright (c) 2014-2024, ETH Zurich
# All rights reserved.
#
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause

import pytest
import warnings

from gt4py.next import config as gtx_config


def test_if_warning_is_raised():
assert not gtx_config.SKIP_DACE_WARNINGS or not __debug__, "Tests do not run in debug mode."

warn_msg = "This is a warning."
with pytest.warns(UserWarning, match=warn_msg):
warnings.warn(warn_msg, UserWarning)
Loading