Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ExternalTaskSensor execution date pattern #10883

Open
sahil-b-shah opened this issue Sep 11, 2020 · 6 comments
Open

Improve ExternalTaskSensor execution date pattern #10883

sahil-b-shah opened this issue Sep 11, 2020 · 6 comments
Labels
area:core-operators Operators, Sensors and hooks within Core Airflow good first issue kind:feature Feature Requests

Comments

@sahil-b-shah
Copy link

Currently in the ExternalTaskSensor there are two ways two set the execution date of a DAG/task the sensor is waiting on:

  • Provide the execution_delta which simply adds/subtracts a time value to/from the execution_date of the sensor itself
  • Provide the execution_date_fn which is a function that takes in just the execution_date and returns a manipulated one.

I believe that the correct way to go about handling the execution_date for the ExternalTaskSensor should be analogous to the way we handle it for other operators, such as the ExternalTaskMarker, or more relevantly, the TriggerDagRunOperator, which is an operator usually used in conjunction with the ExternalTaskSensor.

Specifically, we should remove the execution_delta parameter and replace it with a templated execution_date parameter. This not only covers the existing execution_delta use case through e.g. {{ execution_date - macros.timedelta(days=1) }}, but also provides more flexibility by enabling the benefits of templated parameters in general, such as pulling from xcoms, reading from DAG/operator params, using macros, etc. It also establishes the pattern that we see in the previously mentioned operators.

The proposed solution is also sufficient enough to remove the execution_date_fn because we can register custom macros to manipulate the execution date the same way as an execution_date_fn would. But I do realize we may want to keep it for backwards compatibility reasons.

First time contributor here so happy to implement/help with this to get some airflow OSS chops.

@boring-cyborg
Copy link

boring-cyborg bot commented Sep 11, 2020

Thanks for opening your first issue here! Be sure to follow the issue template!

@mik-laj mik-laj added the kind:feature Feature Requests label Sep 30, 2020
@eladkal eladkal added the area:core-operators Operators, Sensors and hooks within Core Airflow label Oct 10, 2021
@dmcochener
Copy link

I'd like to work on this one!

@eladkal
Copy link
Contributor

eladkal commented May 27, 2022

assigned!

dmcochener added a commit to dmcochener/airflow that referenced this issue May 27, 2022
@dmcochener
Copy link

dmcochener commented May 27, 2022

Current Work
Having issues getting the templating to work. Suggestions? @eladkal

@cedkoffeto
Copy link
Contributor

Hi @dmcochener am new here trying to help and learn
I was interested in this issue so I checked your work and it seems totally correct so my question is:
Is the templating not working only for the "execution_date" field ? or other previous templated fields are also not being rendered.

@dmcochener
Copy link

It’s just the “execution_date” field that is not templating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core-operators Operators, Sensors and hooks within Core Airflow good first issue kind:feature Feature Requests
Projects
None yet
Development

No branches or pull requests

5 participants