forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix type of "moment" when running an e2e example for deferred TI (apa…
…che#45030) While trying to run an e2e example of a task that defers and then launches a trigger: ``` from airflow import DAG from airflow.providers.standard.sensors.date_time import DateTimeSensorAsync from airflow.utils import timezone import datetime with DAG( dag_id="demo_deferred", schedule=None, catchup=False, ) as dag: DateTimeSensorAsync( task_id="async", target_time=str(timezone.utcnow() + datetime.timedelta(seconds=3)), poke_interval=60, timeout=600, ) ``` I realised that the "moment" inside "trigger_kwargs" is of `pendulum.DateTime` type, and since we have a "dict[str, ANY]`, defined here: https://github.com/apache/airflow/blob/main/airflow/api_fastapi/execution_api/datamodels/taskinstance.py#L82 on its datamodel (we cant really have a `UtcDateTime` for one specific field, like we do [here](https://github.com/apache/airflow/blob/main/airflow/api_fastapi/execution_api/datamodels/taskinstance.py#L57C15-L57C26)), it fails to match the type defined in the `Trigger` table which is datetime. So, I have added a "before" validator that checks for the type being string and if it is a string, translates it to a datetime object.
- Loading branch information
1 parent
ef004de
commit fc7d983
Showing
3 changed files
with
19 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters