Skip to content

Commit 42d3238

Browse files
Dana SinghDana Singh
authored andcommitted
#48 Merge branch 'main' of github.com:NOAA-GFDL/fre-workflows into 48.wf-script-edits
2 parents 286866b + 6a26a90 commit 42d3238

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Jinja2Filters/get_components.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import re
2+
import os
3+
from pathlib import Path
4+
import yaml
5+
6+
# set up logging
7+
import logging
8+
logging.basicConfig(level=logging.INFO)
9+
fre_logger = logging.getLogger(__name__)
10+
11+
def get_components(yamlfile):
12+
"""Retrieve active pp components from the yaml
13+
14+
Arguments:
15+
yamlfile (str): Filepath to the yaml
16+
"""
17+
fre_logger.debug(f"Yaml file: {yamlfile}")
18+
components = []
19+
20+
with open(yamlfile) as file_:
21+
yaml_ = yaml.safe_load(file_)
22+
23+
for component in yaml_["postprocess"]["components"]:
24+
if component['switch'] is True:
25+
components.append(component["type"])
26+
27+
# we want to return a list, but some other scripts are expecting a space-separated string
28+
#return(components)
29+
return(" ".join(components))

flow.cylc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
{# The combined yaml is the definitive configuration source #}
4747
{% set YAML = EXPERIMENT + '.yaml' %}
4848

49+
{# Retrieve active pp components from the yaml #}
50+
{% set PP_COMPONENTS = YAML | get_components %}
51+
4952
[meta]
5053
title = "Postprocessing Example 1"
5154
description = """

0 commit comments

Comments
 (0)