airflow.providers.standard.sensors.asset¶
Classes¶
A time bound that Airflow resolves during template rendering. |
|
Bound events by the Dag run's actual start time, including for backfills. |
|
Bound events by the Dag run's earliest allowed start time. |
|
Bound events by the Dag run's logical date. |
|
Bound events by the start of the Dag run's data interval. |
|
Bound events by the end of the Dag run's data interval. |
|
Wait for asset events matching the given filters to reach an expected count. |
Module Contents¶
- class airflow.providers.standard.sensors.asset.AssetEventTimeBound[source]¶
Bases:
ProtocolA 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.
- class airflow.providers.standard.sensors.asset.RunStart(*, offset=timedelta(0))[source]¶
Bases:
_ContextTimeBoundBound 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:
_ContextTimeBoundBound 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:
_ContextTimeBoundBound 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:
_ContextTimeBoundBound 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:
_ContextTimeBoundBound 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.BaseSensorOperatorWait 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_resultcallable to transform, deduplicate or filter them, and succeeds once the resulting number of events satisfiesexpected_count.At least one of
after,before,partition_key,partition_key_regexp_pattern, or non-emptyextrais required.This sensor requires Apache Airflow 3.2+. The
partition_key,partition_key_regexp_patternandextrafilters require Airflow 3.4+.- Parameters:
asset (airflow.sdk.definitions.asset.Asset | airflow.sdk.definitions.asset.AssetAlias | airflow.sdk.definitions.asset.AssetRef) – The
Asset,ref(), orAssetAliasto 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 acceptingcontextandjinja_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_resultis omitted,limitmust not be smaller, or must be greater with the"exact"policy.count_policy (Literal['minimum', 'exact']) –
"minimum"(the default) waits for at leastexpected_countevents;"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]¶