Fix Triggerer subprocess sys.path gap for DAG bundle helpers#65887
Open
gaurav0107 wants to merge 1 commit intoapache:mainfrom
Open
Fix Triggerer subprocess sys.path gap for DAG bundle helpers#65887gaurav0107 wants to merge 1 commit intoapache:mainfrom
gaurav0107 wants to merge 1 commit intoapache:mainfrom
Conversation
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 apache#55894. Triggers whose classpath points into dags/ no longer raise ModuleNotFoundError at deserialization. closes: apache#65455
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TriggerRunner.create_triggers()now initializes the active DAG bundle and appends its root tosys.pathbefore importing trigger classes, matching the pattern established for the task runner, callback supervisor, DAG processor, and CLI in #55894. Triggers whose classpath points intodags/(e.g.helpers.emr_sensor_helpers.MyTrigger) no longer raiseModuleNotFoundErrorat deserialization.Changes
airflow-core/src/airflow/executors/workloads/trigger.py— add optionalbundle_info: BundleInfo | None = Nonefield to theRunTriggerworkload. Optional because asset-based triggers have no associated bundle.airflow-core/src/airflow/jobs/triggerer_job_runner.py:TriggerRunner._create_workload: resolveBundleInfo(name=..., version=...)fromserialized_dag_model.dag_versionand plumb it into both non-assetRunTrigger(...)construction sites. Asset-based branch keepsbundle_info=None— asset triggers ship as provider-installed classes, not bundle-local helpers.TriggerRunner._ensure_bundle_on_syspathhelper mirroringcallback_supervisor.py: if a bundle is specified, initialize it viaDagBundlesManager().get_bundle(...)and appendstr(bundle.path)tosys.path(deduped viaself._bundle_paths_added). Failures logwarningwithexc_infobut do not crash the triggerer — same defensiveness as the callback supervisor.TriggerRunner.create_triggers: call_ensure_bundle_on_syspath(workload.bundle_info)immediately beforeget_trigger_by_classpath(workload.classpath).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,DagBundlesManagernever instantiated), and the exception path (swallowed,sys.pathunchanged). Each test restoressys.pathin atry/finallyto avoid cross-test contamination.closes: #65455
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 4.7 (1M context) following the guidelines