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

Conversation

fmalatino
Copy link
Contributor

@fmalatino fmalatino commented Feb 14, 2024

Description
Adding init files to standardize import method of modules

How Has This Been Tested?
Tested via lint and currently implemented translate tests
OS: RHEL 8.9 Ootpa
Built conda environment using workflow in github action configurations

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included

Copy link
Collaborator

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

Missing initialization imports (QuantityFactory is a big one)

ndsl/__init__.py Show resolved Hide resolved
@fmalatino fmalatino marked this pull request as draft February 15, 2024 20:46
@FlorianDeconinck
Copy link
Collaborator

Please merge in develop instead of main

@fmalatino fmalatino changed the base branch from main to develop February 16, 2024 17:28
Copy link
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

I'd like to see typing exposed at a higher level, and a couple of questions about the layout otherwise.

ndsl/comm/__init__.py Outdated Show resolved Hide resolved
ndsl/comm/__init__.py Outdated Show resolved Hide resolved
ndsl/dsl/dace/__init__.py Outdated Show resolved Hide resolved
ndsl/dsl/__init__.py Outdated Show resolved Hide resolved
ndsl/__init__.py Show resolved Hide resolved
Copy link
Collaborator

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

Good job so far.

I am still debating internally if I dont' want to see two tier of exposure. One first tier of features we almost always need e.g. (Comm, Orchestration, Halo, etc.) and a second tier of more uncommon feature e.g. (CompareToNumpyStencil, Snapshot, ZarrMonitor, etc.)

ndsl/dsl/dace/__init__.py Outdated Show resolved Hide resolved
tests/dsl/__init__.py Outdated Show resolved Hide resolved
@fmalatino fmalatino marked this pull request as ready for review February 27, 2024 18:15
@fmalatino fmalatino marked this pull request as draft February 27, 2024 19:05
@fmalatino fmalatino marked this pull request as ready for review February 27, 2024 20:52
Copy link
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

My main request is that I don't love taking so much out of the init files, and would prefer we kept more in them. If that causes problems with circular imports I'd rather we prioritize the NDSL interface over removing relative imports internally, though I believe there should be other workarounds

ndsl/__init__.py Outdated Show resolved Hide resolved
ndsl/checkpointer/__init__.py Outdated Show resolved Hide resolved
ndsl/__init__.py Outdated
TilePartitioner,
)
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

ndsl/dsl/__init__.py Outdated Show resolved Hide resolved
ndsl/grid/__init__.py Show resolved Hide resolved
@@ -1,2 +1,2 @@
from .config import PerformanceConfig
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would also leave this in as well

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.

Just leave in PerformanceConfig or/and NullTimer, Timer?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd say the tree are useful here either for us or typing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Left all three in.

ndsl/stencils/__init__.py Show resolved Hide resolved
tests/dsl/__init__.py Outdated Show resolved Hide resolved
tests/quantity/__init__.py Outdated Show resolved Hide resolved
ndsl/__init__.py Show resolved Hide resolved
Copy link
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

Getting there! I think there's more that can be moved down the chain, but my main quibble is with defining abstract base classes in ndsl.typing instead of keeping them where they were and importing them into ndsl.typing for exposure

ndsl/checkpointer/base.py Outdated Show resolved Hide resolved
ndsl/__init__.py Outdated Show resolved Hide resolved
ndsl/__init__.py Outdated Show resolved Hide resolved
ndsl/__init__.py Outdated Show resolved Hide resolved
ndsl/__init__.py Outdated Show resolved Hide resolved
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 the idea here is not so much that typing would define a Communicator or Checkpointer base class but that they would be imported into typing so that they would be exposed here when you import ndsl.typing

ndsl/comm/communicator.py Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

the Partitioner abc should still live here IMO

xyz_to_lon_lat,
)
from .eta import HybridPressureCoefficients
from .generation import GridDefinition, GridDefinitions, MetricTerms
Copy link
Collaborator

Choose a reason for hiding this comment

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

GridDefinition doesn't need to be exposed IMO

Comment on lines 3 to 18
from .testing.grid import Grid # type: ignore
from .testing.parallel_translate import (
ParallelTranslate,
ParallelTranslate2Py,
ParallelTranslate2PyState,
ParallelTranslateBaseSlicing,
ParallelTranslateGrid,
)
from .testing.savepoint import SavepointCase, Translate, dataset_to_dict
from .testing.temporaries import assert_same_temporaries, copy_temporaries
from .testing.translate import (
TranslateFortranData2Py,
TranslateGrid,
pad_field_in_j,
read_serialized_data,
)
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 the testing stuff could still be in stencils.testing but that's not a big deal either way

Copy link
Collaborator

Choose a reason for hiding this comment

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

Move down to testing it's specific enough

@FlorianDeconinck
Copy link
Collaborator

Getting there! I think there's more that can be moved down the chain, but my main quibble is with defining abstract base classes in ndsl.typing instead of keeping them where they were and importing them into ndsl.typing for exposure

Yes ndsl.typing should be a stub, code should remain in the original places.

E.g.

typing.py

from ndsl.comm import Communicator

any calling code can then do

from ndsl.typing import Communicator

It is more correct and also would allow us to swap implementation below without touching the exposure

@fmalatino fmalatino requested a review from oelbert March 6, 2024 20:29
Copy link
Collaborator

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

We are getting there. This raises a ton of good question on the architecture of this monster. Very necessary work

from .null import NullCheckpointer
from .snapshots import SnapshotCheckpointer
from .snapshots import SnapshotCheckpointer, _Snapshots
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need _Snapshots? We should always try to have _X class or functions hidden, as this what the prefixed _ is suppose to hint at

ndsl/comm/__init__.py Outdated Show resolved Hide resolved
ndsl/comm/communicator.py Outdated Show resolved Hide resolved
ndsl/dsl/stencil.py Outdated Show resolved Hide resolved
setup.py Show resolved Hide resolved
tests/dsl/test_stencil_config.py Show resolved Hide resolved
tests/dsl/test_stencil_wrapper.py Show resolved Hide resolved
tests/dsl/__init__.py Outdated Show resolved Hide resolved
tests/checkpointer/__init__.py Outdated Show resolved Hide resolved
tests/quantity/__init__.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

A few notes to addressed that I poked

ndsl/__init__.py Outdated
Comment on lines 60 to 61
from .types import Allocator, AsyncRequest, NumpyModule
from .units import UnitsError
Copy link
Collaborator

Choose a reason for hiding this comment

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

Poke

@@ -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.

Poke

@@ -1,2 +1,2 @@
from .config import PerformanceConfig
Copy link
Collaborator

Choose a reason for hiding this comment

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

Poke

setup.py Show resolved Hide resolved
Copy link
Collaborator

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

1 minor requests that isn't blocking. Nice job

@@ -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.

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

ndsl/typing.py Outdated
Comment on lines 4 to 9
from ndsl.comm.local_comm import AsyncResult, ConcurrencyError
from ndsl.comm.null_comm import NullAsyncResult
from ndsl.comm.partitioner import Partitioner
from ndsl.performance.collector import AbstractPerformanceCollector
from ndsl.types import AsyncRequest, NumpyModule
from ndsl.units import UnitsError
Copy link
Collaborator

Choose a reason for hiding this comment

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

UnitsError and ConcurrencyError don't really belong there, but we could import them into ndsl.exceptions.py

I don't believe AsyncResult and NullAsyncResult belong here either, to be honest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove and push again

Copy link
Collaborator

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

Good job.

Copy link
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@FlorianDeconinck FlorianDeconinck merged commit 52b26a2 into develop Mar 11, 2024
3 checks passed
@FlorianDeconinck FlorianDeconinck deleted the feature/init_standard branch March 11, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants