From 934ba3c17569dabceb5bbc0df64d4d287f3ec0b9 Mon Sep 17 00:00:00 2001 From: Grace Guo Date: Tue, 2 Feb 2021 22:41:25 -0800 Subject: [PATCH] fix: Config for dataset health check (#12906) --- superset/config.py | 13 +++++++++---- superset/connectors/sqla/models.py | 8 +++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/superset/config.py b/superset/config.py index 2febf07acd254..3f8bd52fbd66d 100644 --- a/superset/config.py +++ b/superset/config.py @@ -1055,6 +1055,15 @@ 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 + +# ------------------------------------------------------------------- +# * 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. @@ -1081,7 +1090,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 6969bf5442da3..c8c160f29d0b4 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -704,7 +704,13 @@ 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 + # 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") + else None + ) return data_ @property