77
88# set up logging
99import logging
10- logging .basicConfig ()
11- logger = logging .getLogger (__name__ )
12- logger .setLevel (logging .INFO )
10+ logging .basicConfig (level = logging .INFO )
11+ fre_logger = logging .getLogger (__name__ )
1312
1413def form_task_parameters (grid_type , temporal_type , pp_components_str , yamlfile ):
1514 """Form the task parameter list based on the grid type, the temporal type,
@@ -20,7 +19,7 @@ def form_task_parameters(grid_type, temporal_type, pp_components_str, yamlfile):
2019 temporal_type (str): One of: temporal or static
2120 pp_component (str): all, or a space-separated list
2221"""
23- logger .debug (f"Desired pp components: { pp_components_str } " )
22+ fre_logger .debug (f"Desired pp components: { pp_components_str } " )
2423 pp_components = pp_components_str .split ()
2524 path_to_conf = os .path .dirname (os .path .abspath (__file__ )) + '/../app/remap-pp-components/rose-app.conf'
2625 node = metomi .rose .config .load (path_to_conf )
@@ -44,23 +43,21 @@ def form_task_parameters(grid_type, temporal_type, pp_components_str, yamlfile):
4443 if item == "env" or item == "command" :
4544 continue
4645 comp = regex_pp_comp .match (item ).group ()
47- logger .debug (f"Examining item '{ item } ' comp '{ comp } '" )
4846
4947 # skip if pp component not desired
50- logger .debug (f"Is { comp } in { pp_components } ?" )
5148 if comp in pp_components :
52- logger . debug ( 'Yes' )
49+ pass
5350 else :
54- logger .debug ('No' )
5551 continue
52+ fre_logger .debug (f"Examining item '{ item } ' and component '{ comp } '" )
5653
5754 # skip if grid type is not desired
5855 # some grid types (i.e. regrid-xy) have subtypes (i.e. 1deg, 2deg)
5956 # in remap-pp-components/rose-app.conf the grid type and subgrid is specified as "regrid-xy/1deg" (e.g.).
6057 # So we will strip off after the slash and the remainder is the grid type
6158 candidate_grid_type = re .sub ('\/.*' , '' , node .get_value (keys = [item , 'grid' ]))
6259 if candidate_grid_type != grid_type :
63- logger .debug (f"Skipping as not right grid; got '{ candidate_grid_type } ' and wanted '{ grid_type } '" )
60+ fre_logger .debug (f"Skipping as not right grid; got '{ candidate_grid_type } ' and wanted '{ grid_type } '" )
6461 continue
6562
6663 # filter static and temporal
@@ -69,23 +66,25 @@ def form_task_parameters(grid_type, temporal_type, pp_components_str, yamlfile):
6966 # if freq does not include "P0Y" => temporal
7067 freq = node .get_value (keys = [item , 'freq' ])
7168 if freq is not None and 'P0Y' in freq and temporal_type == 'temporal' :
72- logger .debug ("Skipping static when temporal is requested" )
69+ fre_logger .debug ("Skipping static when temporal is requested" )
7370 continue
7471 if temporal_type == "static" :
7572 if freq is not None and 'P0Y' not in freq :
76- logger .debug ("Skipping as static is requested, no P0Y here" , freq )
73+ fre_logger .debug ("Skipping as static is requested, no P0Y here" )
7774 continue
7875 elif (temporal_type == "temporal" ):
7976 if freq is not None and 'P0Y' in freq :
80- logger .debug ("Skipping as temporal is requested, P0Y here" , freq )
77+ fre_logger .debug ("Skipping as temporal is requested, P0Y here" )
8178 continue
8279 else :
8380 raise Exception ("Unknown temporal type:" , temporal_type )
8481
8582 # convert array in string form to array
8683 sources = ast .literal_eval (node .get_value (keys = [item , 'sources' ]))
87- results .extend (sources )
84+ for source in sources :
85+ results .append (source ['history_file' ])
86+ fre_logger .debug (f"Results so far: { results } " )
8887
8988 answer = sorted (list (set (results )))
90- logger .debug ("Returning string" + ', ' .join (answer ))
89+ fre_logger .debug (f "Returning string: { ', ' .join (answer )} " )
9190 return (', ' .join (answer ))
0 commit comments