airflow.providers.standard.sensors.asset

Classes

AssetEventTimeBound

A time bound that Airflow resolves during template rendering.

RunStart

Bound events by the Dag run's actual start time, including for backfills.

RunAfter

Bound events by the Dag run's earliest allowed start time.

LogicalDate

Bound events by the Dag run's logical date.

DataIntervalStart

Bound events by the start of the Dag run's data interval.

DataIntervalEnd

Bound events by the end of the Dag run's data interval.

AssetEventSensor

Wait for asset events matching the given filters to reach an expected count.

Module Contents

class airflow.providers.standard.sensors.asset.AssetEventTimeBound[source]

Bases: Protocol

A time bound that Airflow resolves during template rendering.

Implement resolve(context) to return a datetime or ISO string. Custom objects do not need to inherit this protocol. The result must stay fixed across reschedules of the same Dag run.

resolve(context)[source]

Return the event timestamp bound for this task’s runtime context.

class airflow.providers.standard.sensors.asset.RunStart(*, offset=timedelta(0))[source]

Bases: _ContextTimeBound

Bound events by the Dag run’s actual start time, including for backfills.

Parameters:

offset (datetime.timedelta) – Signed duration to add to dag_run.start_date.

class airflow.providers.standard.sensors.asset.RunAfter(*, offset=timedelta(0))[source]

Bases: _ContextTimeBound

Bound events by the Dag run’s earliest allowed start time.

This timestamp stays fixed when tasks are cleared. With after, an event at this timestamp is included, even if it triggered the run.

Parameters:

offset (datetime.timedelta) – Signed duration to add to dag_run.run_after.

class airflow.providers.standard.sensors.asset.LogicalDate(*, offset=timedelta(0))[source]

Bases: _ContextTimeBound

Bound events by the Dag run’s logical date.

Parameters:

offset (datetime.timedelta) – Signed duration to add to logical_date.

class airflow.providers.standard.sensors.asset.DataIntervalStart(*, offset=timedelta(0))[source]

Bases: _ContextTimeBound

Bound events by the start of the Dag run’s data interval.

Parameters:

offset (datetime.timedelta) – Signed duration to add to data_interval_start.

class airflow.providers.standard.sensors.asset.DataIntervalEnd(*, offset=timedelta(0))[source]

Bases: _ContextTimeBound

Bound events by the end of the Dag run’s data interval.

Parameters:

offset (datetime.timedelta) – Signed duration to add to data_interval_end.

class airflow.providers.standard.sensors.asset.AssetEventSensor(*, asset, after=None, before=None, ascending=True, limit=None, partition_key=None, partition_key_regexp_pattern=None, extra=None, expected_count=1, count_policy='minimum', process_result=None, **kwargs)[source]

Bases: airflow.providers.common.compat.sdk.BaseSensorOperator

Wait for asset events matching the given filters to reach an expected count.

The sensor fetches events of an asset, asset reference, or asset alias matching the supplied filters, optionally applies a process_result callable to transform, deduplicate or filter them, and succeeds once the resulting number of events satisfies expected_count.

At least one of after, before, partition_key, partition_key_regexp_pattern, or non-empty extra is required.

This sensor requires Apache Airflow 3.2+. The partition_key, partition_key_regexp_pattern and extra filters require Airflow 3.4+.

Parameters:
  • asset (airflow.sdk.definitions.asset.Asset | airflow.sdk.definitions.asset.AssetAlias | airflow.sdk.definitions.asset.AssetRef) – The Asset, ref(), or AssetAlias to wait on. It is declared as an inlet. A reference must resolve to an existing asset when the task starts. The target is static; event filters can be templated.

  • after (datetime.datetime | str | AssetEventTimeBound | collections.abc.Callable[..., datetime.datetime | str] | None) – Only include events at or after this timestamp.

  • before (datetime.datetime | str | AssetEventTimeBound | collections.abc.Callable[..., datetime.datetime | str] | None) – Only include events at or before this timestamp. Both bounds accept a datetime, ISO string, any object implementing AssetEventTimeBound, or a template callable accepting context and jinja_env. Airflow resolves them before polling. Custom callables must return stable bounds across reschedules.

  • ascending (bool) – Whether events are returned in ascending timestamp order.

  • limit (int | None) – Positive maximum number of events to fetch, before applying process_result.

  • partition_key (str | None) – Filter by exact partition key match.

  • partition_key_regexp_pattern (str | None) – Filter by partition key regexp pattern.

  • extra (dict[str, str] | None) – Filter by key/value pairs contained in the event extra.

  • expected_count (int) – The non-negative number of processed events required to succeed. Defaults to 1. If process_result is omitted, limit must not be smaller, or must be greater with the "exact" policy.

  • count_policy (Literal['minimum', 'exact']) – "minimum" (the default) waits for at least expected_count events; "exact" requires exactly that number. To check for no events, use "exact" and zero.

  • process_result (collections.abc.Callable[[list[airflow.sdk.execution_time.comms.AssetEventResult]], list[Any]] | None) – A callable applied to the fetched events before the count check, to transform, deduplicate or filter them. It receives the list of asset events and must return a list. It runs on every poke, so it should be idempotent and free of side-effects. Its return value must be JSON-serializable to be pushed into XCom.

template_fields: collections.abc.Sequence[str] = ('partition_key', 'partition_key_regexp_pattern', 'extra', 'after', 'before')[source]
asset[source]
after = None[source]
before = None[source]
ascending = True[source]
limit = None[source]
partition_key = None[source]
partition_key_regexp_pattern = None[source]
extra = None[source]
expected_count = 1[source]
count_policy = 'minimum'[source]
process_result = None[source]
poke(context)[source]

Override when deriving this class.

Was this entry helpful?