Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding and updating __init__ files for modules #14

Merged
merged 15 commits into from
Mar 11, 2024
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
2 changes: 1 addition & 1 deletion examples/mpi/global_timings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
from mpi4py import MPI

from ndsl.performance.timer import Timer
from ndsl import Timer


@contextlib.contextmanager
Expand Down
11 changes: 7 additions & 4 deletions examples/mpi/zarr_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import zarr
from mpi4py import MPI

from ndsl.comm.partitioner import CubedSpherePartitioner, TilePartitioner
from ndsl import (
CubedSpherePartitioner,
QuantityFactory,
SubtileGridSizer,
TilePartitioner,
ZarrMonitor,
)
from ndsl.constants import X_DIM, Y_DIM, Z_DIM
from ndsl.initialization.allocator import QuantityFactory
from ndsl.initialization.sizer import SubtileGridSizer
from ndsl.monitor import ZarrMonitor


OUTPUT_PATH = "output/zarr_monitor.zarr"
Expand Down
30 changes: 30 additions & 0 deletions ndsl/__init__.py
FlorianDeconinck marked this conversation as resolved.
Show resolved Hide resolved
FlorianDeconinck marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
from .checkpointer import SnapshotCheckpointer
from .comm import (
CachingCommReader,
CachingCommWriter,
ConcurrencyError,
CubedSphereCommunicator,
CubedSpherePartitioner,
LocalComm,
NullComm,
TileCommunicator,
TilePartitioner,
)
FlorianDeconinck marked this conversation as resolved.
Show resolved Hide resolved
from .dsl import (
CompareToNumpyStencil,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if we need this at the top level

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is advanced system but for now it's the only one, so I'd leave it here

FlorianDeconinck marked this conversation as resolved.
Show resolved Hide resolved
CompilationConfig,
DaceConfig,
DaCeOrchestration,
FrozenStencil,
GridIndexing,
RunMode,
StencilConfig,
StencilFactory,
)
from .exceptions import OutOfBoundsError
from .halo import HaloDataTransformer, HaloExchangeSpec, HaloUpdater
from .initialization import QuantityFactory, SubtileGridSizer
from .logging import ndsl_log
from .monitor import NetCDFMonitor, ZarrMonitor
from .performance import NullTimer, Timer
from .quantity import Quantity, QuantityHaloSpec
from .testing import DummyComm
9 changes: 0 additions & 9 deletions ndsl/checkpointer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
from .base import Checkpointer
from .null import NullCheckpointer
from .snapshots import SnapshotCheckpointer
from .thresholds import (
InsufficientTrialsError,
SavepointThresholds,
Threshold,
ThresholdCalibrationCheckpointer,
)
from .validation import ValidationCheckpointer
2 changes: 1 addition & 1 deletion ndsl/checkpointer/null.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .base import Checkpointer
from ndsl.checkpointer.base import Checkpointer


class NullCheckpointer(Checkpointer):
Expand Down
3 changes: 1 addition & 2 deletions ndsl/checkpointer/snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import numpy as np

from ndsl.checkpointer.base import Checkpointer
from ndsl.optional_imports import cupy as cp
from ndsl.optional_imports import xarray as xr

from .base import Checkpointer


def make_dims(savepoint_dim, label, data_list):
"""
Expand Down
4 changes: 2 additions & 2 deletions ndsl/checkpointer/thresholds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import numpy as np

from ..quantity import Quantity
from .base import Checkpointer
from ndsl.checkpointer.base import Checkpointer
from ndsl.quantity import Quantity


try:
Expand Down
10 changes: 7 additions & 3 deletions ndsl/checkpointer/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@

import numpy as np

from ndsl.checkpointer.base import Checkpointer
from ndsl.checkpointer.thresholds import (
ArrayLike,
SavepointName,
SavepointThresholds,
cast_to_ndarray,
)
from ndsl.optional_imports import xarray as xr

from .base import Checkpointer
from .thresholds import ArrayLike, SavepointName, SavepointThresholds, cast_to_ndarray


def _clip_pace_array_to_target(
array: np.ndarray, target_shape: Tuple[int, ...]
Expand Down
5 changes: 5 additions & 0 deletions ndsl/comm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .caching_comm import CachingCommReader, CachingCommWriter
from .communicator import CubedSphereCommunicator, TileCommunicator
from .local_comm import ConcurrencyError, LocalComm
from .null_comm import NullComm
from .partitioner import CubedSpherePartitioner, TilePartitioner
4 changes: 2 additions & 2 deletions ndsl/comm/boundary.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import dataclasses
from typing import Tuple

from ..quantity import Quantity, QuantityHaloSpec
from ._boundary_utils import get_boundary_slice
from ndsl.comm._boundary_utils import get_boundary_slice
from ndsl.quantity import Quantity, QuantityHaloSpec


@dataclasses.dataclass
Expand Down
12 changes: 3 additions & 9 deletions ndsl/dsl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@
from ndsl.comm.mpi import MPI

from . import dace
from .dace.dace_config import DaceConfig, DaCeOrchestration
from .dace.orchestration import orchestrate, orchestrate_function
from .stencil import (
CompilationConfig,
FrozenStencil,
GridIndexing,
StencilConfig,
StencilFactory,
)
from .dace import DaceConfig, DaCeOrchestration, orchestrate, orchestrate_function
from .stencil import CompareToNumpyStencil, FrozenStencil, GridIndexing, StencilFactory
from .stencil_config import CompilationConfig, RunMode, StencilConfig

FlorianDeconinck marked this conversation as resolved.
Show resolved Hide resolved

if MPI is not None:
Expand Down
Empty file added ndsl/dsl/caches/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions ndsl/dsl/dace/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from ndsl.dsl.dace.dace_config import DaceConfig
from ndsl.dsl.dace.orchestration import orchestrate
from .dace_config import DaceConfig, DaCeOrchestration
from .orchestration import orchestrate, orchestrate_function
2 changes: 1 addition & 1 deletion ndsl/dsl/stencil.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from ndsl.dsl.dace.orchestration import SDFGConvertible
from ndsl.dsl.stencil_config import CompilationConfig, RunMode, StencilConfig
from ndsl.dsl.typing import Float, Index3D, cast_to_index3d
from ndsl.initialization import GridSizer, SubtileGridSizer
from ndsl.initialization.sizer import GridSizer, SubtileGridSizer
from ndsl.quantity import Quantity


Expand Down
10 changes: 0 additions & 10 deletions ndsl/grid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# flake8: noqa: F401

from .eta import set_hybrid_pressure_coefficients
from .generation import GridDefinitions, MetricTerms
FlorianDeconinck marked this conversation as resolved.
Show resolved Hide resolved
from .gnomonic import (
great_circle_distance_along_axis,
great_circle_distance_lon_lat,
Expand All @@ -11,13 +10,4 @@
xyz_midpoint,
xyz_to_lon_lat,
)
from .helper import (
AngleGridData,
ContravariantGridData,
DampingCoefficients,
DriverGridData,
GridData,
HorizontalGridData,
VerticalGridData,
)
FlorianDeconinck marked this conversation as resolved.
Show resolved Hide resolved
from .stretch_transformation import direct_transform
25 changes: 12 additions & 13 deletions ndsl/grid/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,7 @@
from ndsl.dsl.stencil import GridIndexing
from ndsl.dsl.typing import Float
from ndsl.grid import eta
from ndsl.initialization.allocator import QuantityFactory
from ndsl.initialization.sizer import SubtileGridSizer
from ndsl.quantity import Quantity
from ndsl.stencils.corners import (
fill_corners_2d,
fill_corners_agrid,
fill_corners_cgrid,
fill_corners_dgrid,
)

from .geometry import (
from ndsl.grid.geometry import (
calc_unit_vector_south,
calc_unit_vector_west,
calculate_divg_del6,
Expand All @@ -47,7 +37,7 @@
supergrid_corner_fix,
unit_vector_lonlat,
)
from .gnomonic import (
from ndsl.grid.gnomonic import (
get_area,
great_circle_distance_along_axis,
local_gnomonic_ed,
Expand All @@ -59,7 +49,16 @@
set_tile_border_dxc,
set_tile_border_dyc,
)
from .mirror import mirror_grid
from ndsl.grid.mirror import mirror_grid
from ndsl.initialization.allocator import QuantityFactory
from ndsl.initialization.sizer import SubtileGridSizer
from ndsl.quantity import Quantity
from ndsl.stencils.corners import (
fill_corners_2d,
fill_corners_agrid,
fill_corners_cgrid,
fill_corners_dgrid,
)


# TODO: when every environment in python3.8, remove
Expand Down
5 changes: 2 additions & 3 deletions ndsl/grid/geometry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from ndsl.comm.partitioner import TilePartitioner
from ndsl.quantity import Quantity

from .gnomonic import (
from ndsl.grid.gnomonic import (
get_lonlat_vect,
get_unit_vector_direction,
great_circle_distance_lon_lat,
Expand All @@ -10,6 +8,7 @@
spherical_cos,
xyz_midpoint,
)
from ndsl.quantity import Quantity


def get_center_vector(
Expand Down
7 changes: 3 additions & 4 deletions ndsl/grid/global_setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import math

from ndsl.constants import PI, RADIUS

from .generation import MetricTerms
from .gnomonic import (
from ndsl.grid.generation import MetricTerms
from ndsl.grid.gnomonic import (
_cart_to_latlon,
_check_shapes,
_latlon2xyz,
_mirror_latlon,
symm_ed,
)
from .mirror import _rot_3d
from ndsl.grid.mirror import _rot_3d


def gnomonic_grid(grid_type: int, lon, lat, np):
Expand Down
3 changes: 1 addition & 2 deletions ndsl/grid/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
import ndsl.constants as constants
from ndsl.constants import Z_DIM, Z_INTERFACE_DIM
from ndsl.filesystem import get_fs
from ndsl.grid.generation import MetricTerms
from ndsl.initialization import QuantityFactory
from ndsl.quantity import Quantity

from .generation import MetricTerms


@dataclasses.dataclass(frozen=True)
class DampingCoefficients:
Expand Down
2 changes: 2 additions & 0 deletions ndsl/halo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .data_transformer import HaloDataTransformer, HaloExchangeSpec
from .updater import HaloUpdater
2 changes: 1 addition & 1 deletion ndsl/initialization/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .allocator import QuantityFactory
from .sizer import GridSizer, SubtileGridSizer
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be worth it to keep GridSizer here but not a big deal

from .sizer import SubtileGridSizer
8 changes: 4 additions & 4 deletions ndsl/initialization/allocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import numpy as np

from ..constants import SPATIAL_DIMS
from ..optional_imports import gt4py
from ..quantity import Quantity, QuantityHaloSpec
from .sizer import GridSizer
from ndsl.constants import SPATIAL_DIMS
from ndsl.initialization.sizer import GridSizer
from ndsl.optional_imports import gt4py
from ndsl.quantity import Quantity, QuantityHaloSpec


class StorageNumpy:
Expand Down
1 change: 0 additions & 1 deletion ndsl/monitor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from .netcdf_monitor import NetCDFMonitor
from .protocol import Monitor
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we do want to keep this here for typing purposes

Copy link
Collaborator

Choose a reason for hiding this comment

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

Poke

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should these no longer be exposed at the ndsl level?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Monitor shouldn't I think. NetCDFMonitor should that's the more concrete one. Monitor is a base class

Copy link
Collaborator

Choose a reason for hiding this comment

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

Some day ZarrMonitor should be as well, once zarr is more prevalent (fingers crossed)

from .zarr_monitor import ZarrMonitor
2 changes: 1 addition & 1 deletion ndsl/monitor/convert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from ..optional_imports import cupy
from ndsl.optional_imports import cupy


def to_numpy(array, dtype=None) -> np.ndarray:
Expand Down
9 changes: 4 additions & 5 deletions ndsl/monitor/netcdf_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
import numpy as np

from ndsl.comm.communicator import Communicator
from ndsl.filesystem import get_fs
from ndsl.logging import ndsl_log
from ndsl.monitor.convert import to_numpy
from ndsl.optional_imports import xarray as xr

from ..filesystem import get_fs
from ..logging import ndsl_log
from ..quantity import Quantity
from .convert import to_numpy
from ndsl.quantity import Quantity


class _TimeChunkedVariable:
Expand Down
1 change: 0 additions & 1 deletion ndsl/performance/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from .config import PerformanceConfig
from .timer import NullTimer, Timer
3 changes: 1 addition & 2 deletions ndsl/performance/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ndsl.performance.report import (
Report,
TimeReport,
collect_data_and_write_to_file,
collect_keys_from_data,
gather_hit_counts,
get_experiment_info,
Expand All @@ -19,8 +20,6 @@
from ndsl.performance.timer import NullTimer, Timer
from ndsl.utils import GPU_AVAILABLE

from .report import collect_data_and_write_to_file


class AbstractPerformanceCollector(Protocol):
total_timer: Timer
Expand Down
5 changes: 2 additions & 3 deletions ndsl/performance/config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import dataclasses

from ndsl.comm.comm_abc import Comm
from ndsl.performance.profiler import NullProfiler, Profiler

from .collector import (
from ndsl.performance.collector import (
AbstractPerformanceCollector,
NullPerformanceCollector,
PerformanceCollector,
)
from ndsl.performance.profiler import NullProfiler, Profiler


@dataclasses.dataclass
Expand Down
2 changes: 1 addition & 1 deletion ndsl/stencils/c2l_ord.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ndsl.dsl.dace.wrapped_halo_exchange import WrappedHaloUpdater
from ndsl.dsl.stencil import StencilFactory
from ndsl.dsl.typing import Float, FloatField, FloatFieldIJ
from ndsl.grid import GridData
from ndsl.grid.helper import GridData
from ndsl.initialization.allocator import QuantityFactory


Expand Down
Loading
Loading