You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "rkarish (via GitHub)" <gi...@apache.org> on 2023/02/03 04:48:34 UTC

[GitHub] [airflow] rkarish commented on a diff in pull request #29034: Add functionality for operators to template all eligible fields (apac…

rkarish commented on code in PR #29034:
URL: https://github.com/apache/airflow/pull/29034#discussion_r1095351968


##########
airflow/models/baseoperator.py:
##########
@@ -1184,7 +1199,23 @@ def render_template_fields(
         """
         if not jinja_env:
             jinja_env = self.get_template_env()
-        self._do_render_template_fields(self, self.template_fields, context, jinja_env, set())
+
+        if self.template_all_fields:
+            template_fields = (
+                {key for key in self.__dict__.keys() if isinstance(getattr(self, key), str)}
+                - set(BaseOperator.__dict__.keys())
+                - set(MappedOperator.__dict__.keys())
+            )

Review Comment:
   For this if I only included the attributes from `BaseOperator` then some attributes get leaked through from the `MappedOperator`. This is the result of test when not removing additional attributes from `MappedOperator`.
   
   ```{'weight_rule', 'arg3', 'queue', 'trigger_rule', 'owner', 'arg1', 'arg2', 'task_id'}```
   
   With both all the attributes belonging to the parent classes are excluded.
   
   ```{'arg1', 'arg2', 'arg3'}```



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org