chore: deprecate FLASK_ENV and improve conf.ENVIRONMENT_TAG_CONFIG (#24404)
This commit is contained in:
parent
46159fd190
commit
6a8f60f9fd
|
|
@ -15,4 +15,4 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
FLASK_APP="superset.app:create_app()"
|
FLASK_APP="superset.app:create_app()"
|
||||||
FLASK_ENV="development"
|
FLASK_DEBUG=true
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ jobs:
|
||||||
browser: ["chrome"]
|
browser: ["chrome"]
|
||||||
node: [16]
|
node: [16]
|
||||||
env:
|
env:
|
||||||
FLASK_ENV: development
|
SUPERSET_ENV: development
|
||||||
SUPERSET_CONFIG: tests.integration_tests.superset_test_config
|
SUPERSET_CONFIG: tests.integration_tests.superset_test_config
|
||||||
SUPERSET__SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://superset:superset@127.0.0.1:15432/superset
|
SUPERSET__SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://superset:superset@127.0.0.1:15432/superset
|
||||||
PYTHONPATH: ${{ github.workspace }}
|
PYTHONPATH: ${{ github.workspace }}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ jobs:
|
||||||
containers: [1, 2, 3]
|
containers: [1, 2, 3]
|
||||||
browser: ["chrome"]
|
browser: ["chrome"]
|
||||||
env:
|
env:
|
||||||
FLASK_ENV: development
|
SUPERSET_ENV: development
|
||||||
SUPERSET_CONFIG: tests.integration_tests.superset_test_config
|
SUPERSET_CONFIG: tests.integration_tests.superset_test_config
|
||||||
SUPERSET__SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://superset:superset@127.0.0.1:15432/superset
|
SUPERSET__SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://superset:superset@127.0.0.1:15432/superset
|
||||||
PYTHONPATH: ${{ github.workspace }}
|
PYTHONPATH: ${{ github.workspace }}
|
||||||
|
|
|
||||||
|
|
@ -453,7 +453,7 @@ superset load-examples
|
||||||
# Start the Flask dev web server from inside your virtualenv.
|
# Start the Flask dev web server from inside your virtualenv.
|
||||||
# Note that your page may not have CSS at this point.
|
# Note that your page may not have CSS at this point.
|
||||||
# See instructions below how to build the front-end assets.
|
# See instructions below how to build the front-end assets.
|
||||||
FLASK_ENV=development superset run -p 8088 --with-threads --reload --debugger
|
superset run -p 8088 --with-threads --reload --debugger --debug
|
||||||
```
|
```
|
||||||
|
|
||||||
Or you can install via our Makefile
|
Or you can install via our Makefile
|
||||||
|
|
@ -477,7 +477,7 @@ $ make pre-commit
|
||||||
via `.flaskenv`, however if needed, it should be set to `superset.app:create_app()`**
|
via `.flaskenv`, however if needed, it should be set to `superset.app:create_app()`**
|
||||||
|
|
||||||
If you have made changes to the FAB-managed templates, which are not built the same way as the newer, React-powered front-end assets, you need to start the app without the `--with-threads` argument like so:
|
If you have made changes to the FAB-managed templates, which are not built the same way as the newer, React-powered front-end assets, you need to start the app without the `--with-threads` argument like so:
|
||||||
`FLASK_ENV=development superset run -p 8088 --reload --debugger`
|
`superset run -p 8088 --reload --debugger --debug`
|
||||||
|
|
||||||
#### Dependencies
|
#### Dependencies
|
||||||
|
|
||||||
|
|
@ -518,7 +518,7 @@ def FLASK_APP_MUTATOR(app):
|
||||||
Then make sure you run your WSGI server using the right worker type:
|
Then make sure you run your WSGI server using the right worker type:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
FLASK_ENV=development gunicorn "superset.app:create_app()" -k "geventwebsocket.gunicorn.workers.GeventWebSocketWorker" -b 127.0.0.1:8088 --reload
|
gunicorn "superset.app:create_app()" -k "geventwebsocket.gunicorn.workers.GeventWebSocketWorker" -b 127.0.0.1:8088 --reload
|
||||||
```
|
```
|
||||||
|
|
||||||
You can log anything to the browser console, including objects:
|
You can log anything to the browser console, including objects:
|
||||||
|
|
@ -603,7 +603,7 @@ So a typical development workflow is the following:
|
||||||
1. [run Superset locally](#flask-server) using Flask, on port `8088` — but don't access it directly,<br/>
|
1. [run Superset locally](#flask-server) using Flask, on port `8088` — but don't access it directly,<br/>
|
||||||
```bash
|
```bash
|
||||||
# Install Superset and dependencies, plus load your virtual environment first, as detailed above.
|
# Install Superset and dependencies, plus load your virtual environment first, as detailed above.
|
||||||
FLASK_ENV=development superset run -p 8088 --with-threads --reload --debugger
|
superset run -p 8088 --with-threads --reload --debugger --debug
|
||||||
```
|
```
|
||||||
2. in parallel, run the Webpack dev server locally on port `9000`,<br/>
|
2. in parallel, run the Webpack dev server locally on port `9000`,<br/>
|
||||||
```bash
|
```bash
|
||||||
|
|
@ -922,7 +922,7 @@ For debugging locally using VSCode, you can configure a launch configuration fil
|
||||||
"module": "flask",
|
"module": "flask",
|
||||||
"env": {
|
"env": {
|
||||||
"FLASK_APP": "superset",
|
"FLASK_APP": "superset",
|
||||||
"FLASK_ENV": "development"
|
"SUPERSET_ENV": "development"
|
||||||
},
|
},
|
||||||
"args": [
|
"args": [
|
||||||
"run",
|
"run",
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ FROM python:${PY_VER} AS lean
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV LANG=C.UTF-8 \
|
ENV LANG=C.UTF-8 \
|
||||||
LC_ALL=C.UTF-8 \
|
LC_ALL=C.UTF-8 \
|
||||||
FLASK_ENV=production \
|
SUPERSET_ENV=production \
|
||||||
FLASK_APP="superset.app:create_app()" \
|
FLASK_APP="superset.app:create_app()" \
|
||||||
PYTHONPATH="/app/pythonpath" \
|
PYTHONPATH="/app/pythonpath" \
|
||||||
SUPERSET_HOME="/app/superset_home" \
|
SUPERSET_HOME="/app/superset_home" \
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,5 @@ superset init
|
||||||
# Loading examples
|
# Loading examples
|
||||||
superset load-examples --force
|
superset load-examples --force
|
||||||
|
|
||||||
FLASK_ENV=development FLASK_APP="superset.app:create_app()" \
|
SUPERSET_ENV=development FLASK_APP="superset.app:create_app()" \
|
||||||
flask run -p 8088 --with-threads --reload --debugger --host=0.0.0.0
|
flask run -p 8088 --with-threads --reload --debugger --host=0.0.0.0
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,12 @@ assists people when migrating to a new version.
|
||||||
- [23652](https://github.com/apache/superset/pull/23652): Enables GENERIC_CHART_AXES feature flag by default.
|
- [23652](https://github.com/apache/superset/pull/23652): Enables GENERIC_CHART_AXES feature flag by default.
|
||||||
- [23226](https://github.com/apache/superset/pull/23226): Migrated endpoint `/estimate_query_cost/<int:database_id>` to `/api/v1/sqllab/estimate/`. Corresponding permissions are can estimate query cost on SQLLab. Make sure you add/replace the necessary permissions on any custom roles you may have.
|
- [23226](https://github.com/apache/superset/pull/23226): Migrated endpoint `/estimate_query_cost/<int:database_id>` to `/api/v1/sqllab/estimate/`. Corresponding permissions are can estimate query cost on SQLLab. Make sure you add/replace the necessary permissions on any custom roles you may have.
|
||||||
- [23890](https://github.com/apache/superset/pull/23890): Removes Python 3.8 support.
|
- [23890](https://github.com/apache/superset/pull/23890): Removes Python 3.8 support.
|
||||||
|
- [24404](https://github.com/apache/superset/pull/24404): FLASK_ENV is getting
|
||||||
|
deprecated, we recommend using SUPERSET_ENV and reviewing your
|
||||||
|
config for ENVIRONMENT_TAG_CONFIG, which enables adding a tag in the navbar to
|
||||||
|
make it more clear which envrionment your are in.
|
||||||
|
`SUPERSET_ENV=production` and `SUPERSET_ENV=development` are the two
|
||||||
|
supported switches based on the default config.
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ PYTHONPATH=/app/pythonpath:/app/docker/pythonpath_dev
|
||||||
REDIS_HOST=redis
|
REDIS_HOST=redis
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
|
||||||
FLASK_ENV=development
|
SUPERSET_ENV=development
|
||||||
SUPERSET_ENV=development
|
SUPERSET_ENV=development
|
||||||
SUPERSET_LOAD_EXAMPLES=yes
|
SUPERSET_LOAD_EXAMPLES=yes
|
||||||
CYPRESS_CONFIG=false
|
CYPRESS_CONFIG=false
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ PYTHONPATH=/app/pythonpath:/app/docker/pythonpath_dev
|
||||||
REDIS_HOST=redis
|
REDIS_HOST=redis
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
|
||||||
FLASK_ENV=production
|
SUPERSET_ENV=production
|
||||||
SUPERSET_ENV=production
|
SUPERSET_ENV=production
|
||||||
SUPERSET_LOAD_EXAMPLES=yes
|
SUPERSET_LOAD_EXAMPLES=yes
|
||||||
SUPERSET_SECRET_KEY=TEST_NON_DEV_SECRET
|
SUPERSET_SECRET_KEY=TEST_NON_DEV_SECRET
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ superset load-examples
|
||||||
|
|
||||||
# Start the Flask dev web server from inside your virtualenv.
|
# Start the Flask dev web server from inside your virtualenv.
|
||||||
# Note that your page may not have CSS at this point.
|
# Note that your page may not have CSS at this point.
|
||||||
FLASK_ENV=development superset run -p 8088 --with-threads --reload --debugger
|
superset run -p 8088 --with-threads --reload --debugger --debug
|
||||||
```
|
```
|
||||||
|
|
||||||
Or you can install via our Makefile
|
Or you can install via our Makefile
|
||||||
|
|
@ -66,7 +66,7 @@ make pre-commit
|
||||||
via `.flaskenv`, however if needed, it should be set to `superset.app:create_app()`**
|
via `.flaskenv`, however if needed, it should be set to `superset.app:create_app()`**
|
||||||
|
|
||||||
If you have made changes to the FAB-managed templates, which are not built the same way as the newer, React-powered front-end assets, you need to start the app without the `--with-threads` argument like so:
|
If you have made changes to the FAB-managed templates, which are not built the same way as the newer, React-powered front-end assets, you need to start the app without the `--with-threads` argument like so:
|
||||||
`FLASK_ENV=development superset run -p 8088 --reload --debugger`
|
`superset run -p 8088 --reload --debugger --debug`
|
||||||
|
|
||||||
#### Dependencies
|
#### Dependencies
|
||||||
|
|
||||||
|
|
@ -93,7 +93,7 @@ def FLASK_APP_MUTATOR(app):
|
||||||
Then make sure you run your WSGI server using the right worker type:
|
Then make sure you run your WSGI server using the right worker type:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
FLASK_ENV=development gunicorn "superset.app:create_app()" -k "geventwebsocket.gunicorn.workers.GeventWebSocketWorker" -b 127.0.0.1:8088 --reload
|
SUPERSET_ENV=development gunicorn "superset.app:create_app()" -k "geventwebsocket.gunicorn.workers.GeventWebSocketWorker" -b 127.0.0.1:8088 --reload
|
||||||
```
|
```
|
||||||
|
|
||||||
You can log anything to the browser console, including objects:
|
You can log anything to the browser console, including objects:
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ WTF_CSRF_EXEMPT_LIST = [
|
||||||
]
|
]
|
||||||
|
|
||||||
# Whether to run the web server in debug mode or not
|
# Whether to run the web server in debug mode or not
|
||||||
DEBUG = os.environ.get("FLASK_ENV") == "development"
|
DEBUG = os.environ.get("FLASK_DEBUG")
|
||||||
FLASK_USE_RELOAD = True
|
FLASK_USE_RELOAD = True
|
||||||
|
|
||||||
# Enable profiling of Python calls. Turn this on and append ``?_instrument=1``
|
# Enable profiling of Python calls. Turn this on and append ``?_instrument=1``
|
||||||
|
|
@ -1537,8 +1537,12 @@ WELCOME_PAGE_LAST_TAB: (
|
||||||
# Configuration for environment tag shown on the navbar. Setting 'text' to '' will hide the tag.
|
# Configuration for environment tag shown on the navbar. Setting 'text' to '' will hide the tag.
|
||||||
# 'color' can either be a hex color code, or a dot-indexed theme color (e.g. error.base)
|
# 'color' can either be a hex color code, or a dot-indexed theme color (e.g. error.base)
|
||||||
ENVIRONMENT_TAG_CONFIG = {
|
ENVIRONMENT_TAG_CONFIG = {
|
||||||
"variable": "FLASK_ENV",
|
"variable": "SUPERSET_ENV",
|
||||||
"values": {
|
"values": {
|
||||||
|
"debug": {
|
||||||
|
"color": "error.base",
|
||||||
|
"text": "flask-debug",
|
||||||
|
},
|
||||||
"development": {
|
"development": {
|
||||||
"color": "error.base",
|
"color": "error.base",
|
||||||
"text": "Development",
|
"text": "Development",
|
||||||
|
|
|
||||||
|
|
@ -333,6 +333,30 @@ class BaseSupersetView(BaseView):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_environment_tag() -> dict[str, Any]:
|
||||||
|
# Whether flask is in debug mode (--debug)
|
||||||
|
debug = appbuilder.app.config["DEBUG"]
|
||||||
|
|
||||||
|
# Getting the configuration option for ENVIRONMENT_TAG_CONFIG
|
||||||
|
env_tag_config = appbuilder.app.config["ENVIRONMENT_TAG_CONFIG"]
|
||||||
|
|
||||||
|
# These are the predefined templates define in the config
|
||||||
|
env_tag_templates = env_tag_config.get("values")
|
||||||
|
|
||||||
|
# This is the environment variable name from which to select the template
|
||||||
|
# default is SUPERSET_ENV (from FLASK_ENV in previous versions)
|
||||||
|
env_envvar = env_tag_config.get("variable")
|
||||||
|
|
||||||
|
# this is the actual name we want to use
|
||||||
|
env_name = os.environ.get(env_envvar)
|
||||||
|
|
||||||
|
if not env_name or env_name not in env_tag_templates.keys():
|
||||||
|
env_name = "debug" if debug else None
|
||||||
|
|
||||||
|
env_tag = env_tag_templates.get(env_name)
|
||||||
|
return env_tag or {}
|
||||||
|
|
||||||
|
|
||||||
def menu_data(user: User) -> dict[str, Any]:
|
def menu_data(user: User) -> dict[str, Any]:
|
||||||
menu = appbuilder.menu.get_data()
|
menu = appbuilder.menu.get_data()
|
||||||
|
|
||||||
|
|
@ -346,17 +370,6 @@ def menu_data(user: User) -> dict[str, Any]:
|
||||||
if callable(brand_text):
|
if callable(brand_text):
|
||||||
brand_text = brand_text()
|
brand_text = brand_text()
|
||||||
build_number = appbuilder.app.config["BUILD_NUMBER"]
|
build_number = appbuilder.app.config["BUILD_NUMBER"]
|
||||||
try:
|
|
||||||
environment_tag = (
|
|
||||||
appbuilder.app.config["ENVIRONMENT_TAG_CONFIG"]["values"][
|
|
||||||
os.environ.get(
|
|
||||||
appbuilder.app.config["ENVIRONMENT_TAG_CONFIG"]["variable"]
|
|
||||||
)
|
|
||||||
]
|
|
||||||
or {}
|
|
||||||
)
|
|
||||||
except KeyError:
|
|
||||||
environment_tag = {}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"menu": menu,
|
"menu": menu,
|
||||||
|
|
@ -367,7 +380,7 @@ def menu_data(user: User) -> dict[str, Any]:
|
||||||
"tooltip": appbuilder.app.config["LOGO_TOOLTIP"],
|
"tooltip": appbuilder.app.config["LOGO_TOOLTIP"],
|
||||||
"text": brand_text,
|
"text": brand_text,
|
||||||
},
|
},
|
||||||
"environment_tag": environment_tag,
|
"environment_tag": get_environment_tag(),
|
||||||
"navbar_right": {
|
"navbar_right": {
|
||||||
# show the watermark if the default app icon has been overridden
|
# show the watermark if the default app icon has been overridden
|
||||||
"show_watermark": ("superset-logo-horiz" not in appbuilder.app_icon),
|
"show_watermark": ("superset-logo-horiz" not in appbuilder.app_icon),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue