ktmud commented on a change in pull request #11970:
URL: 
https://github.com/apache/incubator-superset/pull/11970#discussion_r543738483



##########
File path: superset/connectors/sqla/models.py
##########
@@ -1467,6 +1473,29 @@ class and any keys added via `ExtraCache`.
             extra_cache_keys += sqla_query.extra_cache_keys
         return extra_cache_keys
 
+    def health_check(self, commit: bool = False, force: bool = False) -> None:
+        check = config["DATASET_HEALTH_CHECK"]
+        if check is None:
+            return
+
+        extra = self.extra_dict
+        # force re-run health check, or health check is updated
+        if force or extra.get("health_check", {}).get("version") != 
check.version:
+            with event_logger.log_context(action="dataset_health_check"):
+                message = check(self)
+                if message:
+                    extra["health_check"] = {
+                        "version": check.version,
+                        "message": message,
+                    }

Review comment:
       I would also recommend making the message more structured for 
scalability (i.e. let DATASET_HEALTH_CHECK return a dict instead of a string). 
Because in the future, you may need to localize the warning message, then it 
would be better to store an ERROR_CODE + some metadata instead of just a 
message string. This also opens the door for more actionable warning message 
where users may click on the warning icon and open a popup for more details.
   
   Maybe we can even define it as a new SupersetError type and use @etr2460 's 
[error message registry](superset-frontend/src/setup/setupErrorMessages.ts) to 
render it.
   
   But of course, this could also be reserved for future refactor/extension. 
(We can always update the health check version when that happens!)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to