superset icon indicating copy to clipboard operation
superset copied to clipboard

superset_config.py doesn't work

Open zhangjiajie023 opened this issue 9 years ago • 8 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 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

0.15.0

Expected results

the parameters in superset_config.py should work.

Actual results

the parameters in superset_config.py don't work.

Steps to reproduce

  1. vim superset_config.py SQLALCHEMY_DATABASE_URI = 'sqlite:////path/to/superset.db' DRUID_IS_ACTIVE = False and mv superset_config.py /usr/local/superset

  2. add PYTHONPATH in /etc/profile export PYTHONPATH=/usr/local/superset:$PYTHONPATH or export PYTHONPATH=/usr/local/superset source /etc/profile

  3. run superset I set wrong SQLALCHEMY_DATABASE_URI but superset still works

so the superset_config.py doesn't works, something wrong?

zhangjiajie023 avatar Feb 06 '17 09:02 zhangjiajie023

Looks like superset has created new "superset.db" in the path you specified. Thats why its working. Check once. Superset will create a path If path doesn't exist.

pawan-kv avatar Feb 06 '17 10:02 pawan-kv

@pawan-kv The superset_config.py is loaded in supersete/config.py, so I set CONFIG_PATH_ENV_VAR = '/usr/local/superset' in supersete/config.py, and it works, which seems that there is no need to set PYTHONPATH, right?

noooo, this is not a good way, because i can build the source code.

in supersete/config.py, from superset_config import * i can understand why the import failed when superset_config.py is put in PYTHONPATH?

zhangjiajie023 avatar Feb 06 '17 11:02 zhangjiajie023

Maybe Im not getting you quite right.

But this is how we can override "config.py" default settings:

  1. create a new file "superset_config.py" in some directory say "/home/local_settings/". Add line: SQLALCHEMY_DATABASE_URI = 'sqlite:////home/data/superset.db' (or any path u have write permissions to)

  2. Now you can do either: export PYTHONPATH=/home/local_settings/:$PYTHONPATH OR export SUPERSET_CONFIG_PATH=/home/local_settings/

Thats it.

pawan-kv avatar Feb 06 '17 12:02 pawan-kv

Thanks @pawan-kv!

xrmx avatar Feb 09 '17 08:02 xrmx

Didn't work for me in superset 0.18.0 . When setting SUPERSET_CONFIG_PATH=/code/superset/ it was throwing this:

Traceback (most recent call last):
  File "/usr/local/bin/superset", line 12, in <module>
    from superset.cli import manager
  File "/usr/local/lib/python3.5/dist-packages/superset/__init__.py", line 21, in <module>
    from superset import utils, config  # noqa
  File "/usr/local/lib/python3.5/dist-packages/superset/config.py", line 305, in <module>
    imp.load_source('superset_config', os.environ[CONFIG_PATH_ENV_VAR])
  File "/usr/lib/python3.5/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 669, in exec_module
  File "<frozen importlib._bootstrap_external>", line 774, in get_code
  File "/usr/lib/python3.5/imp.py", line 158, in get_data
    return super().get_data(path)
  File "<frozen importlib._bootstrap_external>", line 826, in get_data
IsADirectoryError: [Errno 21] Is a directory: '/code/superset/'

What did work is setting the full path to the file, not just directory. SUPERSET_CONFIG_PATH=/code/superset/superset_config.py

astawiarski avatar May 16 '17 13:05 astawiarski

We just ran into this. If the option is for the config file, not path, can it be changed to:

SUPERSET_CONFIG_FILE=

pixdrift avatar Oct 03 '18 05:10 pixdrift

HI all , i am getting below issue can any one help

Traceback (most recent call last): File "/home/itsupport/superset-venv/bin/superset", line 12, in from superset.cli import manager File "/home/itsupport/superset-venv/lib/python3.5/site-packages/superset/init.py", line 22, in from superset import config, utils File "/home/itsupport/superset-venv/lib/python3.5/site-packages/superset/config.py", line 437, in os.environ[CONFIG_PATH_ENV_VAR]) File "/usr/lib/python3.5/imp.py", line 172, in load_source module = _load(spec) File "/home/kranthi/superset-venv/bin/superset_config.py", line 34 secret = <>

iamcoolkranthi avatar Nov 02 '18 10:11 iamcoolkranthi

secret = <> is not valid python.

mistercrunch avatar Nov 02 '18 15:11 mistercrunch