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

villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new f33a0e1  fix: import superset_config (#15444)
f33a0e1 is described below

commit f33a0e1d686f491cd9f56cdd1e245ada3a8b8d9a
Author: Ville Brofeldt <[email protected]>
AuthorDate: Tue Jun 29 13:30:05 2021 +0300

    fix: import superset_config (#15444)
    
    * fix: import superset_config
    
    * make module name constant
---
 superset/app.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/superset/app.py b/superset/app.py
index 31787be..02682e5 100644
--- a/superset/app.py
+++ b/superset/app.py
@@ -16,10 +16,11 @@
 # under the License.
 from __future__ import annotations
 
-import importlib
+import importlib.machinery
 import importlib.util
 import logging
 import os
+import sys
 from types import ModuleType
 from typing import Any, Dict, Union
 
@@ -76,8 +77,12 @@ def load_override_config() -> Union[Dict[Any, Any], 
ModuleType]:
         # for case where app is being executed via pex.
         cfg_path = os.environ[CONFIG_PATH_ENV_VAR]
         try:
-
-            override_conf = importlib.import_module("superset_config", 
cfg_path)
+            CONFIG_MODULE_NAME = "superset_config"  # pylint: disable=C0103
+            loader = importlib.machinery.SourceFileLoader(CONFIG_MODULE_NAME, 
cfg_path)
+            spec = importlib.util.spec_from_loader(CONFIG_MODULE_NAME, loader)
+            override_conf = importlib.util.module_from_spec(spec)
+            sys.modules[CONFIG_MODULE_NAME] = override_conf
+            loader.exec_module(override_conf)
 
             print(f"Loaded your LOCAL configuration at [{cfg_path}]")
             return override_conf

Reply via email to