nathadfield commented on code in PR #61448:
URL: https://github.com/apache/airflow/pull/61448#discussion_r2894605333


##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -1970,30 +1970,46 @@ def _create_dagruns_for_partitioned_asset_dags(self, 
session: Session) -> set[st
 
             partition_dag_ids.add(apdr.target_dag_id)
             run_after = timezone.utcnow()
-            dag_run = dag.create_dagrun(
-                run_id=DagRun.generate_run_id(
-                    run_type=DagRunType.ASSET_TRIGGERED, logical_date=None, 
run_after=run_after
-                ),
-                logical_date=None,
-                data_interval=None,
-                partition_key=apdr.partition_key,
-                run_after=run_after,
-                run_type=DagRunType.ASSET_TRIGGERED,
-                triggered_by=DagRunTriggeredByType.ASSET,
-                state=DagRunState.QUEUED,
-                creating_job_id=self.job.id,
-                session=session,
-            )
-            asset_events = session.scalars(
-                select(AssetEvent).where(
-                    PartitionedAssetKeyLog.asset_partition_dag_run_id == 
apdr.id,
-                    PartitionedAssetKeyLog.asset_event_id == AssetEvent.id,
+            try:
+                dag_run = dag.create_dagrun(
+                    run_id=DagRun.generate_run_id(
+                        run_type=DagRunType.ASSET_TRIGGERED, 
logical_date=None, run_after=run_after
+                    ),
+                    logical_date=None,
+                    data_interval=None,
+                    partition_key=apdr.partition_key,
+                    run_after=run_after,
+                    run_type=DagRunType.ASSET_TRIGGERED,
+                    triggered_by=DagRunTriggeredByType.ASSET,
+                    state=DagRunState.QUEUED,
+                    creating_job_id=self.job.id,
+                    session=session,
                 )
-            )
-            dag_run.consumed_asset_events.extend(asset_events)
-            session.flush()
-            apdr.created_dag_run_id = dag_run.id
-            session.flush()
+                asset_events = session.scalars(
+                    select(AssetEvent).where(
+                        PartitionedAssetKeyLog.asset_partition_dag_run_id == 
apdr.id,
+                        PartitionedAssetKeyLog.asset_event_id == AssetEvent.id,
+                    )
+                )
+                dag_run.consumed_asset_events.extend(asset_events)
+                session.flush()
+                apdr.created_dag_run_id = dag_run.id
+                session.flush()
+            except BundleVersionUnavailable:
+                self.log.warning(
+                    "Bundle version not yet available for partitioned 
asset-triggered DAG %s. "
+                    "Run will be created on next evaluation cycle.",
+                    apdr.target_dag_id,
+                )
+            except Exception:

Review Comment:
   Good catch. I've added except `OperationalError: raise` before each except 
Exception block so DB errors propagate correctly. Fixed in the latest push.  



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