diff --git a/ndsl/dsl/stencil_config.py b/ndsl/dsl/stencil_config.py index 4d3eafab..0ca0da18 100644 --- a/ndsl/dsl/stencil_config.py +++ b/ndsl/dsl/stencil_config.py @@ -168,26 +168,35 @@ def from_dict(cls, data: dict): class StencilConfig(Hashable): compare_to_numpy: bool = False compilation_config: CompilationConfig = CompilationConfig() - dace_config: Optional[DaceConfig] = None verbose: bool = False + dace_config: DaceConfig = dataclasses.field(init=False) - def __post_init__(self): + def __init__( + self, + *, + compare_to_numpy: bool = False, + compilation_config: CompilationConfig = CompilationConfig(), + verbose: bool = False, + dace_config: DaceConfig | None = None, + ): + self.compare_to_numpy = compare_to_numpy + self.compilation_config = compilation_config + self.verbose = verbose + self.dace_config = ( + dace_config + if dace_config is not None + else DaceConfig( + communicator=None, + backend=self.compilation_config.backend, + orchestration=DaCeOrchestration.Python, + ) + ) self.backend_opts = { "device_sync": self.compilation_config.device_sync, "format_source": self.compilation_config.format_source, } self._hash = self._compute_hash() - # We need a DaceConfig to know if orchestration is part of the build system - # but we can't hash it very well (for now). The workaround is to make - # sure we have a default Python orchestrated config. - if self.dace_config is None: - self.dace_config = DaceConfig( - communicator=None, - backend=self.compilation_config.backend, - orchestration=DaCeOrchestration.Python, - ) - @property def backend(self): return self.compilation_config.backend diff --git a/ndsl/stencils/corners.py b/ndsl/stencils/corners.py index 4c13b021..d4d48a0d 100644 --- a/ndsl/stencils/corners.py +++ b/ndsl/stencils/corners.py @@ -1,8 +1,10 @@ +import warnings from typing import Optional, Sequence, Tuple from gt4py.cartesian import gtscript from gt4py.cartesian.gtscript import PARALLEL, computation, horizontal, interval, region +from ndsl import StencilFactory from ndsl.constants import ( X_DIM, X_INTERFACE_DIM, @@ -10,7 +12,7 @@ Y_INTERFACE_DIM, Z_INTERFACE_DIM, ) -from ndsl.dsl.stencil import GridIndexing, StencilFactory +from ndsl.dsl.stencil import GridIndexing from ndsl.dsl.typing import FloatField @@ -22,6 +24,13 @@ class CopyCorners: def __init__(self, direction: str, stencil_factory: StencilFactory) -> None: """The grid for this stencil""" + warnings.warn( + "Usage of the GT4Py implementation of CopyCorners is discouraged and will" + "be removed in the next release. Use `CopyCornersX` or `CopyCornersY` in PyFV3" + "for a more future-proof implementation of the same code.", + DeprecationWarning, + 2, + ) grid_indexing = stencil_factory.grid_indexing n_halo = grid_indexing.n_halo diff --git a/ndsl/types.py b/ndsl/types.py index e3461c39..2251789b 100644 --- a/ndsl/types.py +++ b/ndsl/types.py @@ -14,7 +14,6 @@ def __call__(self, shape: Iterable[int], dtype: type): class NumpyModule(Protocol): - empty: Allocator zeros: Allocator ones: Allocator