You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by je...@apache.org on 2023/02/14 21:24:26 UTC

[airflow] branch main updated: Fix import cycle starting from airflow/__main__.py (#29523)

This is an automated email from the ASF dual-hosted git repository.

jedcunningham pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 81f07274b9 Fix import cycle starting from airflow/__main__.py (#29523)
81f07274b9 is described below

commit 81f07274b9cd9369a1024eb8b0ad5ee6058202f0
Author: Niko Oliveira <on...@amazon.com>
AuthorDate: Tue Feb 14 13:24:15 2023 -0800

    Fix import cycle starting from airflow/__main__.py (#29523)
---
 airflow/__main__.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/airflow/__main__.py b/airflow/__main__.py
index 9de8c683b5..5eca0b84ed 100644
--- a/airflow/__main__.py
+++ b/airflow/__main__.py
@@ -24,12 +24,21 @@ import os
 
 import argcomplete
 
+# The configuration module initializes and validates the conf object as a side effect the first
+# time it is imported. If it is not imported before importing the settings module, the conf
+# object will then be initted/validated as a side effect of it being imported in settings,
+# however this can cause issues since those modules are very tightly coupled and can
+# very easily cause import cycles in the conf init/validate code (since downstream code from
+# those functions likely import settings).
+# Therefore importing configuration early (as the first airflow import) avoids
+# any possible import cycles with settings downstream.
+from airflow import configuration
 from airflow.cli import cli_parser
-from airflow.configuration import conf
 
 
 def main():
     """Main executable function."""
+    conf = configuration.conf
     if conf.get("core", "security") == "kerberos":
         os.environ["KRB5CCNAME"] = conf.get("kerberos", "ccache")
         os.environ["KRB5_KTNAME"] = conf.get("kerberos", "keytab")