BasPH commented on a change in pull request #5815: [AIRFLOW-5210] Make finding 
template files more efficient

 File path: airflow/models/
 @@ -717,26 +717,27 @@ def prepare_template(self):
     def resolve_template_files(self):
         # Getting the content of files for template_field / template_ext
-        for attr in self.template_fields:
-            content = getattr(self, attr, None)
-            if content is None:
-                continue
-            elif isinstance(content, str) and \
-                    any([content.endswith(ext) for ext in self.template_ext]):
-                env = self.get_template_env()
-                try:
-                    setattr(self, attr, env.loader.get_source(env, content)[0])
-                except Exception as e:
-                    self.log.exception(e)
-            elif isinstance(content, list):
-                env = self.dag.get_template_env()
-                for i in range(len(content)):
-                    if isinstance(content[i], str) and \
-                            any([content[i].endswith(ext) for ext in 
-                        try:
-                            content[i] = env.loader.get_source(env, 
-                        except Exception as e:
-                            self.log.exception(e)
+        if self.template_ext:
 Review comment:
   The way I read it, this method iterates over all `template_fields` and if it 
finds a field value with an extension listed in `template_exts`, runs 
`env.loader.get_source(...)` and sets the result on the specific field.
   It indeed scans over all `template_fields` even if `template_exts` is empty, 
which doesn't make sense so I think this is a valid change.

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

Reply via email to