Skip to content
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

Enable searching for included templates when rendering jinja2 templates. #15

Merged
merged 9 commits into from
Mar 4, 2024

Conversation

aerorahul
Copy link
Contributor

Description
The current implementation of jinja2 rendering was unable to support include when the included template was in a location not directly under the current template directory.
This PR:

  • allows jinja to search for templates in paths that are provided as searchpath as well as from /
  • removes the parsing of mixed jinja and other template form $( ) from function parse_j2yaml. This was a stop gap measure to allow prototyping in the DA applications. Those have now matured that this stop gap needed to be addressed holistically.
  • contains some minor code cleanup where appropriate in jinja2.py and yaml_file.py. Test for the include is added.
  • updates github actions versions for checkout, setup-python. Also updates the authentication to code-cov v4 that requires use of token stored as a secret.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • pynorms
  • pytests
  • in a downstream DA application with robust use of include including nesting.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes need updates to the documentation. I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • New and existing tests pass with my changes
  • Any dependent changes have been merged and published

Copy link

codecov bot commented Mar 2, 2024

Codecov Report

Attention: Patch coverage is 84.21053% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 48.87%. Comparing base (d69dbbc) to head (968cddd).

Files Patch % Lines
src/wxflow/jinja.py 86.20% 3 Missing and 1 partial ⚠️
src/wxflow/schema.py 0.00% 1 Missing ⚠️
src/wxflow/yaml_file.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #15      +/-   ##
===========================================
- Coverage    48.91%   48.87%   -0.05%     
===========================================
  Files           15       15              
  Lines         1429     1416      -13     
  Branches       305      308       +3     
===========================================
- Hits           699      692       -7     
+ Misses         676      670       -6     
  Partials        54       54              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aerorahul aerorahul merged commit dd9ca24 into develop Mar 4, 2024
16 of 17 checks passed
@aerorahul aerorahul deleted the feature/jinja_includes branch March 4, 2024 14:34
CoryMartin-NOAA pushed a commit to NOAA-EMC/GDASApp that referenced this pull request Mar 4, 2024
This PR:
- updates the snowDA yamls to jinja2 templates removing all `$( )` and
`${ }` template forms.
- all inclusion is now performed via jinja2 `include` with the
appropriate indentation.
- jinja2 templates for yamls now carry a `.j2` extension to identify
them as templates.
- requires `feature/jinja2_includes` branch from `wxflow`. 

`parse_j2yaml` from `wxflow` now does not render the `$( )` templates.
This change is **not** backwards compatible.

Corressponding PRs in `wxflow` and `global-workflow` are:
- NOAA-EMC/wxflow#15
- NOAA-EMC/global-workflow#2371
@aerorahul aerorahul mentioned this pull request Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants