dlt.extract.incremental.context
Time interval context for external schedulers.
TAnyTimeInterval
A (start, end) interval as either a TTimeInterval or a plain datetime tuple.
TimeIntervalContext Objects
@configspec
class TimeIntervalContext(ContainerInjectableContext)
Active time interval from an external scheduler.
allow_external_schedulers
When True, enables allow_external_schedulers on incrementals that left it unset.
interval
@property
def interval() -> Optional[TTimeInterval]
Resolved interval as (start, end) datetime tuple, or None.
get_interval_context
def get_interval_context() -> Optional[TimeIntervalContext]
Get the active interval context from Container, or None.
_IntervalAccessor Objects
class _IntervalAccessor()
Callable accessor for the active interval. Exposed as dlt.current.interval.
update
def update(*,
start: Optional[datetime] = None,
end: Optional[datetime] = None) -> None
Override start and/or end, preserving the other bound.
is_empty
@property
def is_empty() -> bool
True when no interval is active or it has zero length (manual and event runs).
apply_lag
def apply_lag(trigger: str,
count: int = 1,
lag_end: bool = False) -> "_IntervalAccessor"
Lags the active interval start (or end) by count trigger ticks into the past.
The bound snaps to the trigger tick grid: count=0 floors it to the
latest tick, negative count moves it into the future.
Arguments:
triggerstr - Aschedule:orevery:trigger, or a bare cron expression.countint - Number of ticks (orevery:periods) to lag, negative moves into the future. Defaults to 1.lag_endbool - WhenTrue, adjusts the end instead of the start.
Returns:
The accessor itself, so calls can be chained.
Raises:
ValueError- If the adjusted interval is empty or negative.RuntimeError- If no interval is active.
apply_full_days
def apply_full_days() -> "_IntervalAccessor"
Widens the active interval to full days: start floored to midnight, end extended to the next midnight, each in its own timezone.
Returns:
The accessor itself, so calls can be chained.
Raises:
RuntimeError- If no interval is active.