Skip to content

TimeDeltaSensor - delta templated - #71314

Open
raphaelauv wants to merge 3 commits into
apache:mainfrom
raphaelauv:feat/TimeDeltaSensor_templated_delta
Open

TimeDeltaSensor - delta templated#71314
raphaelauv wants to merge 3 commits into
apache:mainfrom
raphaelauv:feat/TimeDeltaSensor_templated_delta

Conversation

@raphaelauv

@raphaelauv raphaelauv commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

this will allow to put a delta templated value

similar than this PR #70480

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Aug 13, 2026
@raphaelauv
raphaelauv force-pushed the feat/TimeDeltaSensor_templated_delta branch from 7c7e88f to e1ad87d Compare August 18, 2026 06:23
value = self.delta
if isinstance(value, timedelta):
return value
return timedelta(minutes=int(value))

@ashb ashb Aug 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you choose minutes for this (rather than days, or seconds) -- and why int, not float?

Either way, accepting this needs to be documented.

Also, although it's not commonly known, there is a way of expressing intervals/periods/delta with Pendulum via ISO8061:

ISO 8601 Durations are expressed using the following format, where (n) is replaced by the value for each of the date and time elements that follow the (n):

P(n)Y(n)M(n)DT(n)H(n)M(n)S

Where:

P is the duration designator (referred to as "period"), and is always placed at the beginning of the duration.
Y is the year designator that follows the value for the number of years.
M is the month designator that follows the value for the number of months.
W is the week designator that follows the value for the number of weeks.
D is the day designator that follows the value for the number of days.
T is the time designator that precedes the time components.
H is the hour designator that follows the value for the number of hours.
M is the minute designator that follows the value for the number of minutes.
S is the second designator that follows the value for the number of seconds.

For example:

P3Y6M4DT12H30M5S

Represents a duration of three years, six months, four days, twelve hours, thirty minutes, and five seconds.

>>> import pendulum
>>> pendulum.parse("P3Y6M4DT12H30M5S")
Duration(years=3, months=6, days=4, hours=12, minutes=30, seconds=5)
>>> pendulum.parse("PT6000S")
Duration(hours=1, minutes=40)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minutes , because it was the existing choice of the WaitSensor

https://github.com/apache/airflow/pull/70480/changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you talk about pendum Duration ?

the operator TimeDeltaSensor accept a datetime.timedelta

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you talk about pendum Duration ?

Durations/ISO8601 Periods can be represented as plain text, and so are easy to handle via templates.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay I could add this feature in a second PR

@seanghaeli

Copy link
Copy Markdown
Contributor

Looks good, add an error path test similar to what #70480 has

@raphaelauv
raphaelauv force-pushed the feat/TimeDeltaSensor_templated_delta branch 2 times, most recently from 5226b49 to 2bd9ae9 Compare August 19, 2026 08:57
@raphaelauv

Copy link
Copy Markdown
Contributor Author

the CI always block on Install SVN , I tried two times to re-run it by rebasing and force-push

any idea ?

@raphaelauv
raphaelauv force-pushed the feat/TimeDeltaSensor_templated_delta branch from 2bd9ae9 to c6baa3c Compare August 19, 2026 14:01
@raphaelauv

Copy link
Copy Markdown
Contributor Author

CI is green :) @ashb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants