yuqian90 commented on a change in pull request #7324: [AIRFLOW-6704] Copy 
common TaskInstance attributes from Task
URL: https://github.com/apache/airflow/pull/7324#discussion_r376715983
 
 

 ##########
 File path: airflow/models/taskinstance.py
 ##########
 @@ -61,6 +61,21 @@
 from airflow.utils.timeout import timeout
 
 
+def refresh_from_task(ti, task, pool_override=None):
+    """
+    Copy the necessary attributes of a TaskInstance using its task.
+    """
+    ti.queue = task.queue
+    ti.pool = pool_override or task.pool
+    ti.pool_slots = task.pool_slots
+    ti.priority_weight = task.priority_weight_total
+    ti.run_as_user = task.run_as_user
+    ti.max_tries = task.retries
+    ti.run_as_user = task.run_as_user
+    ti.executor_config = task.executor_config
 
 Review comment:
   I found the PR by @dimberman . 
https://github.com/apache/airflow/pull/5926/files
   
   I think the issue was that @dimberman  wants ``TaskInstance`` to use the 
latest ``executor_config`` from the `Task`, instead of reading it from db. 
Since no where else we set `refresh_executor_config` to True, so what I'm doing 
here will not affect the current behavior for `executor_config`.
   
   However, that said, it's a little strange there's a 
`refresh_executor_config` default to `False` but not being used anywhere. 
Should we just remove the `refresh_executor_config` flag since that's always 
what we are doing? But that's not related to what I'm doing here. Just a 
suggestion.

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


With regards,
Apache Git Services

Reply via email to