Improve ergonomics of pytest machinery#318
Conversation
…esting infrastructure
| @@ -86,18 +124,12 @@ First, check out the highest numbered gold standard tag and compile ``enzo-e``. | |||
| $ git checkout gold-standard-1 | |||
There was a problem hiding this comment.
I know this is not changed in this PR, but aren't we on gold-standard-004?
There was a problem hiding this comment.
You are correct. I have updated this accordingly (and I've added a note commenting that readers will need to update the number in the future)
| else: | ||
| enzoe_path = os.path.join(_root_dir, 'build/bin/enzo-e') | ||
| if not os.path.isfile(enzoe_path): | ||
| raise RuntimeError(f"enzo-e isn't at {enzoe_path}. If the it is " |
There was a problem hiding this comment.
| raise RuntimeError(f"enzo-e isn't at {enzoe_path}. If the it is " | |
| raise RuntimeError(f"enzo-e isn't at {enzoe_path}. If it is " |
brittonsmith
left a comment
There was a problem hiding this comment.
Yeah, this looks good. Just a couple typos I caught, but happy for this to be merged.
| This is useful for testing problems with no analytical solution or generally | ||
| verifying that results from commonly run simulations don't drift. | ||
|
|
||
| It is also useful for testing property of simulation runs beyond the exit-time/cycle of the simulation. |
There was a problem hiding this comment.
This sentence is a bit awkward. I'm not sure what it's trying to say.
There was a problem hiding this comment.
Thanks for catching this! I'm not sure what I was saying here either... (I was probably referencing the fact that most tests in the ctest framework just check the final simulation time/cycle)
I replaced the whole paragraph, which was originally written as
It is also useful for testing property of simulation runs beyond the
exit-time/cycle of the simulation. (While such tests do exist in the
ctest-framework, they often involve more boiler-plate code).with the following snippet:
It is also useful in for testing problems that do have analytic
solutions (the answer test might quantify how close a simulation
result is to the analytic expected solution). While such tests do
exist in the ctest-framework, they often involve more boiler-plate
code.Co-authored-by: Britton Smith <brittonsmith@gmail.com> Co-authored-by: Greg Bryan <gbryan@astro.columbia.edu>
|
@brittonsmith and @gregbryan -- let me know if my changes addressed your concerns |
This PR introduces a number of small changes that should make the pytest machinery easier to use, particularly when you are switching between multiple branches.
These changes include:
--charmandCHARM_PATH--grackle-input-data-dirandGRACKLE_INPUT_DATA_DIR--local-dirandTEST_RESULTS_DIR(the command line flag borrows the name thatytuses)--answer-storeandGENERATE_TEST_RESULTS(the command line flag borrows the name thatytuses)--build-dirwhich you can use to specify the directory where the target Enzo-E binary was built. If--charmandCHARM_PATHare not specified, then the test program will infer the appropriate location of thecharmrunexecutable based on the contents ofCMakeCache.txt.USE_DOUBLEenvironment variable), and querying whether the executable was built with Grackle (tests no longer fail problem ifGRACKLE_INPUT_DATA_DIRis set and enzo-e was compiled without Grackle - those tests are now skipped).As an aside, I completely removed the
ENZO_PATHvariable as it's no longer necessary (and I'm pretty sure that I'm the only person to use it). Everything else should be fully backwards-compatible.With these changes, it's much easier to invoke the pytest machinery while moving between different branches that are built in different build directories (and may depend on different versions of charm++).
For example, if I have the build-directories
build-intel-impibuild-gcc-openmpiI can invoke
pytestfrom the root directory with:pytest test/answer_test --build-dir ./build-intel-impi --local-dir ~/enzoe-gs-intelpytest test/answer_test --build-dir ./build-gcc-openmpi --local-dir ~/enzoe-gs-gccWhile this is verbose, I would have previously needed to be sure to update the
ENZO_PATH,CHARM_PATH, andTEST_RESULTS_DIRenvironment variables. I might also need to adjustGRACKLE_INPUT_DATA_DIRorUSE_DOUBLEif one of these builds was compiled with/without grackle or with a different precision.Additional improvements could potentially be made. For example, it may be sensible for
pytestto assume that it is invoked from a build-directory when it is invoked without--build-dir(unless it is invoked from the root directory). But, that's a topic for another day.In the course of this PR, I refactored the functionality for executing an
enzo-esimulation into a class calledEnzoEDriverand moved it into a newtest_utilssub-directory.Currently there are a bunch of wrappers for executing
enzo-efloating around the repository. The idea was to provide a single centralized implementation that other python code can call into. While most of these other wrappers occur in test code that should eventually be integrated into the pytest, I expect it may still be useful to have this centralized wrapper.In any case, it was important to factor out the enzo-e wrapper from the rest of the answer-testing machinery. This will be important for new checkpoint-restart tests that I'm adding to the pytest machinery, which are nearly ready for review.
Along the way, I also added the ability to allow the enzo-e wrapper to easily modify the parameters used in the simulation. This was inspired by what athena++ does and greatly simplifies the code for forthcoming checkpoint-restart tests and convergence tests. (Note: modifying the parameters currently happens outside of the enzo-e binary, by creating a new parameter file)
EDIT: Reviewing this PR is important because it is a dependency of PR #324, which should be a high priority