Skip to main content
Version: devel

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)

View source on GitHub

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]

View source on GitHub

Resolved interval as (start, end) datetime tuple, or None.

timezone​

@property
def timezone() -> tzinfo

View source on GitHub

Timezone both bounds are in, which is the context timezone when there is no interval.

get_interval_context​

def get_interval_context() -> Optional[TimeIntervalContext]

View source on GitHub

Get the active interval context from Container, or None.

_IntervalAccessor Objects​

class _IntervalAccessor()

View source on GitHub

Callable accessor for the active interval. Exposed as dlt.current.interval.

update​

def update(*,
start: Optional[TAnyDateTime] = None,
end: Optional[TAnyDateTime] = None) -> None

View source on GitHub

Override start and/or end, preserving the other bound.

Each new bound is taken into the interval's timezone: naive values (including plain dates and ISO strings without an offset) are read as wall clock there, aware values are converted. Both ends of the interval keep a single timezone.

Arguments:

  • start Optional[TAnyDateTime] - New start of the interval.
  • end Optional[TAnyDateTime] - New end of the interval.

Raises:

  • IntervalNotAvailable - If no interval is active.

timezone​

@property
def timezone() -> Optional[tzinfo]

View source on GitHub

Timezone of the active interval, or None when no interval is active.

is_empty​

@property
def is_empty() -> bool

View source on GitHub

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"

View source on GitHub

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:

  • trigger str - A schedule: or every: trigger, or a bare cron expression.
  • count int - Number of ticks (or every: periods) to lag, negative moves into the future. Defaults to 1.
  • lag_end bool - When True, 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.
  • IntervalNotAvailable - If no interval is active.

apply_full_days​

def apply_full_days() -> "_IntervalAccessor"

View source on GitHub

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:

  • IntervalNotAvailable - If no interval is active.

timezone​

def timezone() -> tzinfo

View source on GitHub

The context timezone. UTC unless the run declares one through TimezoneContext or DLT_INTERVAL_TIMEZONE.

Unlike dlt.current.interval.timezone, which describes the zone the interval bounds happen to carry, this is the zone dlt actually writes values in and is never None.

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.