hussein-awala commented on code in PR #70225: URL: https://github.com/apache/airflow/pull/70225#discussion_r4393349868
########## providers/standard/docs/sensors/asset.rst: ########## @@ -0,0 +1,163 @@ + .. Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + .. http://www.apache.org/licenses/LICENSE-2.0 + + .. Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + + + +.. _howto/sensor:AssetEventSensor: + +AssetEventSensor +================ + +Use the :class:`~airflow.providers.standard.sensors.asset.AssetEventSensor` to wait for +asset events matching a set of filters to reach an expected count. + +Use this sensor when an already-running Dag needs an asset between tasks. For example, a +daily consumer can run its preparation tasks immediately, then wait for another Dag to +produce the partition for its own data interval. Moving that dependency to an asset schedule +would change when the entire Dag starts and the data interval used by the consumer. + +The sensor declares its target as an inlet, so the dependency is visible in asset lineage +without changing the Dag's schedule. It reads events through ``context["inlet_events"]``. + +.. note:: + + This sensor requires **Apache Airflow 3.2+**. The ``partition_key``, + ``partition_key_regexp_pattern`` and ``extra`` filters require + **Apache Airflow 3.4+**. + +When to use a schedule instead +------------------------------ + +If the dependency does not need to sit in the middle of a run, a schedule is +usually a better fit. See +:doc:`apache-airflow:authoring-and-scheduling/asset-scheduling` for details. + +* Schedule the Dag on the asset when the whole run can wait for it. +* Use ``AssetAndTimeSchedule`` (Airflow 3.4+) when a time-scheduled run needs + the asset before it starts. +* Use a partitioned asset timetable with ``RollupMapper`` to wait for every + partition in a window. + +Use this sensor when some tasks should run immediately and only later tasks +depend on the asset. Here, ``prepare`` starts as soon as the run does, and only +``process`` waits for the partition (``wait_for_partition_events`` is defined +:ref:`below <howto/sensor:AssetEventSensor:filtering>`): Review Comment: I like this section, thanks! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
