Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
branch = develop
[submodule "pyFV3"]
path = pyFV3
url = https://github.com/NOAA-GFDL/PyFV3.git
url = https://github.com/NOAA-GFDL/pyFV3.git
branch = develop
[submodule "pySHiELD"]
path = pySHiELD
url = https://github.com/NOAA-GFDL/PySHiELD.git
url = https://github.com/NOAA-GFDL/pySHiELD.git
branch = develop
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:

repos:
- repo: https://github.com/psf/black
rev: 25.1.0
rev: 25.9.0
hooks:
- id: black

Expand All @@ -14,16 +14,16 @@ repos:
args: ["--profile", "black"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.17.0
rev: v1.18.2
hooks:
- id: mypy
additional_dependencies: [types-pyyaml]
additional_dependencies: [types-PyYAML]
name: mypy-pace
files: pace
args: ["--config-file", "pyproject.toml"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-toml
- id: check-yaml
Expand All @@ -36,7 +36,7 @@ repos:
- id: flake8
name: flake8
language_version: python3
additional_dependencies: [Flake8-pyproject]
additional_dependencies: [Flake8-pyproject, flake8-bugbear]

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.15.0
Expand Down
2 changes: 1 addition & 1 deletion NDSL
Submodule NDSL updated 85 files
+6 −3 .github/workflows/unit_tests.yaml
+5 −3 examples/mpi/zarr_monitor.py
+1 −1 external/gt4py
+6 −1 mkdocs.yml
+46 −19 ndsl/comm/_boundary_utils.py
+11 −7 ndsl/comm/boundary.py
+11 −11 ndsl/comm/decomposition.py
+5 −5 ndsl/comm/partitioner.py
+15 −13 ndsl/constants.py
+4 −5 ndsl/dsl/dace/dace_config.py
+2 −2 ndsl/dsl/dace/labeler.py
+1 −1 ndsl/dsl/dace/stree/optimizations/axis_merge.py
+1 −1 ndsl/dsl/dace/stree/optimizations/clean_tree.py
+1 −1 ndsl/dsl/dace/stree/optimizations/memlet_helpers.py
+1 −1 ndsl/dsl/dace/stree/optimizations/refine_transients.py
+1 −1 ndsl/dsl/dace/stree/optimizations/tree_common_op.py
+2 −2 ndsl/dsl/gt4py_utils.py
+49 −59 ndsl/dsl/stencil.py
+200 −200 ndsl/grid/generation.py
+2 −1 ndsl/grid/global_setup.py
+6 −6 ndsl/grid/helper.py
+6 −7 ndsl/grid/stretch_transformation.py
+40 −24 ndsl/halo/data_transformer.py
+2 −2 ndsl/halo/rotate.py
+24 −21 ndsl/halo/updater.py
+1 −2 ndsl/initialization/allocator.py
+21 −29 ndsl/initialization/subtile_grid_sizer.py
+29 −28 ndsl/performance/timer.py
+52 −34 ndsl/quantity/bounds.py
+2 −2 ndsl/quantity/metadata.py
+16 −17 ndsl/quantity/quantity.py
+2 −2 ndsl/quantity/state.py
+1 −1 ndsl/restart/_legacy_restart.py
+94 −94 ndsl/restart/_properties.py
+1 −44 ndsl/stencils/basic_operations.py
+4 −4 ndsl/stencils/c2l_ord.py
+43 −24 ndsl/stencils/corners.py
+5 −5 ndsl/stencils/testing/grid.py
+3 −3 ndsl/stencils/testing/parallel_translate.py
+2 −0 ndsl/stencils/testing/test_translate.py
+30 −27 ndsl/stencils/tridiag.py
+5 −5 ndsl/types.py
+2 −2 ndsl/utils.py
+8 −8 ndsl/viz/fv3/__init__.py
+4 −4 ndsl/viz/fv3/_constants.py
+9 −9 ndsl/viz/fv3/_plot_cube.py
+2 −2 ndsl/viz/fv3/_plot_diagnostics.py
+8 −8 ndsl/viz/fv3/grid_metadata.py
+2 −8 pyproject.toml
+11 −11 tests/dsl/orchestration/test_call.py
+3 −3 tests/dsl/test_skip_passes.py
+19 −11 tests/dsl/test_stencil.py
+2 −2 tests/dsl/test_stencil_factory.py
+42 −42 tests/mpi/test_mpi_halo_update.py
+16 −16 tests/quantity/test_boundary.py
+4 −4 tests/quantity/test_fieldbundle.py
+52 −7 tests/quantity/test_local.py
+6 −1 tests/quantity/test_quantity.py
+8 −8 tests/quantity/test_state.py
+25 −25 tests/quantity/test_transpose.py
+68 −68 tests/quantity/test_view.py
+16 −17 tests/stencils/test_stencils.py
+10 −10 tests/stree_optimizer/test_merge.py
+4 −4 tests/stree_optimizer/test_pipeline.py
+11 −11 tests/stree_optimizer/test_transient_refine.py
+6 −6 tests/test_4d_fields.py
+8 −23 tests/test_basic_operations.py
+5 −5 tests/test_boilerplate.py
+2 −2 tests/test_caching_comm.py
+18 −18 tests/test_cube_scatter_gather.py
+22 −21 tests/test_dimension_sizer.py
+5 −5 tests/test_g2g_communication.py
+36 −36 tests/test_halo_data_transformer.py
+50 −50 tests/test_halo_update.py
+25 −25 tests/test_halo_update_ranks.py
+18 −18 tests/test_legacy_restart.py
+7 −7 tests/test_ndsl_runtime.py
+4 −3 tests/test_netcdf_monitor.py
+97 −97 tests/test_partitioner.py
+20 −20 tests/test_rotate.py
+5 −5 tests/test_sync_shared_boundary.py
+9 −9 tests/test_tile_scatter.py
+25 −25 tests/test_tile_scatter_gather.py
+44 −40 tests/test_timer.py
+39 −37 tests/test_zarr_monitor.py
4 changes: 3 additions & 1 deletion pace/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ def _get_derived_state(self, state: DriverState):
state.dycore_state.delp,
)
else:
warnings.warn(f"{name} is not a supported diagnostic variable.")
warnings.warn(
f"{name} is not a supported diagnostic variable.", stacklevel=2
)
return output

def _get_z_select_state(self, state: DycoreState):
Expand Down
7 changes: 4 additions & 3 deletions pace/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def n_timesteps(self) -> int:
if self.total_time < self.timestep:
warnings.warn(
f"No simulation possible: you asked for {self.total_time} "
f"simulation time but the timestep is {self.timestep}"
f"simulation time but the timestep is {self.timestep}",
stacklevel=2,
)
return floor(self.total_time.total_seconds() / self.timestep.total_seconds())

Expand Down Expand Up @@ -442,7 +443,7 @@ def exit_function(*args, **kwargs):
)
exit(0)

setattr(self, "step_all", exit_function)
self.step_all = exit_function # type: ignore[method-assign]
elif self.config.stencil_config.compilation_config.run_mode == RunMode.Run:

def exit_instead_of_build(self):
Expand All @@ -457,7 +458,7 @@ def exit_instead_of_build(self):

from gt4py.stencil_builder import StencilBuilder

setattr(StencilBuilder, "build", exit_instead_of_build)
StencilBuilder.build = exit_instead_of_build # type: ignore["method-assign"]

self.config.stencil_config.dace_config = DaceConfig(
communicator=communicator,
Expand Down
4 changes: 3 additions & 1 deletion pace/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def get_driver_state(
)

@classmethod
def from_dict(cls, config: dict, hooks={}):
def from_dict(cls, config: dict, hooks=None):
if not hooks:
hooks = {}
instance = cls.registry.from_dict(config, hooks=hooks)
return cls(config=instance, type=config["type"])

Expand Down
4 changes: 3 additions & 1 deletion pace/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def register_func(cls: TT) -> TT:

return register_func

def from_dict(self, config: dict, hooks={}) -> T:
def from_dict(self, config: dict, hooks=None) -> T:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't have a strong opinion blocking this, but should we add type hints? In this example, "config" has a type hint, but "hooks" doesn't have it. Also, the return type is the generic "T". However, the from_dict in pace/initialization.py has a from_dict that doesn't specify a return type hint. If we add a hook type hint, I think it might be dict[type, Callable[[Any], Any]] based on https://github.com/konradhalas/dacite/blob/master/dacite/config.py.

"""
Creates a registered type from the given config dict.

Expand All @@ -116,6 +116,8 @@ def from_dict(self, config: dict, hooks={}) -> T:
It can also have a "config" key, which is a dict used to initialize the
dataclass. By default this is an empty dict.
"""
if not hooks:
hooks = {}
config.setdefault("config", {})
if self.default_type is not None:
type_name = config.get("type", self.default_type)
Expand Down
2 changes: 1 addition & 1 deletion pyFV3
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ warn_unreachable = true
ignore_errors = true
module = [
# We currently can't type stencils
"pyshield.stencils.*",
# Will be fixed with NDSL version 2026.01.00, see
# https://github.com/NOAA-GFDL/NDSL/pull/360
"pyfv3.testing.translate_fvdynamics"
"pyfv3.stencils.*",
"pyshield.stencils.*"
]

[tool.setuptools]
Expand Down
2 changes: 1 addition & 1 deletion tests/main/fv3core/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def value(self) -> int:
def assert_types_match(classes):
types = collections.defaultdict(set)
for cls in classes:
for name, field in cls.__dataclass_fields__.items():
for name, _field in cls.__dataclass_fields__.items():
# Get type hints in case we're using postponed evaluation of types
# Example: '<class 'bool'> instead of 'bool'
types[name].add(typing.get_type_hints(cls)[name])
Expand Down