Skip to content

Using jinja2 loops in config files? #563

Closed Answered by maddenp-noaa
benjamin-cash asked this question in Q&A
Discussion options

You must be logged in to vote
$ cat ben.yaml 
{%- set months = ['01','02','03','04','05','06','07','08','09','10','11','12'] -%}
input_base: '/work2/02441/bcash/frontera/ufs_input'
fix:
  {%- raw %}
  base_dir: '{{ input_base }}/fix'
  aer: '{{ fix.base_dir }}/aer/20220805'
  {% endraw -%}
  files_to_copy:
   {% for mn in months -%}
   aeroclim.m{{ mn }}.nc: '{% raw %}{{ fix.aer }}{% endraw %}/merra2.aerclim.2003-2014.m{{ mn }}.nc'
   {% endfor %}
$ cat ben.yaml | uw template render | uw config realize --input-format yaml --output-format yaml
input_base: /work2/02441/bcash/frontera/ufs_input
fix:
  base_dir: /work2/02441/bcash/frontera/ufs_input/fix
  aer: /work2/02441/bcash/frontera/ufs_input/fix/aer/20220805
  file…

Replies: 3 comments 9 replies

Comment options

You must be logged in to vote
2 replies
@benjamin-cash
Comment options

benjamin-cash Aug 8, 2024
Collaborator Author

@benjamin-cash
Comment options

benjamin-cash Aug 8, 2024
Collaborator Author

Comment options

You must be logged in to vote
2 replies
@benjamin-cash
Comment options

benjamin-cash Aug 8, 2024
Collaborator Author

@benjamin-cash
Comment options

benjamin-cash Aug 8, 2024
Collaborator Author

Comment options

You must be logged in to vote
5 replies
@benjamin-cash
Comment options

benjamin-cash Aug 8, 2024
Collaborator Author

@maddenp-noaa
Comment options

@christinaholtNOAA
Comment options

@benjamin-cash
Comment options

benjamin-cash Aug 8, 2024
Collaborator Author

@maddenp-noaa
Comment options

Answer selected by benjamin-cash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants