Cylc 8 with LFRic Rose stems and Jinja2 issues

Took a look into this myself,

I tracked the problem down to this line:

subtree = context.vars['target'][target_dets['platform']]

In this function Jinja2Globals/get_target_property.py::get_target_property.

After a bit of investigation it looks like context.vars is empty in certain situations. The offending call is coming from the macro called scripting. The target variable is set in this macro, however, it doesn’t seem to be present in context.vars. This might be a Jinja2 bug, I don’t know enough about @contextfunction to say for sure.

It appears that the target variable is present directly in the context variable so I managed to shift the error by making the following change:

 @contextfunction
 def get_target_property(context, target_dets, prop_path=None, compiler=None):
     if prop_path is not None:
         path_parts = prop_path.split('.')
     else:
         path_parts = [] 
-    subtree = context.vars['target'][target_dets['platform']]    
+    subtree = context['target'][target_dets['platform']]    
     while len(path_parts) > 0: