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

Updating submodules and pace refactor #75

Merged
merged 26 commits into from
Apr 18, 2024
Merged

Conversation

fmalatino
Copy link
Contributor

@fmalatino fmalatino commented Mar 21, 2024

Description
This PR updates the NDSL, pyFV3, and pySHiELD submodules to most recent commits, reflecting the standardized import methods.

How Has This Been Tested?
Tested using the currently implemented unit tests in tests/main

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

@fmalatino fmalatino marked this pull request as ready for review March 25, 2024 15:27
Copy link
Contributor

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

Two quick questions on the driver init and relative imports, just because it looks a little awkward but nothing blocking

Comment on lines 14 to 16
MonitorDiagnostics,
NullDiagnostics,
ZSelect,
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the logic behind adding these here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just copying what was done in NDSL, with exposing without rationale, and then un-exposing when it is deemed unnecessary.

@@ -6,8 +6,7 @@
import yaml

from ndsl.logging import AVAILABLE_LOG_LEVELS, ndsl_log

from .driver import Driver, DriverConfig
from pace.driver.driver import Driver, DriverConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am following the style that was set forth in how I handled imports in the submodules. When I am within a package and I am referencing something internal to the package, the absolute path is used, when outside the package the relative path is used.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that makes sense, it just looks funny here

@fmalatino fmalatino requested a review from oelbert April 2, 2024 13:50
Copy link
Contributor

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

👍

Copy link
Contributor

@bensonr bensonr left a comment

Choose a reason for hiding this comment

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

As I look at the driver/pace/driver code I have a question about what we are building with Pace. If Pace is designed to be the model and we will be adding other components (land, ice, ocean, waves, etc.) within, I'm not sure it makes senes to treat the driver as a submodule. However, if we envision Pace being say the atmospheric component within a larger module, it does make sense to leave the submodule treatment in place.

@fmalatino
Copy link
Contributor Author

As I look at the driver/pace/driver code I have a question about what we are building with Pace. If Pace is designed to be the model and we will be adding other components (land, ice, ocean, waves, etc.) within, I'm not sure it makes senes to treat the driver as a submodule. However, if we envision Pace being say the atmospheric component within a larger module, it does make sense to leave the submodule treatment in place.

@oelbert ?

@oelbert
Copy link
Contributor

oelbert commented Apr 9, 2024

My understanding has been that Pace is solely an atmospheric model and any ocean or land model would be separate

@lharris4
Copy link

lharris4 commented Apr 9, 2024 via email

Copy link
Contributor

@bensonr bensonr 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 using srun in the .jenkins code. Should we use a macro that can be either srun or mpirun as we shouldn't always assume a slurm environment?

Is all of the documentation that is NDSL, pyFV3, or pySHiELD specific also duplicated in those repos? Or better yet, it should live in those repos and become available via the submodule includes.

The driver/pace structure still seems redundant to me. Perhaps it is my lack of Python semantics, but we are in the Pace repo and have a driver/. Why do I need to yet again remind you this is pace by having driver/pace/? Is it better to have pace/ or pace/driver so that all references are pace.X or pace.driver.X?

@@ -142,8 +142,8 @@ test_mpi_54rank:
mpirun -n 54 $(MPIRUN_ARGS) python3 -m mpi4py -m pytest tests/mpi_54rank
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we always be using mpirun here or is there a chance it could be another invoker?

Copy link
Contributor

Choose a reason for hiding this comment

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

A change here would be prompted by a change in the docker image


This package provides command-line routines to run the Pace model, and utilities to write model driver scripts.

We suggest reading the code in the examples directory, or taking a look at `pace/driver/run.py` to see how the main entrypoint for this package works.
We suggest reading the code in the examples directory, or taking a look at `driver/pace/driver/run.py` to see how the main entrypoint for this package works.
Copy link
Contributor

Choose a reason for hiding this comment

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

Did the structure change to driver/pace/run.py or is it still driver/pace/driver/run.py?

@oelbert
Copy link
Contributor

oelbert commented Apr 16, 2024

The driver/pace structure still seems redundant to me. Perhaps it is my lack of Python semantics, but we are in the Pace repo and have a driver/. Why do I need to yet again remind you this is pace by having driver/pace/? Is it better to have pace/ or pace/driver so that all references are pace.X or pace.driver.X?

pace/driver/pace/driver/* structure is definitely a relic of Pace's development history, and we want to resolve that. Do you think we should do it here or in a separate PR?

@bensonr
Copy link
Contributor

bensonr commented Apr 16, 2024

In response to this comment, this PR is already renaming things from driver/pace/driver. Instead of doing it yet again, I was hoping we could get the structure set in one step. As always, I want the approach with the least chance of breaking things.

@fmalatino
Copy link
Contributor Author

In response to this comment, this PR is already renaming things from driver/pace/driver. Instead of doing it yet again, I was hoping we could get the structure set in one step. As always, I want the approach with the least chance of breaking things.

Currently the method of setting up the pace package differs from its submodules in that it uses a requirements file for specifying the requirements for the pip install of the package, as opposed to passing them through a setup.py or other build backend method. Within the requirements file we specify a need for an editable install of the submodules and pace, which will search for a setup.py file in each of the directories specified. Each of the setup.py files look for a namespace package matching the specified name(s) in the call to the find_namespace_packages. These namespace packages must be contained within a directory alongside the setup.py file.
Proposed in PR:

driver/
├── pace/      
│   ├── __init__.py      
│   └── driver.py
│   └── other.py            
└── setup.py

Current:

driver/
├── pace/ 
│     ├── driver/      
│          ├── __init__.py      
│          └── driver.py
│          └── other.py            
└── setup.py

I chose driver to serve as the outer directory to contain the pace package and the setup.py with the intention that once installed the user would then use the package like:

import pace

driver = pace.Driver(...)

As opposed to what existed previously:

import pace.driver

driver = pace.driver.Driver(...)

We can change the use of setup.py to include all of the desired requirements and make calls to install the submodules as well, which will then treat the cloned repo as the outer directory containing the pace package alongside its setup.py:

cloned_pace/
├── pace/      
│   ├── __init__.py      
│   └── driver.py
│   └── other.py            
└── setup.py
└── other_mods/

This will however not use the requirements file method, and will require some minor changes elsewhere, like in the github workflows, etc. I have tested both of these methods and went with the former as it keeps prevents a need to change the other files. If the latter is preferred the changes can be easily made. Also, I am not attached to the name driver for the outer directory, only using it as it made it easy to implement.

@fmalatino fmalatino requested a review from bensonr April 17, 2024 14:07
@fmalatino
Copy link
Contributor Author

@bensonr and @oelbert

I have made changes to the requirements_dev.txt file which should allow for pace to be installed without an outer directory (aside from it being contained in the cloned repo).

Copy link
Contributor

@bensonr bensonr left a comment

Choose a reason for hiding this comment

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

Thanks for taking my suggestions regarding structure. You've done a great job making it work. There are two minor nits that could be saved for a future issue/PR.

pace/README.md Outdated

This package provides command-line routines to run the Pace model, and utilities to write model driver scripts.

We suggest reading the code in the examples directory, or taking a look at `pace/driver/run.py` to see how the main entrypoint for this package works.
We suggest reading the code in the examples directory, or taking a look at `driver/pace/driver/run.py` to see how the main entrypoint for this package works.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be pace/run.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Amended in 15fc295

setup_requires=setup_requirements,
tests_require=test_requirements,
name="pace-driver",
name="pace",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to update more of this info here in the setup block here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this may be a good issue as I am not sure what would be appropriate to retain relating to the AI2 work.

Copy link
Contributor

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

Phew, that's a lot of changes!

@fmalatino fmalatino changed the title Updating submodules and import methods Updating submodules and pace refactor Apr 18, 2024
@fmalatino fmalatino merged commit 7e435fa into develop Apr 18, 2024
4 checks passed
@@ -0,0 +1,31 @@
name: "Main unit tests"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this workflow file needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are the tests contained within that directory also tested in CI? If so, it can be removed.

@fmalatino fmalatino deleted the refactor/submodule_updates branch June 25, 2024 16:35
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.

5 participants