-
Notifications
You must be signed in to change notification settings - Fork 12
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
Preserve import statement functions - take II #283
Conversation
b8df25c
to
cab16c3
Compare
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/283/index.html |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #283 +/- ##
==========================================
+ Coverage 92.82% 92.88% +0.05%
==========================================
Files 102 102
Lines 18220 18247 +27
==========================================
+ Hits 16913 16948 +35
+ Misses 1307 1299 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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, as discussed offline this seems like a justifiable variant of baking in IFS-specific knowledge but minimal impact. The blanket check for func
in the import name might create problems, though, so I've suggested a slightly different approach.
target_symbol = im.module.split('.')[0].lower() | ||
if targets and target_symbol.lower() in targets: | ||
if targets and target_symbol.lower() in targets and not 'func' in im.module.lower(): |
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.
Sorry for nitpicking further but just realized that this may fail in pretty trivial cases, e.g., #include "myfunc.intfb.h"
will now not be processed... 😅
Should we apply the IFS-specific knowledge a bit more explicitly, e.g. like this?
target_symbol, *suffices = im.module.lower().split('.', maxsplit=1)
if targets and target_symbol in targets and 'func.h' not in suffices:
Note that this works even if no .
is in the module name at all, returning suffices
as an empty list.
That way this becomes a very loose restriction specific to the problem of statement functions and in-line with the coding standards.
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 of course, well spotted and apologies for the clumsy oversight 😅
ef023b4
to
b6993c7
Compare
b6993c7
to
1301302
Compare
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 for taking care of the requested changes and bonus points for capturing this edge case in the 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.
Looks great and is confirmed clean with ec-physics regression. GTG
A second take on preserving statement function imports via c-style headers. This time, rather than only renaming imports with
intfb
in their name, we now skip all imports withfunc
in their name. I do realise that this introduces another IFS specific naming convention to theDependencyTransformation
, and this probably needs generalising.