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

Add ParamGen and multi-namelist definition functionality #183

Merged
merged 34 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f072a64
Move all non-ConfigCAM classes to new, separate 'cam_config_classes.p…
nusbaume Oct 12, 2021
59c291c
Update CIME to use ParamGen branch.
nusbaume Oct 13, 2021
b183035
Ignore new share code directories.
nusbaume Oct 13, 2021
9262863
Initial implementation of ParamGen as the
nusbaume Nov 6, 2021
b46b544
Update ncar-physics external to avoid need to modify SDF.
nusbaume Nov 23, 2021
3abeaed
Make the case 'DEBUG' flag a config variable/namelist attribute.
nusbaume Jan 11, 2022
de01ffa
Write namelist variable strings based off their specified type.
nusbaume Jan 11, 2022
b7f9b15
Write namelist entries alphabetically, and make sure the type element…
nusbaume Jan 12, 2022
60ada0c
Modify issue-closing workflow to only run on PRs to the NCAR
nusbaume Jan 24, 2022
113c6f3
Add new 'append_atm_in_pg' method to allow for the use of multiple
nusbaume Feb 1, 2022
5a0bac7
Fix some bugs to allow CAMDEN to build/run.
nusbaume Feb 8, 2022
a8e128e
Fix python doctests.
nusbaume Feb 8, 2022
39a9776
Fix python unit tests.
nusbaume Feb 8, 2022
2c5b876
Fix pylint concerns.
nusbaume Feb 9, 2022
df3393c
Add new 'AtmInParamGenError' error class, and fix build cache bug.
nusbaume Feb 9, 2022
3fdec60
Add the ability to write array/list entries to atm_in.
nusbaume Feb 11, 2022
7dd3d59
Add ParamGen and namelist reader generator tests to Github Actions.
nusbaume Feb 11, 2022
7bedb19
Remove python 3.6 from testing list (doesn't work with ParamGen), and…
nusbaume Feb 11, 2022
b4a3629
Make modifications associated with restricting the python
nusbaume Mar 8, 2022
e46823a
Fix pylint errors, and update python versions used in Github Actions.
nusbaume Mar 9, 2022
6aef116
Add array index duplication checking, along with some code review req…
nusbaume Apr 14, 2022
27bf2af
Add remaining code review requests.
nusbaume Apr 15, 2022
b7f8c15
Fix pylint errors.
nusbaume Apr 15, 2022
27c9b87
Fix additional pylint errors.
nusbaume Apr 15, 2022
ea79c2a
Fix bugs found during integration testing.
nusbaume Apr 19, 2022
4229b2f
Add Courtney's code review requests.
nusbaume May 20, 2022
34fbe68
Update ParamGen branch to head of CIME, and implement related code mods.
nusbaume Jun 10, 2022
c9c7389
Move CIME external to tag from ESMCI/CIME repo.
nusbaume Jun 27, 2022
35a18b7
Created new function (parse_dim_spec) to parse array sections
Jul 15, 2022
30d7d1e
Merge pull request #3 from gold2718/ParamGen_namelist
nusbaume Jul 15, 2022
6146444
Update comments and attempt to fix current CI test failures.
nusbaume Jul 15, 2022
fe3433d
Apply changes from another round of code review.
nusbaume Jul 19, 2022
b3c2bc9
Apply code review suggestions for the 'ConfigCAM' class and related f…
nusbaume Jul 26, 2022
c161e61
Simplify error message code for CAM config classes.
nusbaume Jul 29, 2022
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
26 changes: 13 additions & 13 deletions .github/scripts/branch_pr_issue_closer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def project_card_move(oa_token, column_id, card_id):
"""

#create required argument strings from inputs:
github_oa_header = ''' "Authorization: token {0}" '''.format(oa_token)
github_url_str = '''https://api.github.com/projects/columns/cards/{0}/moves'''.format(card_id)
json_post_inputs = ''' '{{"position":"top", "column_id":{}}}' '''.format(column_id)
github_oa_header = f''' "Authorization: token {oa_token}" '''
github_url_str = f'''https://api.github.com/projects/columns/cards/{card_id}/moves'''
json_post_inputs = f''' '{{"position":"top", "column_id":{column_id}}}' '''

#Create curl command line string:
curl_cmdline = '''curl -H '''+github_oa_header+''' -H "Accept: application/vnd.github.inertia-preview+json" -X POST -d '''+\
Expand Down Expand Up @@ -101,7 +101,7 @@ def end_script(msg):
"""
Prints message to screen, and then exits script.
"""
print("\n{}\n".format(msg))
print(f"\n{msg}\n")
print("Issue closing check has completed successfully.")
sys.exit(0)

Expand Down Expand Up @@ -173,7 +173,7 @@ def _main_prog():
first_word = post_msg_word_list[0]

#Print merged pr number to screen:
print("Merged PR: {}".format(first_word))
print(f"Merged PR: {first_word}")

try:
#Try assuming the word is just a number:
Expand Down Expand Up @@ -267,10 +267,10 @@ def _main_prog():
issue_pattern = re.compile(r'#[0-9]+(\s|,|$)|.')

#Create new "close" issues list:
close_issues = list()
close_issues = []

#Create new "closed" PR list:
close_pulls = list()
close_pulls = []

#Search text right after keywords for possible issue numbers:
for match in word_matches:
Expand Down Expand Up @@ -364,20 +364,20 @@ def _main_prog():
end_script(endmsg)

#Print project name associated with merged PR:
print("merged PR project name: {}".format(proj_mod_name))
print(f"merged PR project name: {proj_mod_name}")

#++++++++++++++++++++++++++++++++++++++++
#Extract repo project "To do" card issues
#++++++++++++++++++++++++++++++++++++++++

#Initalize issue counting dictionary:
proj_issues_count = dict()
proj_issues_count = {}

#Initalize issue id to project card id dictionary:
proj_issue_card_ids = dict()
proj_issue_card_ids = {}

#Initialize list for issues that have already been closed:
already_closed_issues = list()
already_closed_issues = []

#Loop over all repo projects:
for project in projects:
Expand Down Expand Up @@ -467,7 +467,7 @@ def _main_prog():
cam_issue = cam_repo.get_issue(number=issue_num)
#Close issue:
cam_issue.edit(state='closed')
print("Issue #{} has been closed.".format(issue_num))
print(f"Issue #{issue_num} has been closed.")
else:
#Extract card id from id dictionary:
if issue_num in proj_issue_card_ids:
Expand Down Expand Up @@ -498,7 +498,7 @@ def _main_prog():

#Close Pull Request:
cam_pull.edit(state='closed')
print("Pull Request #{} has been closed.".format(pull_num))
print(f"Pull Request #{pull_num} has been closed.")

#++++++++++
#End script
Expand Down
20 changes: 9 additions & 11 deletions .github/scripts/pr_mod_file_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

import sys
import os
import subprocess
import shlex
import argparse

from stat import S_ISREG
Expand Down Expand Up @@ -63,7 +61,7 @@ def _file_is_python(filename):
#If no ".py" extension exists, then
#open the file and look for a shabang
#that contains the word "python".
with open(filename, "r") as mod_file:
with open(filename, "r", encoding='utf-8') as mod_file:
#Loop over lines in file:
for line in mod_file:

Expand Down Expand Up @@ -170,7 +168,7 @@ def _main_prog():
#++++++++++++++++++++++++++++++

#Create empty list to store python files:
pyfiles = list()
pyfiles = []

#Extract Github file objects:
file_obj_list = pull_req.get_files()
Expand Down Expand Up @@ -220,14 +218,14 @@ def _main_prog():
print("+++++++++++++++++++++++++++++++++++++++++++++++")

#Raise test failure exception:
fail_msg = "One or more files are below allowed pylint " \
"score of {}.\nPlease see pylint message(s) " \
"above for possible fixes."
fail_msg = "One or more files are below allowed pylint "
fail_msg += f"score of {pylev}.\nPlease see pylint message(s) "
fail_msg += "above for possible fixes."
raise PrModTestFail(fail_msg)
else:
#All tests have passed, so exit normally:
print("All pylint tests passed!")
sys.exit(0)

#All tests have passed, so exit normally:
print("All pylint tests passed!")
sys.exit(0)

#If no python files exist in PR, then exit script:
else:
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/branch_push_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,23 @@ jobs:
#This job is designed to close any issues or pull requests specified
#in the body of a pull request merged into a non-default branch.
issue_closer:
if: github.repository == 'NCAR/CAMDEN' # Only run on main repo
runs-on: ubuntu-latest
steps:
# Acquire github action routines
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# Acquire specific version of python
- name: Set up Python 3.6
if: github.repository == 'NCAR/CAMDEN' # Only run on main repo
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: '3.6' # Semantic version range syntax or exact version of a Python version
python-version: '3.10' # Semantic version range syntax or exact version of a Python version
# Install required python packages
- name: Install dependencies
if: github.repository == 'NCAR/CAMDEN' # Only run on main repo
run: |
python -m pip install --upgrade pip # Install latest version of PIP
pip install PyGithub # Install PyGithub python package
# Run CAM issue-closing script
- name: Run python Github issue-closing script
if: github.repository == 'NCAR/CAMDEN' # Only run on main repo
env:
ACCESS_TOKEN: ${{ secrets.WRITE_ACCESS_TOKEN }}
run: .github/scripts/branch_pr_issue_closer.py --access_token $ACCESS_TOKEN --trigger_sha $GITHUB_SHA
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/pr_open_sync_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
strategy:
matrix:
#All of these python versions will be used to run tests:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10"]
gold2718 marked this conversation as resolved.
Show resolved Hide resolved
fail-fast: false
steps:
# Acquire github action routines:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# Acquire specific version of python:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
Expand All @@ -35,7 +35,9 @@ jobs:
pip install pytest
# Run "checkout_externals":
- name: Checkout externals
run: manage_externals/checkout_externals --externals Externals_CAM.cfg ccpp-framework
run: |
manage_externals/checkout_externals --externals Externals_CAM.cfg ccpp-framework
manage_externals/checkout_externals --externals Externals.cfg cime
# Run python unit and doctests:
- name: python unit tests
run: |
Expand All @@ -47,12 +49,20 @@ jobs:
python cime_config/cam_autogen.py
# CAM build cache doctests:
python cime_config/cam_build_cache.py
# Namelist reader generator doctests:
python cime_config/create_readnl_files.py
# Registry generator doctests:
pytest src/data/generate_registry_data.py --doctest-modules
# ParamGen atm_in namelist writer doctests:
pytest cime_config/atm_in_paramgen.py --doctest-modules
# Registry generator unit tests:
python test/unit/test_registry.py
# Namelist reader autogeneration unit tests
python test/unit/create_readnl_files_tests.py
# Physics variable init (phys_init) generator unit tests:
python test/unit/write_init_unit_tests.py
# ParamGen atm_in namelist writer unit tests:
python test/unit/test_atm_in_paramgen.py

#####

Expand All @@ -65,12 +75,12 @@ jobs:
runs-on: ubuntu-latest
steps:
# acquire github action routines
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# acquire specific version of python
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: '3.8' # Use python 3.8
python-version: "3.10" # Use python 3.8
# install required python packages
- name: Install dependencies
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
ccpp_framework
chem_proc
cime
share
libraries
components
manage_externals.log
src/physics/carma/base
Expand Down
2 changes: 1 addition & 1 deletion Externals.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ required = True
[cime]
branch = CAMDEN_ParamGen
protocol = git
repo_url = https://github.com/gold2718/cime
repo_url = https://github.com/nusbaume/cime
cacraigucar marked this conversation as resolved.
Show resolved Hide resolved
local_path = cime
required = True

Expand Down
4 changes: 2 additions & 2 deletions Externals_CAM.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
local_path = ccpp_framework
protocol = git
repo_url = https://github.com/gold2718/ccpp-framework
tag = CPF_0.2.030
tag = CPF_0.2.032
required = True

[cosp2]
Expand All @@ -23,7 +23,7 @@ required = False
local_path = src/physics/ncar_ccpp
protocol = git
repo_url = https://github.com/NCAR/atmospheric_physics
tag = atmos_phys0_00_014
tag = atmos_phys0_00_015
required = True

[silhs]
Expand Down
Loading