ephraimbuddy commented on code in PR #57853:
URL: https://github.com/apache/airflow/pull/57853#discussion_r2518027414


##########
airflow-core/src/airflow/serialization/serialized_objects.py:
##########
@@ -1862,10 +1878,37 @@ def _is_excluded(cls, var: Any, attrname: str, op: 
DAGNode):
         # Check if value matches client_defaults (hierarchical defaults 
optimization)
         if cls._matches_client_defaults(var, attrname):
             return True
-        schema_defaults = cls.get_schema_defaults("operator")
 
+        # for const fields, we should always be excluded when False, 
regardless of client_defaults
+        const_fields = cls.get_operator_const_fields()

Review Comment:
   While this is cached, it's called in every _is_excluded check, I wonder if 
we can do a class level caching:
   ```
   if not hasattr(cls, '_const_fields'):
       cls._const_fields = cls._compute_const_fields()
   ```



##########
airflow-core/src/airflow/serialization/serialized_objects.py:
##########
@@ -1707,6 +1707,22 @@ def set_task_dag_references(task: SerializedOperator | 
MappedOperator, dag: Seri
             # Bypass set_upstream etc here - it does more than we want
             dag.task_dict[task_id].upstream_task_ids.add(task.task_id)
 
+    @classmethod
+    @lru_cache(maxsize=1)  # Only one type: "operator"
+    def get_operator_const_fields(cls) -> set[str]:

Review Comment:
   We probably should add a doc string for this. 
   
   
       



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to