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

Update master from gmtb/develop 2019/10/16 #230

Merged

Conversation

climbfuji
Copy link
Collaborator

@climbfuji climbfuji commented Oct 16, 2019

Associated PRs:

#230
NCAR/ccpp-physics#340
NOAA-EMC/GFDL_atmos_cubed_sphere#5
NOAA-EMC/fv3atm#1
ufs-community/ufs-weather-model#1
NOAA-EMC/NEMS#11 (merged)
NOAA-EMC/NEMS#12

See ufs-community/ufs-weather-model#1 for a description and regression testing information.

This PR for ccpp-framework merges the previously approved changes made for the gmtb/develop branch into the master branch.

Changes specific to ccpp-framework:

  • cleanup of prebuild scripts (move common code into common.py module, ...)
  • add capability to create html pages from metadata files for all schemes in a CCPP configuration file (required for generating scientific documentation)
  • add out-of-source build capability to CCPP prebuild scripts (optional argument --builddir for ccpp_prebuild.py, write out list of schemes and caps to a shell script that can be sourced and sets environment variables)

climbfuji and others added 18 commits September 12, 2019 08:33
…INTERNAL_VARIABLE_DEFINITON_FILE to common.py, correct typo
…_batchconvert

gmtb/develop: metadata2html batch processing
…call to check_fortran_type, but do not throw an error in case a DDT is not registered
gmtb/develop: update from master, address issues from previous commit
- Documentation has been moved to the NCAR/ccpp-doc repository.
Remove CCPPtechnical directory, new home in NCAR/ccpp-doc repo
…ired for parallel cmake builds in NEMSfv3gfs
Copy link
Collaborator

@gold2718 gold2718 left a comment

Choose a reason for hiding this comment

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

Most of my comments / requested changes are suggestions but I am worried about the commented-out code in parse_checkers.py.

@@ -14,6 +15,16 @@

CCPP_TYPE = 'ccpp_t'

# SCRIPTDIR is the directory where ccpp_prebuild.py and its Python modules are located
SCRIPTDIR = os.path.abspath(os.path.split(__file__)[0])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason to not use os.path.dirname instead of split here? That function gets enhancements (e.g., support path-like objects) that I am not sure are guaranteed to work with split.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Out of curiosity, are these enhancements for Python 3? I read on the web (Python 2, https://docs.python.org/2/library/os.path.html and other sources) that os.path.dirname as well as os.path.basename internally use os.path.split to return the first/second part.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it seems that python 3 has more functionality for these functions (and probably a different internal implementation although I have not looked into that).

SCRIPTDIR = os.path.abspath(os.path.split(__file__)[0])

# SRCDIR is the directory where the CCPP framework source code (C, Fortran) is located
SRCDIR = os.path.abspath(os.path.join(SCRIPTDIR, '..', 'src'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use os.pardir in place of ...


# Import the host-model specific CCPP prebuild config;
# split into path and module name for import
configpath = os.path.abspath(os.path.split(configfile)[0])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another place to use os.path.dirname?

# Import the host-model specific CCPP prebuild config;
# split into path and module name for import
configpath = os.path.abspath(os.path.split(configfile)[0])
configmodule = os.path.split(configfile)[1].rstrip('.py')
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 prefer os.path.basename(configfile).rstrip('.py')
Also, is there enforcement somewhere of the .py suffix? If not, why not just strip off any suffix?
re.sub('[.]+[^.]*$', '', os.path.basename(configfile))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will use os.path.basename(configfile).rstrip('.py') for now. Not sure, but if I use __import__ or importlib.import_module afterwards, isn't Python looking for configfile + .py ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, I am going to use

    configpath = os.path.abspath(os.path.dirname(configfile))
    configmodule = os.path.splitext(os.path.basename(configfile))[0]

because this relies on existing functionality of the os module only.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that.

configpath = os.path.abspath(os.path.split(configfile)[0])
configmodule = os.path.split(configfile)[1].rstrip('.py')
sys.path.append(configpath)
ccpp_prebuild_config = __import__(configmodule)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a particular reason why importlib.import_module cannot be used here? __import__ is discouraged unless necessary.

Comment on lines +357 to +365
# DH* 20190913 - skip checking if a DDT is registered at this time
#if match is None:
# if error:
# raise CCPPError("'{}' is not a valid{} Fortran type".format(typestr, dt))
# else:
# typestr = None
# # End if
## End if
# *DH 20190913
Copy link
Collaborator

Choose a reason for hiding this comment

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

This sort of change is going to make it difficult to keep the capgen development branch up to date with master. Can we find some other technique (e.g., some variable test) to ensure that this clause is not triggered for master but is active for feature/capgen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd suggest to worry about this once capgen is merged into master - until then, the logic in the master-version of the scripts that capgen would be using would require this change as well, because it assumes that (a) all DDTs used are defined in the same metadata file (which is certainly not going to be the case) and that they are defined in the metadata file before they are used. I understand that the feature/capgen version completes the analysis phase and then knows about all DDTs, but the current version in the master branch does not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I will accept that, however, this means that master and feature/capgen will diverge until then. Adding more logic to keep the if statement from being triggered in master, will allow updates to feature/capgen.

…dard libraries instead of deprecated or manual tools
@codecov-io
Copy link

codecov-io commented Oct 18, 2019

Codecov Report

Merging #230 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #230   +/-   ##
=======================================
  Coverage   47.28%   47.28%           
=======================================
  Files          14       14           
  Lines        1343     1343           
=======================================
  Hits          635      635           
  Misses        708      708

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c2332d...82329df. Read the comment docs.

Copy link
Collaborator

@grantfirl grantfirl left a comment

Choose a reason for hiding this comment

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

Looks OK to me.

@climbfuji climbfuji merged commit d473ed5 into NCAR:master Oct 31, 2019
@climbfuji climbfuji deleted the update_master_from_gmtb_develop_20191016 branch June 27, 2022 03:10
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.

4 participants