superset icon indicating copy to clipboard operation
superset copied to clipboard

[Bug] superset_config.py is not working as expecting.

Open kk580kk opened this issue 7 years ago • 10 comments

Make sure these boxes are checked before submitting your issue - thank you!

  • [x] I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • [x] I have reproduced the issue with at least the latest released version of superset.
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar.

Superset version

https://github.com/apache/incubator-superset/commit/fc8acf27c82ef3030d641289fa80f926f2a83b76

Expected results

working with settings from supset_config.py

Actual results


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]))
        module = sys.modules[__name__]
        override_conf = imp.load_source(
            'superset_config',
            os.environ[CONFIG_PATH_ENV_VAR])
        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__))
except ImportError:
    pass

there not CONFIG_PATH_ENV_VAR in os environment, and throw a exception when finding superset_config module "there is no superset_config module" .

Steps to reproduce

Create a virtual environemnt and activate it (recommended)

virtualenv -p python3 ./venv

setup a python3.6 virtualenv

source venv/bin/activate

Install external dependencies

pip install -r requirements.txt pip install -r requirements-dev.txt

Install Superset in editable (development) mode

pip install -e .

Create an admin user

fabmanager create-admin --app superset

Initialize the database

superset db upgrade

Create default roles and permissions

superset init

Load some data to play with

superset load_examples

Start the Flask dev web server from inside the superset dir (but see below for frontend asset compilation)

cd superset flask run -p 8080 --with-threads --reload --debugger

kk580kk avatar Dec 07 '18 03:12 kk580kk

If you fire up a python shell from that context and import superset_config, does it work?

mistercrunch avatar Dec 07 '18 04:12 mistercrunch

If you fire up a python shell from that context and import superset_config, does it work?

I have pycharm and suspend at that point, then run import superset_config , and got error could not find module superset_config

kk580kk avatar Dec 10 '18 03:12 kk580kk

please check you SUPERSET_HOME env setting

On Mon, Dec 10, 2018 at 11:48 AM 达斯特兰斯 [email protected] wrote:

If you fire up a python shell from that context and import superset_config, does it work?

I have pycharm and suspend at that point, then run import superset_config , and got error could not find module superset_config

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apache/incubator-superset/issues/6499#issuecomment-445660618, or mute the thread https://github.com/notifications/unsubscribe-auth/AB7FUqhNMcT5EVG2eRoGUO8-DW1oEyxMks5u3dmEgaJpZM4ZHs9g .

zhaoyongjie avatar Dec 10 '18 03:12 zhaoyongjie

please check you SUPERSET_HOME env setting …

Is there any document in the tutorial says how to set SUPERSET_HOME ?

kk580kk avatar Dec 10 '18 09:12 kk580kk

SUPERSET_HOME

just add export SUPERSET_HOME="path to config" to your .bashrc or your .bash_profile in your home. Then restart your terminal.

If superset_home doesn't work change it with export PYTHONPATH="path to config:$PYTHONPATH"

ripoul avatar Dec 10 '18 13:12 ripoul

export PYTHONPATH=/opt/superset

replase the path /opt/superset with path where your superset_config in

Jiafan avatar Dec 17 '18 15:12 Jiafan

Anyone think we need to clarify the docs here http://superset.apache.org/installation.html#configuration ? It's clear enough to me, but maybe that's mostly because I probably wrote the docs on this....

mistercrunch avatar Dec 18 '18 00:12 mistercrunch

@kk580kk

export SUPERSET_HOME=<superset home directory>
export SUPERSET_CONFIG_PATH=<overwrite default superset_config.py>

zhaoyongjie avatar Dec 18 '18 01:12 zhaoyongjie

@mistercrunch make sure it is in your PYTHONPATH I got it, but it is not a naturally expection as I had followed the tutorial but got a error. Maybe I need to read some more document before trying to run this project.

kk580kk avatar Dec 18 '18 02:12 kk580kk

@zhaoyongjie Thanks,

kk580kk avatar Dec 18 '18 02:12 kk580kk