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.

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[datetime] = None,
end: Optional[datetime] = None) -> None

View source on GitHub

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

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.
  • RuntimeError - 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:

  • RuntimeError - If no interval is active.

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.