potiuk commented on a change in pull request #21731:
URL: https://github.com/apache/airflow/pull/21731#discussion_r820698842
##########
File path: airflow/models/taskinstance.py
##########
@@ -2394,24 +2394,89 @@ class SimpleTaskInstance:
Used to send data between processes via Queues.
"""
- def __init__(self, ti: TaskInstance):
- self._dag_id: str = ti.dag_id
- self._task_id: str = ti.task_id
- self._run_id: str = ti.run_id
- self._start_date: datetime = ti.start_date
- self._end_date: datetime = ti.end_date
- self._try_number: int = ti.try_number
- self._state: str = ti.state
- self._executor_config: Any = ti.executor_config
+ def __init__(
+ self,
+ dag_id: str,
+ task_id: str,
+ run_id: str,
+ start_date: datetime,
+ end_date: datetime,
+ try_number: int,
+ state: str,
+ executor_config: Any,
+ pool: str,
+ queue: str,
+ key: TaskInstanceKey,
+ run_as_user: Optional[str] = None,
+ priority_weight: Optional[int] = None,
+ ):
+ self._dag_id: str = dag_id
+ self._task_id: str = task_id
+ self._run_id: str = run_id
+ self._start_date: datetime = start_date
+ self._end_date: datetime = end_date
+ self._try_number: int = try_number
+ self._state: str = state
+ self._executor_config: Any = executor_config
self._run_as_user: Optional[str] = None
- if hasattr(ti, 'run_as_user'):
- self._run_as_user = ti.run_as_user
- self._pool: str = ti.pool
+ self._run_as_user = run_as_user
+ self._pool: str = pool
self._priority_weight: Optional[int] = None
- if hasattr(ti, 'priority_weight'):
- self._priority_weight = ti.priority_weight
- self._queue: str = ti.queue
- self._key = ti.key
+ self._priority_weight = priority_weight
+ self._queue: str = queue
+ self._key = key
+
+ def __eq__(self, other):
+ if isinstance(other, self.__class__):
+ return self.__dict__ == other.__dict__
+ return NotImplemented
+
+ @classmethod
+ def from_ti(cls, ti: TaskInstance):
Review comment:
Good Idea.
--
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]