dstandish commented on a change in pull request #19242:
URL: https://github.com/apache/airflow/pull/19242#discussion_r739613535
##########
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:
What do you think about something like this?
```suggestion
source_dict = source.__dict__
self.try_number = source_dict.pop('_try_number')
self.pool_slots = source_dict.pop('pool_slots', 1)
for k, v in source_dict.items():
setattr(self, k, v)
```
--
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]