-
Notifications
You must be signed in to change notification settings - Fork 65
Testing refactor #612
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
Testing refactor #612
Conversation
… with same binary name.
|
Greetings all, apologies for throwing this out there without an issue but I've been trying to keep up with the changes in the framework and the equivalent tests and was getting lost in the details and noticed a few things that I thought would make things a little bit easier overall. My main goal was making it more explicit what was being tested and reducing the amount of duplication we have but that necessitated quite a few changes at various levels of the infrastructure. I started going down a rabbit hole of how the framework is built and tested but before going much further, I figured I would share some of the things I've updated and check in to see if these make sense and are useful for the rest of the team. There are a few technical details that need to be evaluated as well but I wanted to check if, overall, this is moving things in a reasonable direction or if this is making things more complicated? |
|
Hi @mwaxmonsky, thanks for tackling this. So far, most of this looks like much needed cleanup! There is one change I do not understand. The old (clumsy, wordy) |
climbfuji
left a comment
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.
There is a lot of great stuff in this PR, thanks @mwaxmonsky.
My main concern with this PR is that it touches code/build files that aren't just used by the unit tests, but also by production code (e.g. the top-level CMakeLists.txt file). For instance, this PR enfores -O0 and certain compiler flags for the CCPP framework. We definitely do not want -O0 for production environments. There must be different options to set compilers for unit testing and for host models like the UFS, CAM/SIMA, NEPTUNE, and there must be a way for the host model to define compiler flags that overwrite any defaults (if we want to set defaults for cases other than running the tests).
There are two comments below that need fixing.
We also need to consider targeting the main branch for this PR due to the impact on the host modeling systems. This PR may have to come straight after the current develop was merged into main. And it must be written in a way that it allows ccpp-prebuild to continue to work, otherwise this PR (or the develop branch, if this PR gets merged into develop) will be blocked until all host models have moved to capgen. We don't want this, it was a heavy lift last time to get feature/capgen being merged into main after a long time of parallel development.
CMakeLists.txt
Outdated
| ADD_COMPILE_OPTIONS(-ggdb) | ||
| ADD_COMPILE_OPTIONS(-ffree-line-length-none) | ||
| ADD_COMPILE_OPTIONS(-cpp) | ||
| elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "IntelLLVM") |
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.
ifort will be staying around for quite a while longer, we need this as an option, too.
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.
Ah, okay, I'll add those back in and differentiate between ifort and ifx.
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.
Added ifort support back but haven't set up a job to run it yet.
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.
@climbfuji Would you be able to take a look at this and let me know if it's still not configured correctly and resolve the chain if so?
CMakeLists.txt
Outdated
| option(BUILD_SHARED_LIBS "Build a static library" OFF) | ||
| set(CCPP_VERBOSITY "0" CACHE STRING "Verbosity level of output (default: 0)") | ||
|
|
||
| if(CCPP_FRAMEWORK_ENABLE_TESTS) |
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.
If CCPP_FRAMEWORK_ENABLE_TESTS is ON, then there needs to be a find_package call for pFUnit with the REQUIRED keyword. pfunit must come from the user-provided software stack. No implicit installs during cmake calls/build steps.
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.
Understood, happy to make that change. I'm actually looking to make a container with all the dependencies/packages already installed so the environment better mimics our development environments to make the cmake call clean as well (we can pass in the pfunit path at configure time but it's clunky without modules).
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.
Updated so the debug flags are only added for test runs. I would like to create a container with the dependencies and cut down on the turnaround time to run the tests but this will work for now until that gets added.
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.
We should just move to a spack-stack container in the future
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.
Would we be able to leverage that at NCAR or would that be site specific?
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.
Anybody can. It's trivial to make a container that suits our needs, your needs, ...
test/capgen_test/test_reports.py
Outdated
| Usage: python test_reports <build_dir> <database_filepath> | ||
| ----------------------------------------------------------------------- | ||
| """ |
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.
Is every test directory in test/ going to have a copy of this gigantic file?
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 will be templating it so each test/test_reports.py file only sets the field variables and inherits the tests from a shared parent file. That's a detail that's on my list but wanted to get feedback on the present state before refactoring the other directories.
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.
@climbfuji Would you be able to take another look at this now that the tests are refactored and let me know if this can be resolved?
@gold2718 Yup! I made sure to be as faithful to the current coverage and made each of the shell tests their own unit tests at the bottom of the python file using the |
@climbfuji Happy to remove the In terms of options from different compilers/flags, I'll look into different APIs for cmake and see what makes the most sense. As for targeting main, I'm happy to pivot there but the tests for prebuild run successfully the same as on main. Is the issue that users would have to update their model code and their build integration with the framework? Just trying to understand the issue of targeting develop instead of main. |
Yes, if you change the top-level CMakeLists.txt, you will impact the host models that use the ccpp-framework. UFS, SCM and NEPTUNE all use the ccpp-framework CMakeLists.txt. |
|
Also, this might be better saved for a discussion thread but I was wondering about the references to MPI and OpenMP. I don't see any openmp pragmas or types and currently the only reference to MPI is the mpi_comm in I see a note in # Maximum number of concurrent CCPP instances per MPI task
CCPP_NUM_INSTANCES = 200and this value is used in the write function in mkstatic but it doesn't look like this is directly tied to the framework being build with MPI support. If we don't need MPI or openmp at build time for the framework, would it make sense removing these references in the CMake and ccpp_types or are these actively being used and I'm just missing a key detail? |
|
Currently, capgen generates |
|
ccpp-prebuild doesn't use any OpenMP calls in the auto-generated caps (everything comes from the host model via |
CMakeLists.txt
Outdated
| #------------------------------------------------------------------------------ | ||
| # Set package definitions | ||
| set(PACKAGE "ccpp-framework") | ||
| set(AUTHORS "Dom Heinzeller" "Grant Firl" "Mike Kavulich" "Dustin Swales" "Courtney Peverley") |
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.
Should we add more people here? Those who regularly contribute code and are on the CCPP framework dev team (@mwaxmonsky for example???)
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.
AUTHORS seems to be an environment variable that isn't used anywhere in the framework. Do we actually need this here?
If we do want to list the project authors it should probably be in documentation, maybe the top-level README.md?
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 looked into this a while ago and I think pre-github days, this was one of the ways to list the authors when packaging a release through one of the CPack functions (or maybe there was an intent to use the variable at some point?) but now that we have a CODEOWNERS file, would it make sense to create a single source for the code authors?
There doesn't seem to be a standard way to manage contributors/authors if we want to list external contributions unfortunately so any solution we come up with will have to be hand built depending on how we want to integrate that capability as well.
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.
If we don't need, then let's remove it.
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.
Can we remove this line?
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.
Removed!
climbfuji
left a comment
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.
It would have been nice if we could have avoided the duplication of variable lists between Fortran and Python, but we can make this update another time. The changes here look great and we should merge this rather sooner than later.
CMakeLists.txt
Outdated
| #------------------------------------------------------------------------------ | ||
| # Set package definitions | ||
| set(PACKAGE "ccpp-framework") | ||
| set(AUTHORS "Dom Heinzeller" "Grant Firl" "Mike Kavulich" "Dustin Swales" "Courtney Peverley") |
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.
Can we remove this line?
CMakeLists.txt
Outdated
| set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") | ||
| set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") |
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.
Can we do this with modern CMake syntax, i.e. only find the package here and then do
target_link_libraries(... OpenMP::OpenMP_C OpenMP::OpenMP_Fortran)
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.
So I think I might be missing something. The _OPENMP pragmas are added to the capgen code but even forcing _OPENMP=1 when running these results in no issues. Is this a case of we need these flags for the ccpp_lib but without a host explicitly needing OpenMP or MPI, we won't see any issues when they are removed?
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.
@mwaxmonsky I created mwaxmonsky#1 to better explain what I was thinking of.
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 @climbfuji! I pulled in those changes but 2 things come to mind:
- If we are requiring OPENMP for the workflow, should we add another workflow without OpenMP?
- I think the github runners support two cores, would it make sense to construct the tests to leverage two cores so we know that OpenMP is supported at runtime or is building/linking enough as a check?
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.
IMO what we have is good enough for both 1 and 2 for now.
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.
Okay, I'll leave everything as is. Thanks!
| add_library(ccpp_framework STATIC ${SOURCES_F90}) | ||
| target_link_libraries(ccpp_framework PUBLIC MPI::MPI_Fortran) | ||
| set_target_properties(ccpp_framework PROPERTIES VERSION ${PROJECT_VERSION} | ||
| set_target_properties(ccpp_framework PROPERTIES |
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.
See my comment above. Using the correct target_link_libraries for OpenMP will make line 18 unnecessary
test/var_compatibility_test/test_var_compatibility_integration.F90
Outdated
Show resolved
Hide resolved
peverwhee
left a comment
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 @mwaxmonsky ! One small documentation addition request.
Co-authored-by: Courtney Peverley <[email protected]>
|
@mwaxmonsky I see you made a few more changes in response to the approving reviews. Are there any more changes you planned to make or is it ready to merge? |
@mkavulich I'm happy with where this is and don't have any additional changes in mind so unless there are any last minute comments, I think we're good to go! |
…mpilers; run ccpp_prebuild.py tests in GitHub actions (#6) 1. Initial support for LLVM clang/flang; add guards to prevent using an unsupported compiler. 2. Enable basic CI testing for ccpp_prebuild.py and capgen.py on Atlantis with LLVM. Changes will be propagated to NCAR ccpp-framework main, but because of an impending update of the testing harness in the repository (NCAR#612) I will wait until after that PR is merged.
Refactoring of testing infrastructure
Changes include:
unittestframework.to just fortran and python file.
ddthost, and var_compatability tests.
and tests.
dependenciesand--exclude-requiredtests.CMAKE_BUILD_TYPE.-DDEBUGflag as generated code requires a--debugflag to insert debug logic explicitly.TODO:
Convert Fortran tests to pFUnit testsRemoving pFUnit for now.Determine if yaml or json is possible for Fortran to have single source for variable names and integrate into workflowWill implement in a separate PR to reduce review.User interface changes?: No
Fixes: None
Resolves #514
Testing:
test removed: None
unit tests:
system tests:
manual testing: