You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/11/17 08:54:12 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #19242: Populate TI from callback request's SimpleTaskInstance

uranusjr commented on a change in pull request #19242:
URL: https://github.com/apache/airflow/pull/19242#discussion_r751023868



##########
File path: airflow/models/taskinstance.py
##########
@@ -705,6 +705,32 @@ def error(self, session=None):
         session.merge(self)
         session.commit()
 
+    def refresh_from_instance(self, source: Union["SimpleTaskInstance", "TaskInstance"]) -> None:
+        self.start_date = source.start_date
+        self.end_date = source.end_date
+        self.duration = source.duration
+        self.state = source.state
+        # Get the raw value of try_number column, don't read through the
+        # accessor here otherwise it will be incremented by one already.
+        self.try_number = source._try_number
+        self.max_tries = source.max_tries
+        self.hostname = source.hostname
+        self.unixname = source.unixname
+        self.job_id = source.job_id
+        self.pool = source.pool
+        self.pool_slots = source.pool_slots or 1
+        self.queue = source.queue
+        self.priority_weight = source.priority_weight
+        self.operator = source.operator
+        self.queued_dttm = source.queued_dttm
+        self.queued_by_job_id = source.queued_by_job_id
+        self.pid = source.pid
+        self.executor_config = source.executor_config
+        self.external_executor_id = source.external_executor_id
+        self.trigger_id = source.trigger_id
+        self.next_method = source.next_method
+        self.next_kwargs = source.next_kwargs

Review comment:
       Not particularly a fan since this makes type checking and autocompletion much more difficult. But considering we’re going to drop 3.6 pretty soon and be able to use dataclasses (available in stdlib for 3.7+), there will be another way to keep static checks work well while simplifying the runtime implementation.




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