Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Jinja2Filters/get_analysis_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ def __init__(self, name, config, experiment_components, experiment_starting_date
logger.debug(f"{name}: initializing AnalysisScript instance")

# Skip if configuration wants to skip it
self.switch = config["workflow"]["analysis_on"]
# analysis_on is an optional key that is True (by default)
# if not defined in the YAML
if "analysis_on" in config["workflow"]:
self.switch = config["workflow"]["analysis_on"]
else:
self.switch = True

if self.switch is False:
return

Expand Down
29 changes: 22 additions & 7 deletions Jinja2Filters/get_components.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Return a space separated string of components to be post-processed.
"""
import logging
import yaml

Expand All @@ -6,20 +9,32 @@
fre_logger = logging.getLogger(__name__)

def get_components(yamlfile):
"""Retrieve active pp components from the yaml
"""
Retrieve active pp components from the yaml

Arguments:
yamlfile (str): Filepath to the yaml
"""
fre_logger.debug(f"Yaml file: {yamlfile}")
components = []
:param yamlfile: Filepath to the yaml
:type yamlfile: str
:return: Space separated string of components to be post-processed
:rtype: str
"""
fre_logger.debug("Yaml file: %s", yamlfile)

components = []
with open(yamlfile) as file_:
yaml_ = yaml.safe_load(file_)

for component in yaml_["postprocess"]["components"]:
if component['postprocess_on'] is True:
# if postprocess_on key exists, evaluate value
if "postprocess_on" in component:
if component['postprocess_on'] is True:
components.append(component["type"])
fre_logger.info("%s to be post-processed", component["type"])
else:
fre_logger.info("%s will NOT be post-processed", component["type"])
else:
# default is True, if not set
components.append(component["type"])
fre_logger.info("%s to be post-processed", component["type"])

# we want to return a list, but some other scripts are expecting a space-separated string
#return(components)
Expand Down
4 changes: 2 additions & 2 deletions Jinja2Filters/tests/get_components_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from Jinja2Filters import get_components

CONFIG = {'postprocess': {'components': [{'postprocess_on': True, 'type': 'comp1'},
{'postprocess_on': True, 'type': 'comp2'},
{'postprocess_on': False, 'type': 'comp3'}]}}
{'type': 'comp2'},
{'postprocess_on': False, 'type': 'comp3'}]}}

def test_get_components(tmp_path):
"""Give 2 active components and one inactive component, expect the first two back"""
Expand Down
4 changes: 0 additions & 4 deletions for_gh_runner/yaml_workflow/local_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ postprocess:
pp_grid_spec: *GRID_SPEC96_LOCAL
switches:
clean_work: True
do_refinediag: False
do_atmos_plevel_masking: True
do_preanalysis: False
do_analysis: False
do_analysis_only: False
4 changes: 0 additions & 4 deletions for_gh_runner/yaml_workflow/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@ postprocess:
pp_grid_spec: *GRID_SPEC96
switches:
clean_work: True
do_refinediag: False
do_atmos_plevel_masking: True
do_preanalysis: False
do_analysis: False
do_analysis_only: False
Loading