From b3db6140c88106fedebe91db0ca817eca4234dc8 Mon Sep 17 00:00:00 2001 From: Craig Rueda Date: Wed, 15 Dec 2021 16:16:48 -0800 Subject: [PATCH] fix(alembic): Making Alembic logger config optional (#17774) * Making Alembic logger config optional * Switching to app config --- superset/config.py | 5 +++++ superset/migrations/env.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/superset/config.py b/superset/config.py index 337fef882a97..8bee76bee0ea 100644 --- a/superset/config.py +++ b/superset/config.py @@ -103,6 +103,11 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]: return None +# +# If True, we will skip the call to load the logger config found in alembic.init +# +ALEMBIC_SKIP_LOG_CONFIG = False + # Depending on the context in which this config is loaded, the # version_info.json file may or may not be available, as it is # generated on install via setup.py. In the event that we're diff --git a/superset/migrations/env.py b/superset/migrations/env.py index 923516e3115b..d0220e33f9ee 100755 --- a/superset/migrations/env.py +++ b/superset/migrations/env.py @@ -31,7 +31,9 @@ # Interpret the config file for Python logging. # This line sets up loggers basically. -fileConfig(config.config_file_name) +if not current_app.config["ALEMBIC_SKIP_LOG_CONFIG"]: + # Skip loading logger config if the user has this config set + fileConfig(config.config_file_name) logger = logging.getLogger("alembic.env") DATABASE_URI = current_app.config["SQLALCHEMY_DATABASE_URI"]