Skip to content

Add /files/dags to PYTHONPATH in Breeze#61436

Open
jason810496 wants to merge 1 commit intoapache:mainfrom
jason810496:ci/breeze/fix-files-dags-python-path
Open

Add /files/dags to PYTHONPATH in Breeze#61436
jason810496 wants to merge 1 commit intoapache:mainfrom
jason810496:ci/breeze/fix-files-dags-python-path

Conversation

@jason810496
Copy link
Member

Why

The default dags path in Breeze will be /files/dags, but /files/dags is not in PYTHONPATH, which cause the triggers defined in Dag file are not able to import by Triggerer, and have to workaround by copying Dag file to some directories that are in PYTHONPATH. Pointed out in: #58676 (comment)

What

We should add /files/dags to PYTHONPATH in Breeze in case the triggers are defined in dags, and cause "unable to import trigger" during Triggerer runtime.

Before: /files/dags is not in PYTHONPATH

>>> import sys; import pprint; pprint.pprint(sys.path)
['',
 '/opt/airflow',
 '/opt/airflow/providers/standard/tests',
 '/usr/python/lib/python310.zip',
 '/usr/python/lib/python3.10',
# ...
 '/opt/airflow/providers/yandex/src',

After: /files/dags is now in PYTHONPATH

>>> import sys; import pprint; pprint.pprint(sys.path)
['',
 '/opt/airflow',
 '/files/dags',  # <----------------------------- added!
 '/opt/airflow/providers/standard/tests',
 '/usr/python/lib/python310.zip',
 '/usr/python/lib/python3.10',
 '/usr/python/lib/python3.10/lib-dynload',
 '/usr/python/lib/python3.10/site-packages',
 '/opt/airflow/airflow-core/src',
 '/opt/airflow/airflow-ctl/src',
 ...

@potiuk
Copy link
Member

potiuk commented Feb 4, 2026

Hmm. I think that should not be the case - at least by default when Airflow imports Dags (whether it's in Triggerer, worker or Dag Processor), it should add bundle root to the PYTHONPATH automatically - and we should avoid adding it externally- if we see a problem that it is not added, we should fix it.

@jedcunningham @ephraimbuddy - am I right ?

@jedcunningham
Copy link
Member

jedcunningham commented Feb 4, 2026

Correct (edit: mostly). In fact, triggers from Dag files was pretty broken before anyways, so we intentionally removed that ability in AF3.

edit:

whether it's in Triggerer, worker or Dag Processor), it should add bundle root to the PYTHONPATH automatically

Yes for worker and dag processor. But not for the triggerer - the single process architecture means you can't do it reliably.

@jedcunningham
Copy link
Member

See #48603.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants