251 use jinja for job script rendering#254
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #254 +/- ##
==========================================
+ Coverage 60.76% 61.15% +0.38%
==========================================
Files 30 30
Lines 2238 2260 +22
==========================================
+ Hits 1360 1382 +22
Misses 878 878 ☔ View full report in Codecov by Sentry. |
| #PBS -l storage={{storage}} | ||
|
|
||
| module purge | ||
| {% for module in modules -%} |
There was a problem hiding this comment.
Note the -%, which controls whitespace generation in Jinja.
https://jinja.palletsprojects.com/en/latest/templates/#whitespace-control
|
All tests pass btw. |
ccarouge
left a comment
There was a problem hiding this comment.
A small comment about typing. Otherwise all good. I approve but it would be good to fix the typing before merging if I am correct in my comment.
| template = load_package_data(template_file) | ||
| return interpolate_string_template(template, **kwargs) |
There was a problem hiding this comment.
Above it says load_package_data() outputs a dictionary but interpolate_string_template() takes a string as input.
I'm guessing the typing of the function's return value for load_package_data() needs to be updated to be Union[str, dict]?
There was a problem hiding this comment.
yes you are correct, now that we are potentially reading raw data this is needed. I'll update that now.
Replaced in-source job script generation with Jinja templating.
For context - this simplifies the generation of job scripts (and indeed anything that interpolates into a template), meaning that we can remove the multiline string blocks, which are sensitive to whitespace, and abstract them into separate files.
This results in cleaner and more flexible code going forward and opens up opportunities to change the underlying templates at a moments notice.