git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing execution_date inside a function


If you look at the source code for the TimeDeltaSensor, it's about 10 lines
of code. You can easily derive `BaseSensorOperator` and write your own
DynamicTimeDeltaSensor that has its own logic, or one that receives a
callable `are_conditions_met(execution_date)` that receives the execution
date and returns True/False.

On Fri, Jun 8, 2018 at 2:04 PM Pedro Machado <pedro@xxxxxxxxxxxxxx> wrote:

> I am using TimeDeltaSensor and would like to pass a delta value that
> depends on the execution_date. The delta depends on the day of the week of
> the execution_date.
>
>         wait_for_data = TimeDeltaSensor(
>             task_id="wait_for_data",
>             delta=get_delta(),
>             poke_interval=60 * 10,
>             timeout=60 * 60 * (24 * 7 + 2),
>             retries=10,
>             dag=dag)
>
> Is it possible to access the execution_date from inside the get_delta
> function? How?
>
> Thanks,
>
> Pedro
>