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 2022/07/07 07:10:34 UTC
[GitHub] [airflow] eladkal commented on issue #20116: BaseOperator.get_task_instances is broken due to order by TaskInstance.execution_date
eladkal commented on issue #20116:
URL: https://github.com/apache/airflow/issues/20116#issuecomment-1177177172
Duplicate of https://github.com/apache/airflow/issues/21656 issue was fixed in https://github.com/apache/airflow/pull/21705
Noting that the reproduce example provided will not work even now.
`task.get_task_instances(start_date="20211201", end_date="20211201")` is wrong. The values can not be strings.
https://github.com/apache/airflow/blob/c23b31cd786760da8a8e39ecbcf2c0d31e50e594/airflow/models/baseoperator.py#L1242-L1243
The DAG
```
import pendulum
from airflow.operators.dummy import DummyOperator
from airflow import DAG
dag = DAG(
"20116",
start_date=pendulum.parse("20211201"),
)
with dag:
task1 = DummyOperator(task_id="test_task")
task = dag.get_task("test_task")
task.get_task_instances(start_date="20211201", end_date="20211201")
```
Will yield:
```
Broken DAG: [/files/dags/20116.py] Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/type_api.py", line 1487, in process
return process_param(value, dialect)
File "/opt/airflow/airflow/utils/sqlalchemy.py", line 68, in process_bind_param
raise TypeError('expected datetime.datetime, not ' + repr(value))
TypeError: expected datetime.datetime, not '20211201'
```
You can change it to:
`task.get_task_instances(start_date=pendulum.parse("20211201"), end_date=pendulum.parse("20211201"))`
--
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