2019-01-15 18:53:27 -05:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
# distributed with this work for additional information
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
# under the License.
|
2020-04-04 16:23:18 -04:00
|
|
|
# type: ignore
|
2019-02-27 18:11:38 -05:00
|
|
|
from copy import copy
|
2019-10-18 17:44:27 -04:00
|
|
|
|
2020-04-04 16:23:18 -04:00
|
|
|
from superset.config import *
|
2020-04-07 16:00:42 -04:00
|
|
|
from tests.superset_test_custom_template_processors import CustomPrestoTemplateProcessor
|
2016-03-18 02:44:58 -04:00
|
|
|
|
2019-06-25 16:34:48 -04:00
|
|
|
AUTH_USER_REGISTRATION_ROLE = "alpha"
|
|
|
|
SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(DATA_DIR, "unittests.db")
|
feat(SIP-39): Async query support for charts (#11499)
* Generate JWT in Flask app
* Refactor chart data API query logic, add JWT validation and async worker
* Add redis stream implementation, refactoring
* Add chart data cache endpoint, refactor QueryContext caching
* Typing, linting, refactoring
* pytest fixes and openapi schema update
* Enforce caching be configured for async query init
* Async query processing for explore_json endpoint
* Add /api/v1/async_event endpoint
* Async frontend for dashboards [WIP]
* Chart async error message support, refactoring
* Abstract asyncEvent middleware
* Async chart loading for Explore
* Pylint fixes
* asyncEvent middleware -> TypeScript, JS linting
* Chart data API: enforce forced_cache, add tests
* Add tests for explore_json endpoints
* Add test for chart data cache enpoint (no login)
* Consolidate set_and_log_cache and add STORE_CACHE_KEYS_IN_METADATA_DB flag
* Add tests for tasks/async_queries and address PR comments
* Bypass non-JSON result formats for async queries
* Add tests for redux middleware
* Remove debug statement
Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
* Skip force_cached if no queryObj
* SunburstViz: don't modify self.form_data
* Fix failing annotation test
* Resolve merge/lint issues
* Reduce polling delay
* Fix new getClientErrorObject reference
* Fix flakey unit tests
* /api/v1/async_event: increment redis stream ID, add tests
* PR feedback: refactoring, configuration
* Fixup: remove debugging
* Fix typescript errors due to redux upgrade
* Update UPDATING.md
* Fix failing py tests
* asyncEvent_spec.js -> asyncEvent_spec.ts
* Refactor flakey Python 3.7 mock assertions
* Fix another shared state issue in Py tests
* Use 'sub' claim in JWT for user_id
* Refactor async middleware config
* Fixup: restore FeatureFlag boolean type
Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
2020-12-10 23:21:56 -05:00
|
|
|
DEBUG = False
|
2016-11-10 02:08:22 -05:00
|
|
|
SUPERSET_WEBSERVER_PORT = 8081
|
2016-06-09 21:05:58 -04:00
|
|
|
|
2020-08-06 15:07:22 -04:00
|
|
|
# Allowing SQLALCHEMY_DATABASE_URI and SQLALCHEMY_EXAMPLES_URI to be defined as an env vars for
|
2016-06-09 21:05:58 -04:00
|
|
|
# continuous integration
|
2019-06-25 16:34:48 -04:00
|
|
|
if "SUPERSET__SQLALCHEMY_DATABASE_URI" in os.environ:
|
2019-10-18 17:44:27 -04:00
|
|
|
SQLALCHEMY_DATABASE_URI = os.environ["SUPERSET__SQLALCHEMY_DATABASE_URI"]
|
2016-08-30 00:55:31 -04:00
|
|
|
|
2020-08-06 15:07:22 -04:00
|
|
|
SQLALCHEMY_EXAMPLES_URI = SQLALCHEMY_DATABASE_URI
|
|
|
|
if "SUPERSET__SQLALCHEMY_EXAMPLES_URI" in os.environ:
|
|
|
|
SQLALCHEMY_EXAMPLES_URI = os.environ["SUPERSET__SQLALCHEMY_EXAMPLES_URI"]
|
|
|
|
|
2020-08-27 12:49:18 -04:00
|
|
|
if "UPLOAD_FOLDER" in os.environ:
|
|
|
|
UPLOAD_FOLDER = os.environ["UPLOAD_FOLDER"]
|
|
|
|
|
2020-04-28 17:28:09 -04:00
|
|
|
if "sqlite" in SQLALCHEMY_DATABASE_URI:
|
|
|
|
logger.warning(
|
2020-05-14 11:58:30 -04:00
|
|
|
"SQLite Database support for metadata databases will be "
|
|
|
|
"removed in a future version of Superset."
|
2020-04-28 17:28:09 -04:00
|
|
|
)
|
|
|
|
|
2020-08-27 12:49:18 -04:00
|
|
|
# Speeding up the tests.
|
|
|
|
PRESTO_POLL_INTERVAL = 0.1
|
|
|
|
HIVE_POLL_INTERVAL = 0.1
|
|
|
|
|
2016-08-30 00:55:31 -04:00
|
|
|
SQL_MAX_ROW = 666
|
2020-03-03 12:52:20 -05:00
|
|
|
SQLLAB_CTAS_NO_LIMIT = True # SQL_MAX_ROW will not take affect for the CTA queries
|
2020-10-08 06:55:39 -04:00
|
|
|
FEATURE_FLAGS = {
|
2020-10-13 21:43:06 -04:00
|
|
|
**FEATURE_FLAGS,
|
2020-10-08 06:55:39 -04:00
|
|
|
"foo": "bar",
|
|
|
|
"KV_STORE": True,
|
|
|
|
"SHARE_QUERIES_VIA_KV_STORE": True,
|
|
|
|
"ENABLE_TEMPLATE_PROCESSING": True,
|
2020-10-29 19:47:11 -04:00
|
|
|
"ENABLE_REACT_CRUD_VIEWS": os.environ.get("ENABLE_REACT_CRUD_VIEWS", False),
|
2020-11-05 05:19:48 -05:00
|
|
|
"ROW_LEVEL_SECURITY": True,
|
2020-12-01 20:57:15 -05:00
|
|
|
"ALERT_REPORTS": True,
|
2020-10-08 06:55:39 -04:00
|
|
|
}
|
2019-06-25 16:34:48 -04:00
|
|
|
|
|
|
|
|
2019-02-27 18:11:38 -05:00
|
|
|
def GET_FEATURE_FLAGS_FUNC(ff):
|
|
|
|
ff_copy = copy(ff)
|
2019-06-25 16:34:48 -04:00
|
|
|
ff_copy["super"] = "set"
|
2019-02-27 18:11:38 -05:00
|
|
|
return ff_copy
|
|
|
|
|
2016-08-30 00:55:31 -04:00
|
|
|
|
|
|
|
TESTING = True
|
|
|
|
WTF_CSRF_ENABLED = False
|
2020-08-28 05:49:10 -04:00
|
|
|
|
|
|
|
FAB_ROLES = {"TestRole": [["Security", "menu_access"], ["List Users", "menu_access"]]}
|
|
|
|
|
|
|
|
PUBLIC_ROLE_LIKE = "Gamma"
|
2019-06-25 16:34:48 -04:00
|
|
|
AUTH_ROLE_PUBLIC = "Public"
|
2017-01-24 21:11:51 -05:00
|
|
|
EMAIL_NOTIFICATIONS = False
|
2020-05-14 11:58:30 -04:00
|
|
|
REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
|
|
|
|
REDIS_PORT = os.environ.get("REDIS_PORT", "6379")
|
|
|
|
REDIS_CELERY_DB = os.environ.get("REDIS_CELERY_DB", 2)
|
|
|
|
REDIS_RESULTS_DB = os.environ.get("REDIS_RESULTS_DB", 3)
|
2020-09-15 14:17:21 -04:00
|
|
|
REDIS_CACHE_DB = os.environ.get("REDIS_CACHE_DB", 4)
|
|
|
|
|
2020-11-14 01:35:10 -05:00
|
|
|
CACHE_DEFAULT_TIMEOUT = 600
|
|
|
|
|
2020-09-15 14:17:21 -04:00
|
|
|
CACHE_CONFIG = {
|
|
|
|
"CACHE_TYPE": "redis",
|
2020-11-14 01:35:10 -05:00
|
|
|
"CACHE_DEFAULT_TIMEOUT": 60,
|
2020-09-15 14:17:21 -04:00
|
|
|
"CACHE_KEY_PREFIX": "superset_cache",
|
|
|
|
"CACHE_REDIS_URL": f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_CACHE_DB}",
|
|
|
|
}
|
2020-05-14 11:58:30 -04:00
|
|
|
|
2020-11-14 01:35:10 -05:00
|
|
|
DATA_CACHE_CONFIG = {
|
2020-11-12 03:00:38 -05:00
|
|
|
**CACHE_CONFIG,
|
2020-11-14 01:35:10 -05:00
|
|
|
"CACHE_DEFAULT_TIMEOUT": 30,
|
2020-11-12 03:00:38 -05:00
|
|
|
"CACHE_KEY_PREFIX": "superset_data_cache",
|
|
|
|
}
|
|
|
|
|
feat(SIP-39): Async query support for charts (#11499)
* Generate JWT in Flask app
* Refactor chart data API query logic, add JWT validation and async worker
* Add redis stream implementation, refactoring
* Add chart data cache endpoint, refactor QueryContext caching
* Typing, linting, refactoring
* pytest fixes and openapi schema update
* Enforce caching be configured for async query init
* Async query processing for explore_json endpoint
* Add /api/v1/async_event endpoint
* Async frontend for dashboards [WIP]
* Chart async error message support, refactoring
* Abstract asyncEvent middleware
* Async chart loading for Explore
* Pylint fixes
* asyncEvent middleware -> TypeScript, JS linting
* Chart data API: enforce forced_cache, add tests
* Add tests for explore_json endpoints
* Add test for chart data cache enpoint (no login)
* Consolidate set_and_log_cache and add STORE_CACHE_KEYS_IN_METADATA_DB flag
* Add tests for tasks/async_queries and address PR comments
* Bypass non-JSON result formats for async queries
* Add tests for redux middleware
* Remove debug statement
Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
* Skip force_cached if no queryObj
* SunburstViz: don't modify self.form_data
* Fix failing annotation test
* Resolve merge/lint issues
* Reduce polling delay
* Fix new getClientErrorObject reference
* Fix flakey unit tests
* /api/v1/async_event: increment redis stream ID, add tests
* PR feedback: refactoring, configuration
* Fixup: remove debugging
* Fix typescript errors due to redux upgrade
* Update UPDATING.md
* Fix failing py tests
* asyncEvent_spec.js -> asyncEvent_spec.ts
* Refactor flakey Python 3.7 mock assertions
* Fix another shared state issue in Py tests
* Use 'sub' claim in JWT for user_id
* Refactor async middleware config
* Fixup: restore FeatureFlag boolean type
Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
2020-12-10 23:21:56 -05:00
|
|
|
GLOBAL_ASYNC_QUERIES_JWT_SECRET = "test-secret-change-me-test-secret-change-me"
|
|
|
|
|
2020-05-14 11:58:30 -04:00
|
|
|
|
2016-08-30 00:55:31 -04:00
|
|
|
class CeleryConfig(object):
|
2020-05-14 11:58:30 -04:00
|
|
|
BROKER_URL = f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_CELERY_DB}"
|
2019-06-25 16:34:48 -04:00
|
|
|
CELERY_IMPORTS = ("superset.sql_lab",)
|
2020-05-14 11:58:30 -04:00
|
|
|
CELERY_RESULT_BACKEND = f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_RESULTS_DB}"
|
2019-06-25 16:34:48 -04:00
|
|
|
CELERY_ANNOTATIONS = {"sql_lab.add": {"rate_limit": "10/s"}}
|
2016-08-30 00:55:31 -04:00
|
|
|
CONCURRENCY = 1
|
2017-11-10 20:52:34 -05:00
|
|
|
|
|
|
|
|
2016-08-30 00:55:31 -04:00
|
|
|
CELERY_CONFIG = CeleryConfig
|
2020-04-07 16:00:42 -04:00
|
|
|
|
|
|
|
CUSTOM_TEMPLATE_PROCESSORS = {
|
|
|
|
CustomPrestoTemplateProcessor.engine: CustomPrestoTemplateProcessor
|
|
|
|
}
|
2020-05-27 12:02:03 -04:00
|
|
|
|
|
|
|
PRESERVE_CONTEXT_ON_EXCEPTION = False
|