You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "gaurav0107 (via GitHub)" <gi...@apache.org> on 2026/04/26 19:12:20 UTC
[PR] Fix Triggerer subprocess sys.path gap for DAG bundle helpers [airflow]
gaurav0107 opened a new pull request, #65887:
URL: https://github.com/apache/airflow/pull/65887
`TriggerRunner.create_triggers()` now initializes the active DAG bundle and appends its root to `sys.path` before importing trigger classes, matching the pattern established for the task runner, callback supervisor, DAG processor, and CLI in #55894. Triggers whose classpath points into `dags/` (e.g. `helpers.emr_sensor_helpers.MyTrigger`) no longer raise `ModuleNotFoundError` at deserialization.
### Changes
1. `airflow-core/src/airflow/executors/workloads/trigger.py` — add optional `bundle_info: BundleInfo | None = None` field to the `RunTrigger` workload. Optional because asset-based triggers have no associated bundle.
2. `airflow-core/src/airflow/jobs/triggerer_job_runner.py`:
- `TriggerRunner._create_workload`: resolve `BundleInfo(name=..., version=...)` from `serialized_dag_model.dag_version` and plumb it into both non-asset `RunTrigger(...)` construction sites. Asset-based branch keeps `bundle_info=None` — asset triggers ship as provider-installed classes, not bundle-local helpers.
- New `TriggerRunner._ensure_bundle_on_syspath` helper mirroring `callback_supervisor.py`: if a bundle is specified, initialize it via `DagBundlesManager().get_bundle(...)` and append `str(bundle.path)` to `sys.path` (deduped via `self._bundle_paths_added`). Failures log `warning` with `exc_info` but do not crash the triggerer — same defensiveness as the callback supervisor.
- `TriggerRunner.create_triggers`: call `_ensure_bundle_on_syspath(workload.bundle_info)` immediately before `get_trigger_by_classpath(workload.classpath)`.
3. `airflow-core/tests/unit/jobs/test_triggerer_job.py` — three new unit tests covering the dedup path (appends once), the no-op paths (`None`, empty name, `DagBundlesManager` never instantiated), and the exception path (swallowed, `sys.path` unchanged). Each test restores `sys.path` in a `try/finally` to avoid cross-test contamination.
closes: #65455
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Opus 4.7 (1M context)
Generated-by: Claude Opus 4.7 (1M context) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
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
Re: [PR] Fix Triggerer subprocess sys.path gap for DAG bundle helpers [airflow]
Posted by "gaurav0107 (via GitHub)" <gi...@apache.org>.
gaurav0107 closed pull request #65887: Fix Triggerer subprocess sys.path gap for DAG bundle helpers
URL: https://github.com/apache/airflow/pull/65887
--
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
Re: [PR] Fix Triggerer subprocess sys.path gap for DAG bundle helpers [airflow]
Posted by "gaurav0107 (via GitHub)" <gi...@apache.org>.
gaurav0107 commented on PR #65887:
URL: https://github.com/apache/airflow/pull/65887#issuecomment-4336455101
Closing this as Bug Already got closed
--
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