ashb commented on code in PR #57631:
URL: https://github.com/apache/airflow/pull/57631#discussion_r2526641608


##########
providers/standard/src/airflow/providers/standard/operators/python.py:
##########
@@ -488,8 +488,30 @@ def execute(self, context: Context) -> Any:
         serializable_keys = set(self._iter_serializable_context_keys())
         new = {k: v for k, v in context.items() if k in serializable_keys}
         serializable_context = cast("Context", new)
+        # Store bundle_path for subprocess execution
+        self._bundle_path = self._get_bundle_path_from_context(context)
         return super().execute(context=serializable_context)
 
+    def _get_bundle_path_from_context(self, context: Context) -> Path | None:
+        """
+        Extract bundle_path from the task instance's bundle_instance.
+
+        :param context: The task execution context
+        :return: Path to the bundle root directory, or None if not in a bundle
+        """
+        if not AIRFLOW_V_3_0_PLUS:
+            return None
+
+        # In Airflow 3.x, the RuntimeTaskInstance has a bundle_instance 
attribute
+        # that contains the bundle information including its path
+        ti = context.get("ti")
+        if ti and hasattr(ti, "bundle_instance"):
+            bundle_instance = ti.bundle_instance
+            if bundle_instance and hasattr(bundle_instance, "path"):
+                return Path(bundle_instance.path)

Review Comment:
   Why bother makin it a path object when all we do is stringify it



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