Apache Superset config.py on
Asked Answered
R

6

12

I am trying to customising my Apache Superset. I am not very familiar with Terminal.

On the documentation it is written: "To configure your application, you need to create a file (module) superset_config.py and make sure it is in your PYTHONPATH. Here are some of the parameters you can copy / paste in that configuration module:".

Let's say I want to decrease ROW_LIMIT to 5000, and my Superset is installed on an Anaconda Environment called "ExperimentSuperset".

Can someone please explain to me what do I have to do to reach this results?

Rese answered 5/12, 2019 at 12:38 Comment(0)
M
12

The pythonpath is mainly defined by:

  1. execution directory
  2. pythonpath environemnt variable
  3. default install dir for modules

(Also it can be enhanced using sys.path and pth file - which definesdirectories and itself needs to be in python).

To my experience, pythonpath variable is set by most superset applications and can be evaluated the simplest way by calling set in console or echo $pythonpath. You can also use python to print out the pythonpath from terminal: python -c "import sys; print('\n'.join(sys.path))".

Superset looks in the path for a file called superset_config.py there. You can also directly point to the file even if it is not in the path when you set the environment variable SUPERSET_CONFIG_PATH=/your/path/to/superset_config.py.

In the sources there's a file called config.py that has all settings. All settings there will be overwritten with the settings loaded from superset_config.py. So you just need to define the specifics of your superset application.

So your specific steps are:

  1. create a new and empty superset_config.py
  2. add ROW_LIMIT = 5000 to file
  3. make sure it's in python path or set environment variable SUPERSET_CONFIG_PATH

Superset will then use the config file and read your settings. Noite the config is a fully functional python file, so you can add methods etc. In the superset example there's a useful method pulling parameters in from environment variables. This is especially useful when using e.g. Docker.

Miraculous answered 7/4, 2020 at 19:24 Comment(0)
H
6

At the end of config.py, you'll see that it tries to load superset_config.py from the SUPERSET_CONFIG_PATH environment variable, so all you need to do is:

  1. Create the file
  2. Set the values you want there (ROW_LIMIT = 5000)
  3. Run this command:
export SUPERSET_CONFIG_PATH=/path/to/your/superset_config.py

  1. Restart your superset to take the changes

Source: https://github.com/apache/superset/issues/2117#issuecomment-277666183

Helsell answered 12/8, 2021 at 19:42 Comment(0)
R
1

Configure your superset_config.py to override the default parameters of superset which is declared in config.py file -

superset_config.py:

ROW_LIMIT=5000

If you are running your docker image with docker run command then it might not work. Because superset_config.py only execute if there is SUPERSET_CONFIG_PATH in os.environ. You need to add the SUPERSET_CONFIG_PATH in Dockerfile so that it will be picked up from os.environ.

To achieve this you need to configure your Dockerfile like this, add SUPERSET_CONFIG_PATH with ENV:

Dockerfile:

ENV LANG=C.UTF-8 \
    LC_ALL=C.UTF-8 \
    FLASK_ENV=production \
    SUPERSET_ENV=production \
    SUPERSET_LOAD_EXAMPLES=yes \
    CYPRESS_CONFIG=false \
    MAPBOX_API_KEY='XXXXXX' \
    FLASK_APP="superset.app:create_app()" \
    PYTHONPATH="/app/pythonpath:/app/docker/pythonpath_prod" \
    SUPERSET_HOME="/app/superset_home" \
    SUPERSET_CONFIG_PATH="/path/to/your/superset_config.py" \
    SUPERSET_PORT=8088 

For example my file is available at /app/docker/superset_config.py then this will my SUPERSET_CONFIG_PATH.

Now build new image using Dockerfile.

You can check your image Env config by this command.

docker inspect <image-name:tag>

For any query please comment. Thanks.

Reams answered 21/2, 2023 at 7:29 Comment(0)
K
0

A simple approach would be:

Have customized superset_config.py file in current directory.

example superset_config.py

ROW_LIMIT = 5000
SUPERSET_WEBSERVER_PORT = 9777
SQLALCHEMY_DATABASE_URI = 'sqlite:///superset.sqlite3'

We don't need to export environment variable SUPERSET_CONFIG_PATH. Instead we can call our intended actions with modified PYTHONPATH

For example:

PYTHONPATH=.:$PYTHONPATH superset db upgrade

# or
PYTHONPATH=.:$PYTHONPATH python main.py
 
Krissie answered 10/11, 2021 at 0:43 Comment(0)
C
0

This question was asked some time ago but I found myself in the same situation recently and would like to offer my input if it will help someone else. As of the current date to be able to make edits to the configuration you have to create a file named "superset_config.py" and place it in the pythonpath. One of the default python path for apache/superset is "/app/pythonpath".

In the docker run command, specify a volume on your localhost that is linked to the container using the -v option, for example, docker run --network <your_network_name> --detach --name <name_of_your_container> -v /<path_to_local_volume>:/app/pythonpath/ -e "SUPERSET_SECRET_KEY=<YOUR_SECRET_KEY> --restart=unless-stopped -p 8088:8088 apache/superset:<version_tag>. The other options declared in the run is is not mandatory and only depend on if you want to declare those values. PS. You specify additional PYTHONPATH by setting the environment variable option -e -e PYTHONPATH=</path/to/your/python/modules>.

Caseate answered 11/8, 2023 at 21:25 Comment(0)
B
-2

If the installation was done with the instructions from "installing from scratch", the config.py will be somewhere similar to: /root/venv/lib/python3.6/site-packages/superset/config.py

Boaten answered 21/1, 2021 at 15:38 Comment(1)
Please explain your answer.Entreaty

© 2022 - 2024 — McMap. All rights reserved.