You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2026/01/06 12:04:55 UTC

Re: [PR] Add bundle_path temporarily to sys.path during DagBag parsing. [airflow]

uranusjr commented on code in PR #55894:
URL: https://github.com/apache/airflow/pull/55894#discussion_r2664707910


##########
airflow-core/src/airflow/dag_processing/dagbag.py:
##########
@@ -235,6 +235,13 @@ def __init__(
         self.bundle_path = bundle_path
         self.bundle_name = bundle_name
 
+        # Add bundle path to sys.path if provided.
+        # This allows DAG files to import modules from their bundle directory.
+        # No cleanup is performed - this is intentional for ephemeral processes
+        # (dag processor, task runner, CLI) where the process exits after use.
+        if bundle_path and str(bundle_path) not in sys.path:
+            sys.path.append(str(bundle_path))

Review Comment:
   It is extremely counter-intuitive that creating a DagBag object has a system-wide side effect. I would argue this is worse than the previous approach.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org