Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local config no longer fails to import silently #8006

Merged
merged 4 commits into from
Aug 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"""
from collections import OrderedDict
import imp
import importlib.util
import json
import logging
import os
import sys

Expand Down Expand Up @@ -622,29 +624,29 @@ class CeleryConfig(object):
# SQLALCHEMY_DATABASE_URI by default if set to `None`
SQLALCHEMY_EXAMPLES_URI = None

try:
if CONFIG_PATH_ENV_VAR in os.environ:
# Explicitly import config module that is not in pythonpath; useful
# for case where app is being executed via pex.
print(
"Loaded your LOCAL configuration at [{}]".format(
os.environ[CONFIG_PATH_ENV_VAR]
)
)
if CONFIG_PATH_ENV_VAR in os.environ:
# Explicitly import config module that is not necessarily in pythonpath; useful
# for case where app is being executed via pex.
try:
cfg_path = os.environ[CONFIG_PATH_ENV_VAR]
module = sys.modules[__name__]
override_conf = imp.load_source(
"superset_config", os.environ[CONFIG_PATH_ENV_VAR]
)
override_conf = imp.load_source("superset_config", cfg_path)
for key in dir(override_conf):
if key.isupper():
setattr(module, key, getattr(override_conf, key))

else:
from superset_config import * # noqa
import superset_config

print(
"Loaded your LOCAL configuration at [{}]".format(superset_config.__file__)
print(f"Loaded your LOCAL configuration at [{cfg_path}]")
except Exception:
logging.exception(
f"Failed to import config for {CONFIG_PATH_ENV_VAR}={cfg_path}"
)
except ImportError:
pass
raise
elif importlib.util.find_spec("superset_config"):
try:
from superset_config import * # noqa pylint: disable=import-error
import superset_config # noqa pylint: disable=import-error

print(f"Loaded your LOCAL configuration at [{superset_config.__file__}]")
except Exception:
logging.exception("Found but failed to import local superset_config")
raise
betodealmeida marked this conversation as resolved.
Show resolved Hide resolved