devnp2007 commented on code in PR #77023:
URL: https://github.com/apache/airflow/pull/77023#discussion_r4740017940


##########
airflow-core/src/airflow/models/deadline.py:
##########
@@ -267,11 +285,261 @@ def prune_deadlines(cls, *, session: Session, 
conditions: dict[Mapped, Any]) ->
 
         return deleted_count
 
+    @property
+    def is_late(self) -> bool:
+        return self.missed and self.resolved_at is None
+
+    @classmethod
+    def _discover_asset_partition_keys(cls, *, session: Session, asset_id: 
int) -> list[str | None]:
+        from airflow.models.asset import AssetEvent
+
+        keys: list[str] = []
+        seen: set[str] = set()
+        event_keys = session.scalars(
+            select(AssetEvent.partition_key)

Review Comment:
   Good catch testing this in Breeze @seanghaeli—querying historical 
`AssetEvent.partition_key` rows was definitely the wrong approach.
   
   I've updated `_discover_asset_partition_keys()` in `745e0f4c142` to derive 
expected partition keys from the producer's timetable for the target 
`deadline_time` window instead:
   - **`CronPartitionTimetable`:** resolves the expected key for the window via 
`_align_to_prev(target_dt)` + `_get_partition_info()`, so a key that never 
arrives still gets a scheduled deadline and previously delivered keys are not 
re-scheduled on subsequent ticks.
   - **`PartitionedAssetTimetable`:** recursively resolves upstream keys (with 
cycle protection) and maps them through the configured `PartitionMapper`.
   - **Fallbacks:** falls back to `[None]` for unpartitioned producers, and 
checks static consumer mappers (`AllowedKeyMapper` / `RollupMapper`) for 
external assets without a producer.
   
   Added 4 unit tests in `test_asset_deadline.py` covering never-arrived 
partitions, historical partitions not re-scheduling, 
`PartitionedAssetTimetable` mapping, and unpartitioned fallback.



-- 
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]

Reply via email to