-
Notifications
You must be signed in to change notification settings - Fork 0
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
Initial implementation #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xylar @chengzhuzhang I have more work to do, but I think I have the main idea of the refactor captured in this pull request and the corresponding E3SM-Project/zppy#642.
I should stress I haven't run this code yet. I still need to get the environments sorted out to be able to call zppy-interfaces
from zppy
. That is, while I think the main idea is captured here, there is still polishing/testing work left. However, I wanted to tag you here to allow for any further design input early on.
Specifically, my remaining action items:
- Create a
conda
directory and setup the yaml/toml files necessary to produce a dev environment. - Use
zppy
to generate stand-alonets
andmpas_analysis
output. - Run
global-time-series
interface in the dev environment on that output. - Run the
global_time_series
task in zppy (i.e., make surezppy
can correctly callzppy-interfaces
). - Create a
tests/
directory and add some integration tests.zppy
should simply test that it can invokezppy-interfaces global-time-series
.zppy-interfaces
however should test that Global Time Series plots actually generate correctly. As for unit tests, Create global time series Viewers zppy#616 will do that once it's ported to this repo. - Add pre-commit checks
- Add documentation for this repo/package.
zppy-interfaces/__main__.py
Outdated
if args.interface == "global_time_series": | ||
global_time_series.global_time_series() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm following zstash
's design here: have one arg parser for the package as a whole (e.g., https://github.com/E3SM-Project/zstash/blob/main/zstash/main.py#L34) and one each for the individual utilities [commands in zstash
or interfaces
in this package] (e.g., https://github.com/E3SM-Project/zstash/blob/main/zstash/create.py#L103)
The result is that calling the global time series code would be done via:
zppy-interfaces global-time-series <args>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@forsyth2, this seems like a bit of a clunky interface to me. Since the tools don't have much to unify them, I would just given them individual entry points. You could give them a unique prefix like zi-global-time-series
if you like.
zstash
is a coherent package with clear subcommands similar to git
or conda
so it makes sense to use this kind of an approach there but I think zppy-interfaces doesn't clearly benefit in the same way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is obviously just my opinion. You can stick with the zppy-intefaces
main command with subcommands if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xylar If we do completely separate commands, would it make more sense to have distinct dependency requirement lists too? (As opposed to a single dev.yml
for all of zppy-interfaces
). I'm not sure if that was something we had decided on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could see several utilities being useful to multiple interfaces -- for example, the OutputViewer
class for Global Time Series that E3SM-Project/zppy#616 will introduce will also be useful for adding Viewers to the PMP task in E3SM-Project/zppy#640. It follows that it may be useful to have a single dev environment for all of zppy-interfaces
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xylar If we do completely separate commands, would it make more sense to have distinct dependency requirement lists too? (As opposed to a single
dev.yml
for all ofzppy-interfaces
). I'm not sure if that was something we had decided on.
No, I would just have a single set of dependencies that covers the full package (all commands and any public functions, etc.).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could see several utilities being useful to multiple interfaces -- for example, the
OutputViewer
class for Global Time Series that E3SM-Project/zppy#616 will introduce will also be useful for adding Viewers to the PMP task in E3SM-Project/zppy#640. It follows that it may be useful to have a single dev environment for all ofzppy-interfaces
.
Yes, and there should be a place for a common framework that includes things like this.
I made a few suggestions but this is looking great so far! you'll need some more "glue" like |
Thanks @xylar! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes on latest changes
import unittest | ||
from typing import Any, Dict, List | ||
|
||
from zppy_interfaces.global_time_series.coupled_global import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to figure out how to import the code properly to the tests.
I've moved many of the tests and the modularized/refactored functions from E3SM-Project/zppy#616 directly into this pull request. Specifically I've moved the changes that are more general refactoring and not specific to Land support or Viewer generation.
coupled_global.coupled_global(parameters) | ||
|
||
|
||
# TODO: replace command line arguments with _get_cfg_parameters, like https://github.com/E3SM-Project/e3sm_diags/blob/main/e3sm_diags/parser/core_parser.py#L809 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think a cfg
would be cleaner, but I want to get this all working properly first before spending time on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I think we're close to being able to replicate existing functionality using the split-repo approach.
3 issues remaining, noted as part of this review.
@forsyth2, haven't heard anything further on this. Has this just had to move to the back burner or are you stuck anywhere that @altheaden, @tomvothecoder or I could help with? |
@xylar Yes, competing priorities at the moment unfortunately. Hoping to get back to this sometime this week. |
@forsyth2, it sounds like you should delete whatever installation of mambaforge/miniconda/whatever that you are currently using and start fresh. Download miniforge3: |
While that's fine, it should also be possible to use the entry point after you've run
|
Updating conda buildPreviously had this defined in
Deleted that block. Ran Went to https://github.com/conda-forge/miniforge (full link was giving a security error)
Now, this is at the end of my
Wrapped that in a function to call myself rather than having it auto-run:
Creating new environments
Testing/debugging
Re: #1 (comment) -- running the entry point requires the parameters be passed in on the command line. (It runs the Edit
python tests/integration/utils.py
zppy -c tests/integration/generated/test_min_case_global_time_series_original_8_chrysalis.cfg
# Wait for that to finish
cd /lcrc/group/e3sm/ac.forsyth2/zppy_min_case_global_time_series_original_8_output/test-642-working-env-20241121/v3.LR.historical_0051/post/scripts
cat global_time_series_1985-1995.o632171 That gives:
In the
Re: #1 (comment) -- the Made some edits in the cd /lcrc/group/e3sm/ac.forsyth2/zppy_min_case_global_time_series_original_8_output/test-642-working-env-20241121/v3.LR.historical_0051/post/scripts
rm -rf global_time_series_1985-1995* # Allow us to re-run just the global_time_series part
cd /home/ac.forsyth2/ez/zppy
pip install .
python tests/integration/utils.py
zppy -c tests/integration/generated/test_min_case_global_time_series_original_8_chrysalis.cfg The
Continued various debugging attempts on both the
which seems to be the opposite problem. Looks like the issue is the args actually have to be defined with zppy successfully generating plots by calling zppy-interfacesActually got zppy to call zppy-interfaces successfully. Still have the TS error on the zppy-interfaces side though. After more debugging, was successful in getting plots to show up at https://web.lcrc.anl.gov/public/e3sm/diagnostic_output/ac.forsyth2/zppy_min_case_global_time_series_original_8_www/test-642-working-env-20241121/v3.LR.historical_0051/global_time_series/global_time_series_1985-1995_results/ |
Cleaning up the codeMade edits to both This included build updates for
Rerun min-caseRerun the min-case to make sure everything still works: Edit
Run unit tests
All unit tests are now passing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have the initial implementation of the zppy
/zppy-interfaces
refactor done.
[Required reviewers] @xylar @chengzhuzhang I'd like to get approval from both of you before merging this.
[Optional reviewers] @tomvothecoder @altheaden you may want to review the conda/build portions of this PR.
Remaining to-do
After the refactor PRs merge:
- Run
zppy
's Weekly tests onmain
to make sure everything is still working properly after the merges. - Adjust the land support/Viewer generation PR (Create global time series Viewers zppy#616) accordingly
- Help integrate the PMP PR (Workflow for ZPPY- PCMDI for E3SM diagnostics (with fixes on issues found in #624) zppy#640) accordingly
Add these as GitHub issues to get to later:
- Add documentation, according to https://docs.e3sm.org/zppy/_build/html/main/contributing.html#initial-setup-obsolete-for-reference-only. (Looks like it's better to do that as its own PR) [definitely need to do this before the Unified release!]
- Add option to specify parameters through cfg rather than command line. E.g., https://github.com/E3SM-Project/e3sm_diags/blob/main/e3sm_diags/parser/core_parser.py#L809
- Switch pre-commit checks to
ruff
, as in https://github.com/xCDAT/xcdat/pull/702/files. - Rethink how testing is done in
zppy
&zppy-interfaces
.zppy
should simply test that it can invokezppy-interfaces global-time-series
.zppy-interfaces
however should test that Global Time Series plots actually generate correctly. Maybe havezppy
test thatzppy
is passing in the right parameters and then havezppy-interfaces
actually do the image comparisons of the plots, using pre-generatedts
andmpas_analysis
output.
Helpful details for reviewers
This is actually 2 PRs. This one and E3SM-Project/zppy#642.
zppy
- Anything under
tests/integration/generated
can be ignored. Those are just auto-generated testing files. - I added a
global_time_series
-specificenvironment_commands
to the test suite, so thatzppy-interfaces
could be used.- This is reflected in the 6 template
cfg
s (3 of these templates are "min-case" files which I use for debugging, and the other 3 are the big tests we run roughly weekly onmain
. For this PR, I've been debugging with themin_case_global_time_series_original_8
min-case.) - Also reflected in
tests/integration/utils.py
(This file is used to make run-ablecfg
s out of the templates).
- This is reflected in the 6 template
- I organized
zppy/templates
to be more logical.- There is now a subdirectory
zppy/templates/inclusions
which is for adding text word-for-word. default.ini
and the campaign files are now kept inzppy/defaults
.zppy/examples
includes files that aren't actually used anywhere and thus serve only as examples.- The
global_time_series
-specific files (coupled_global.py
,ocean_month.py
,readTS.py
) have been moved over tozppy-interfaces/zppy_interfaces/global_time_series
, out of thezppy
repo completely. Note, thereadTS.py
file has been included intocoupled_global.py
and other utilities have been pulled out into a newutils.py
. - The
jinja2
template bash scripts remain inzppy/templates
itself. - These directory changes can be seen throughout the PR, including in the unit test changes.
- There is now a subdirectory
- Much of
zppy/templates/global_time_series.bash
has been moved over tozppy_interfaces/global_time_series/__main__.py
aspython
code rather thanbash
code.
zppy-interfaces
This PR
- Conda/build updates:
.flake8
,.pre-commit-config.yaml
,conda/dev.yml
,pyproject.toml
,zppy_interfaces/version.py
- I noticed many changes in Create global time series Viewers zppy#616 were actually more general and not specifically about Land support and/or Viewer generation. I've pulled out those changes (notably refactoring of
coupled_global.py
into more concise, composable functions & testing those functions in unit tests)- Unit test:
tests/global_time_series/test_global_time_series.py
zppy_interfaces/global_time_series/coupled_global.py
andzppy_interfaces/global_time_series/utils.py
reflect these changes.
- Unit test:
- The only entry point right now is
zi-global-time-series
which runszppy_interfaces/global_time_series/__main__.py main
.- Please note that this modifies the case directory (only the
posts/
subdirectory though), which could be seen as modifying the input. However, this was the case before the refactor as well. Pre-refactor, the case dir was defined to be{{ output }}
, so we knew we were modifying the directory the user specified as output (which they could have set to be identical to{{ input }}
). Now, we sort of assumeoutput dir = input dir = case dir
, relying onzppy
to pass in the right output dir. - The
if __name__ == "__main__":
block of that file is for debugging manually, and is not called byzppy
.
- Please note that this modifies the case directory (only the
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My brief review of the DevOps related files with some comments and suggestions.
I recommend setting up a GH Actions build workflow similar to zppy
that runs the pre-commit
hooks and unit tests: https://github.com/E3SM-Project/zppy/blob/main/.github/workflows/build_workflow.yml
pyproject.toml
Outdated
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python :: 3.13", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tomvothecoder! I've implemented your suggestions on both PRs. Details of testing
That gives a warning -- one we're already escaping -- but all tests pass
After some edits to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@forsyth2, this looks great! On small suggested change.
Thanks for the reviews @xylar! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @forsyth2 this is exciting change. Thanks for making it happening. I think @xylar and @tomvothecoder had solid reviews for DevOp codes. and things looks promising. I'm approving this PR, it addresses the initial implementation.
Regarding to usability, I'm wondering if it is general enough, for instance, does zi-global-time-series
support land only simulation with easy syntax? Maybe the coupled_global.py
can be polished a bit. Anyway, these can be addressed in a future PR.
Thanks @chengzhuzhang!
|
Thank you @forsyth2 , command line options are good to have as well, just we need to think through all the options and make them intuitive to use. |
I added the issues mentioned in #1 (review): #2, #3, #4, #5. I also redid the issue labels (the color tags) to match |
It looks like any remaining comments/concerns can be addressed in later pull requests, so I think it's safe to say we have the initial implementation done. I'm going to merge this PR and E3SM-Project/zppy#642. The plan after that is:
|
Initial implementation for
zppy-interfaces
. Resolves discussion at E3SM-Project/zppy#641. Implements E3SM-Project/zppy#398.This pull request should be reviewed in conjunction with E3SM-Project/zppy#642.