(closes #2936, #1220, #2088) Fix doctests and add CI tests#3441
(closes #2936, #1220, #2088) Fix doctests and add CI tests#3441sergisiso wants to merge 25 commits into
Conversation
…d brining the shallow example inside the test directory
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3441 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 393 393
Lines 55067 55046 -21
=========================================
- Hits 55067 55046 -21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…lities to be able to find them
|
@arporter @LonelyCat124 This PR fixes the doctests using both: And enables both as checks in CI (We need both because there isn't a complete overlap between both sets and their working dir is different, so we need to be sure that paths have been normalised). There are some doctests that didn't work, for example because they used non-existing example files. In this cases I converted the It is ready for review. |
arporter
left a comment
There was a problem hiding this comment.
Good job Sergi, it's great to have this working and the PR wasn't quite as big as I feared :-)
Only significant quibble is with the new utility method - I'm not sure it buys us much over get_invoke and wonder whether the two can be merged?
|
|
||
| .. testoutput:: | ||
|
|
||
| .. The snippet above fails a `.. testcode ::` block, but if it didn't we |
There was a problem hiding this comment.
Why does it fail? Is it because the file doesn't exist or is it because of the relative path given to the module manager?
There was a problem hiding this comment.
It failed because some of the module files where moved to ../external/lfric_infrastructure/ and this was not updated. Fixed now.
(Hopefully these are the things that enabling doc-tests back will avoid)
| config.api = api | ||
|
|
||
| _, info = parse(filepath, api=api) | ||
| psy = PSyFactory(api, distributed_memory=dist_mem).create(info) |
There was a problem hiding this comment.
This could be simplified a lot if you used get_invoke. In fact, I'm not sure that this new method brings much benefit over the latter?
There was a problem hiding this comment.
I have now one calling the other, so the code is not duplicated.
One of the reasons that I prefered the new method is because all examples had the "invoke.schedule" before and this is not user-facing infrastructure. It's not what they have to do in the trans script and think this could be unecessarely confusing.
|
|
||
| class GOceanExtractTrans(ExtractTrans): | ||
| ''' GOcean1.0 API application of ExtractTrans transformation \ | ||
| ''' GOcean1.0 API application of ExtractTrans transformation |
| ''' LFRic API application of ExtractTrans transformation | ||
| to extract code into a stand-alone program. For example: | ||
|
|
||
| >>> from psyclone.parse.algorithm import parse |
There was a problem hiding this comment.
How come you've removed this? Also, the paragraph above still ends with "For example:..."
There was a problem hiding this comment.
The filename does not exist: find . -name solver_alg.x90 returns nothing.
Removed "For example:"
| >>> # Uncomment the following line to see a text view of the schedule | ||
| >>> # print(schedule.view()) | ||
| >>> kernels = schedule.children[9] | ||
| >>> kernels = schedule.children[26] |
There was a problem hiding this comment.
This could be a bit fragile. Could we make it a little better by walking over Loops?
There was a problem hiding this comment.
Done.
Note that a lot of doctests like this one are currently not very interesting, they only show how to apply a transformation (which a python user should already know). What is more interesting is to show the before and after of the associated code. I suppose this was the idea behing the print(schedule.view()) but these are too lang and hard to read and they where commented in the documentation anyway (so not checked nor shown in docs).
My idea is to make a second chosing snippets of fortran that demonstrate each transformation, but it became too much for this PR. So for now I just wanted to enable the automatic testing and then we should make them apply and showcase more relevant inout/output nodes/strings.
| class OMPParallelLoopTrans(OMPLoopTrans): | ||
| ''' Adds an OpenMP PARALLEL DO directive to a loop. | ||
|
|
||
| For example: |
There was a problem hiding this comment.
It seems a shame to lose this. Is it possible to keep a version?
There was a problem hiding this comment.
As mention, I didn't find these very valuable as they were because:
- the psyfactory/invoke should not be exposed to the user
- the trans.apply is trivial and doesn't need a example imo
- the input file does not exist, so it was not possible to see the behaviour (which is the interesting part).
But since you asked I redid this example as I think we should be doing them.
|
|
||
| ''' | ||
| Profiler.set_options([Profiler.INVOKES], api="nemo") | ||
| Profiler.set_options([Profiler.INVOKES], api="gocean") |
There was a problem hiding this comment.
This implies Profiler was missing a check on the validity of the API string? Have you fixed that?
There was a problem hiding this comment.
This didn't use the api value, and it feels it is not the right place to validate api strings. So I changed it to a boolean "is_psykal"
There was a problem hiding this comment.
(btw, I initially changed that because I did a grep for remaining api="nemo", not because it failed)
| assert issubclass(psy_except, PSycloneError) | ||
| # Check if the exception inherits PSycloneError (we don't use | ||
| # issubclass because the import_modules used in this test re-imports | ||
| # already loaded modules and create two super classes PSycloneError) |
There was a problem hiding this comment.
Does that mean we should be monkeypatching or something or are those changes local to this test?
There was a problem hiding this comment.
(Well done on fixing this BTW - presumably this was the test error we see occasionally?)
There was a problem hiding this comment.
Yes, this was not isolated. But under further inspection I think we were overcomplicating a lot this test. I updated to something much simpler. Let me know what you think.
| >>> from psyclone.parse.algorithm import parse | ||
| >>> from psyclone.psyGen import PSyFactory | ||
| >>> api = "lfric" | ||
| >>> ast, invokeInfo = parse("file.f90", api=api) |
There was a problem hiding this comment.
Is it possible to recover this one? If not, please update the docstring above.
There was a problem hiding this comment.
Updated docstring.
|
@arporter This is ready for another look, I provided in the comments some more explanation about why I did certain additions/deletetions in the PR that were missing for context. |
No description provided.