refactor: imports cleanup#264
Merged
FlorianDeconinck merged 4 commits intoOct 14, 2025
Merged
Conversation
This PR suggests three things related to cleaning up imports of NDSL. 1. split grid_sizer and subtile_grid_sizer 2. import MPI directly from mpi4py 3. cleanup direct gt4py imports in tests The reason to do 1) is that `GridSizer` is used in the `QuantityFactory` as well as in `SubtileGridSizer`. Both classes live in the same folder and are exported as public API through the `__init__` file. To avoid a circular dependency, I've split out `GridSizer` in its own module that can be loaded upfront. The reason we previsosly imported `MPI` from `ndsl.comm.mpi` was that at some point `mpi4py` was an optional dependency and `ndsl.comm.mpi` would export a stub if `mpi4py` wasn't present. Now that `mpi4py` is a required dependency, we can just get `MPI` from there. The reason for 3) is also historical. By now, we make sure to `import . from dsl` in the top-level `__init__` at the very top. This ensures that we can properly set the literal precision for gt4py in `ndsl/dsl/__init__.py`.
Collaborator
Author
|
Changed the |
FlorianDeconinck
approved these changes
Oct 14, 2025
Co-authored-by: Florian Deconinck <deconinck.florian@gmail.com>
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR suggests two things related to cleaning up the imports of NDSL.
GridSizerandSubtileGridSizergt4pyimports in testsThe reason to do 1) is that
GridSizeris used in theQuantityFactoryas well as inSubtileGridSizer. Both classes live in the same folder and are exported as public API through the__init__file. To avoid a circular dependency, I've split outGridSizerin its own module that can be loaded upfront.The reason for 2) is also historical. By now, we make sure to
import . from dslin the top-level__init__at the very top. This ensures that we can properly set the literal precision for gt4py inndsl/dsl/__init__.py.Alongside, I've ensured no direct imports from
mpi4py. I've learned thatndsl.comm.mpishould be the only place to import frommpi4pydirectly, leaving us the option to easily swap the library in the future (if we then wish to do so).This PR is motivated by me trying to rebase the stale TracerBundle PR without getting import cycles and having to resolve them by moving random things up and down in
__init__files.How has this been tested?
All good as long as tests are still green.
Checklist