From 6bc9931a29d47bdc847e24d000cce0cd1312ba05 Mon Sep 17 00:00:00 2001 From: Grace Date: Tue, 2 Feb 2021 17:03:14 -0800 Subject: [PATCH 1/2] fix: Configurateion for dataset health check --- superset/config.py | 8 ++++---- superset/connectors/sqla/models.py | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/superset/config.py b/superset/config.py index 32638d9ab6af2..b8f810159a864 100644 --- a/superset/config.py +++ b/superset/config.py @@ -1074,6 +1074,10 @@ class CeleryConfig: # pylint: disable=too-few-public-methods GLOBAL_ASYNC_QUERIES_TRANSPORT = "polling" GLOBAL_ASYNC_QUERIES_POLLING_DELAY = 500 +# It's possible to add a dataset health check logic which is specific to your system. +# It will get executed each time when user open a chart's explore view. +DATASET_HEALTH_CHECK = None + if CONFIG_PATH_ENV_VAR in os.environ: # Explicitly import config module that is not necessarily in pythonpath; useful # for case where app is being executed via pex. @@ -1100,7 +1104,3 @@ class CeleryConfig: # pylint: disable=too-few-public-methods except Exception: logger.exception("Found but failed to import local superset_config") raise - -# It's possible to add a dataset health check logic which is specific to your system. -# It will get executed each time when user open a chart's explore view. -DATASET_HEALTH_CHECK = None diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index 1881e680fe84a..13599a26b7c20 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -704,7 +704,11 @@ def data(self) -> Dict[str, Any]: data_["fetch_values_predicate"] = self.fetch_values_predicate data_["template_params"] = self.template_params data_["is_sqllab_view"] = self.is_sqllab_view - data_["health_check_message"] = self.health_check_message + data_["health_check_message"] = ( + self.health_check_message + if config.get("DATASET_HEALTH_CHECK") + else None + ) return data_ @property From c2fefb630df66e8e5494ce5ac776a577976ae998 Mon Sep 17 00:00:00 2001 From: Grace Date: Tue, 2 Feb 2021 18:13:23 -0800 Subject: [PATCH 2/2] add extra comments to avoid happening again --- superset/config.py | 5 +++++ superset/connectors/sqla/models.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/superset/config.py b/superset/config.py index b8f810159a864..8ea153aa1a32e 100644 --- a/superset/config.py +++ b/superset/config.py @@ -1078,6 +1078,11 @@ class CeleryConfig: # pylint: disable=too-few-public-methods # It will get executed each time when user open a chart's explore view. DATASET_HEALTH_CHECK = None +# ------------------------------------------------------------------- +# * WARNING: STOP EDITING HERE * +# ------------------------------------------------------------------- +# Don't add config values below this line since local configs won't be +# able to override them. if CONFIG_PATH_ENV_VAR in os.environ: # Explicitly import config module that is not necessarily in pythonpath; useful # for case where app is being executed via pex. diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index 13599a26b7c20..833f3fc8267f5 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -704,6 +704,8 @@ def data(self) -> Dict[str, Any]: data_["fetch_values_predicate"] = self.fetch_values_predicate data_["template_params"] = self.template_params data_["is_sqllab_view"] = self.is_sqllab_view + # Don't return previously populated health check message in case + # the health check feature is turned off data_["health_check_message"] = ( self.health_check_message if config.get("DATASET_HEALTH_CHECK")