ashb commented on code in PR #57631:
URL: https://github.com/apache/airflow/pull/57631#discussion_r2526642434
##########
providers/standard/src/airflow/providers/standard/operators/python.py:
##########
@@ -565,6 +587,18 @@ def _execute_python_callable_in_subprocess(self,
python_path: Path):
if self.env_vars:
env_vars.update(self.env_vars)
+ # Add bundle_path to PYTHONPATH for subprocess to import DAG
bundle modules
+ if hasattr(self, "_bundle_path") and self._bundle_path:
+ bundle_path_str = str(self._bundle_path)
Review Comment:
```suggestion
```
##########
providers/standard/src/airflow/providers/standard/operators/python.py:
##########
@@ -565,6 +587,18 @@ def _execute_python_callable_in_subprocess(self,
python_path: Path):
if self.env_vars:
env_vars.update(self.env_vars)
+ # Add bundle_path to PYTHONPATH for subprocess to import DAG
bundle modules
+ if hasattr(self, "_bundle_path") and self._bundle_path:
+ bundle_path_str = str(self._bundle_path)
+ existing_pythonpath = env_vars.get("PYTHONPATH", "")
+ path_separator = ";" if os.name == "nt" else ":"
+
+ if existing_pythonpath:
+ # Prepend bundle_path to existing PYTHONPATH
+ env_vars["PYTHONPATH"] =
f"{bundle_path_str}{path_separator}{existing_pythonpath}"
Review Comment:
```suggestion
if existing_pythonpath:
# Prepend bundle_path to existing PYTHONPATH
env_vars["PYTHONPATH"] =
f"{existing_pythonpath}{os.pathsep}{self._bundle_path}"
```
I aslo think we should add the bundle after any explicit user specified path
--
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]