potiuk commented on code in PR #30641:
URL: https://github.com/apache/airflow/pull/30641#discussion_r1166790878
##########
airflow/models/xcom_arg.py:
##########
@@ -332,7 +341,23 @@ def get_task_map_length(self, run_id: str, *, session:
Session) -> int | None:
@provide_session
def resolve(self, context: Context, session: Session = NEW_SESSION) -> Any:
- ti = context["ti"]
+ from airflow.models.taskinstance import TaskInstance
+
+ context_ti = context["ti"]
+ if isinstance(context_ti, TaskInstance):
+ ti = context_ti
+ else:
+ ti = (
+ session.query(TaskInstance)
+ .filter_by(
+ dag_id=context_ti.dag_id,
+ task_id=context_ti.task_id,
+ run_id=context_ti.run_id,
+ map_index=context_ti.map_index,
+ )
+ .one()
+ )
+
Review Comment:
Prepend it with `assert(isinstance(ti, TaskInstance), "Wait for AIP-44
implementation to complete")` -> this will satisfy MyPy and will allow us to
implement AIP-44 veriant when our tests will start failing with the assert.
(and assert will be optimized away).
--
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]