mirror of
https://github.com/apache/superset.git
synced 2024-10-23 08:34:39 +08:00
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.
|
||||
#
|
||||
FLASK_APP="superset.app:create_app()"
|
||||
FLASK_ENV="development"
|
||||
FLASK_DEBUG=true
|
||||
|
@ -28,7 +28,7 @@ jobs:
|
||||
browser: ["chrome"]
|
||||
node: [16]
|
||||
env:
|
||||
FLASK_ENV: development
|
||||
SUPERSET_ENV: development
|
||||
SUPERSET_CONFIG: tests.integration_tests.superset_test_config
|
||||
SUPERSET__SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://superset:superset@127.0.0.1:15432/superset
|
||||
PYTHONPATH: ${{ github.workspace }}
|
||||
|
2
.github/workflows/superset-e2e.yml
vendored
2
.github/workflows/superset-e2e.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
||||
containers: [1, 2, 3]
|
||||
browser: ["chrome"]
|
||||
env:
|
||||
FLASK_ENV: development
|
||||
SUPERSET_ENV: development
|
||||
SUPERSET_CONFIG: tests.integration_tests.superset_test_config
|
||||
SUPERSET__SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://superset:superset@127.0.0.1:15432/superset
|
||||
PYTHONPATH: ${{ github.workspace }}
|
||||
|
@ -453,7 +453,7 @@ superset load-examples
|
||||
# Start the Flask dev web server from inside your virtualenv.
|
||||
# Note that your page may not have CSS at this point.
|
||||
# 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
|
||||
@ -477,7 +477,7 @@ $ make pre-commit
|
||||
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:
|
||||
`FLASK_ENV=development superset run -p 8088 --reload --debugger`
|
||||
`superset run -p 8088 --reload --debugger --debug`
|
||||
|
||||
#### Dependencies
|
||||
|
||||
@ -518,7 +518,7 @@ def FLASK_APP_MUTATOR(app):
|
||||
Then make sure you run your WSGI server using the right worker type:
|
||||
|
||||
```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:
|
||||
@ -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/>
|
||||
```bash
|
||||
# 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/>
|
||||
```bash
|
||||
@ -922,7 +922,7 @@ For debugging locally using VSCode, you can configure a launch configuration fil
|
||||
"module": "flask",
|
||||
"env": {
|
||||
"FLASK_APP": "superset",
|
||||
"FLASK_ENV": "development"
|
||||
"SUPERSET_ENV": "development"
|
||||
},
|
||||
"args": [
|
||||
"run",
|
||||
|
@ -52,7 +52,7 @@ FROM python:${PY_VER} AS lean
|
||||
WORKDIR /app
|
||||
ENV LANG=C.UTF-8 \
|
||||
LC_ALL=C.UTF-8 \
|
||||
FLASK_ENV=production \
|
||||
SUPERSET_ENV=production \
|
||||
FLASK_APP="superset.app:create_app()" \
|
||||
PYTHONPATH="/app/pythonpath" \
|
||||
SUPERSET_HOME="/app/superset_home" \
|
||||
|
@ -41,5 +41,5 @@ superset init
|
||||
# Loading examples
|
||||
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
|
||||
|
@ -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.
|
||||
- [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.
|
||||
- [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
|
||||
|
||||
|
@ -39,7 +39,7 @@ PYTHONPATH=/app/pythonpath:/app/docker/pythonpath_dev
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
|
||||
FLASK_ENV=development
|
||||
SUPERSET_ENV=development
|
||||
SUPERSET_ENV=development
|
||||
SUPERSET_LOAD_EXAMPLES=yes
|
||||
CYPRESS_CONFIG=false
|
||||
|
@ -39,7 +39,7 @@ PYTHONPATH=/app/pythonpath:/app/docker/pythonpath_dev
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
|
||||
FLASK_ENV=production
|
||||
SUPERSET_ENV=production
|
||||
SUPERSET_ENV=production
|
||||
SUPERSET_LOAD_EXAMPLES=yes
|
||||
SUPERSET_SECRET_KEY=TEST_NON_DEV_SECRET
|
||||
|
@ -42,7 +42,7 @@ superset load-examples
|
||||
|
||||
# Start the Flask dev web server from inside your virtualenv.
|
||||
# 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
|
||||
@ -66,7 +66,7 @@ make pre-commit
|
||||
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:
|
||||
`FLASK_ENV=development superset run -p 8088 --reload --debugger`
|
||||
`superset run -p 8088 --reload --debugger --debug`
|
||||
|
||||
#### Dependencies
|
||||
|
||||
@ -93,7 +93,7 @@ def FLASK_APP_MUTATOR(app):
|
||||
Then make sure you run your WSGI server using the right worker type:
|
||||
|
||||
```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:
|
||||
|
@ -246,7 +246,7 @@ WTF_CSRF_EXEMPT_LIST = [
|
||||
]
|
||||
|
||||
# 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
|
||||
|
||||
# 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.
|
||||
# 'color' can either be a hex color code, or a dot-indexed theme color (e.g. error.base)
|
||||
ENVIRONMENT_TAG_CONFIG = {
|
||||
"variable": "FLASK_ENV",
|
||||
"variable": "SUPERSET_ENV",
|
||||
"values": {
|
||||
"debug": {
|
||||
"color": "error.base",
|
||||
"text": "flask-debug",
|
||||
},
|
||||
"development": {
|
||||
"color": "error.base",
|
||||
"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]:
|
||||
menu = appbuilder.menu.get_data()
|
||||
|
||||
@ -346,17 +370,6 @@ def menu_data(user: User) -> dict[str, Any]:
|
||||
if callable(brand_text):
|
||||
brand_text = brand_text()
|
||||
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 {
|
||||
"menu": menu,
|
||||
@ -367,7 +380,7 @@ def menu_data(user: User) -> dict[str, Any]:
|
||||
"tooltip": appbuilder.app.config["LOGO_TOOLTIP"],
|
||||
"text": brand_text,
|
||||
},
|
||||
"environment_tag": environment_tag,
|
||||
"environment_tag": get_environment_tag(),
|
||||
"navbar_right": {
|
||||
# show the watermark if the default app icon has been overridden
|
||||
"show_watermark": ("superset-logo-horiz" not in appbuilder.app_icon),
|
||||
|
Loading…
Reference in New Issue
Block a user