From 94fc5d586e225e569250d16f7b1efc3b619af78c Mon Sep 17 00:00:00 2001 From: Daniel Vaz Gaspar Date: Fri, 5 Mar 2021 09:40:08 +0000 Subject: [PATCH] docs: deprecate old alerts and dash/charts reports (#13440) * docs: deprecated old alerts and dash/charts reports * revert celery default config * fix lint --- UPDATING.md | 7 ++++ .../docs/installation/alerts_reports.mdx | 2 +- superset/app.py | 7 ++++ superset/config.py | 27 ++++++++++--- superset/tasks/slack_util.py | 3 ++ superset/views/alerts.py | 24 ++++++++++- superset/views/schedules.py | 40 ++++++++++++++++++- 7 files changed, 100 insertions(+), 10 deletions(-) diff --git a/UPDATING.md b/UPDATING.md index 18f6e80812620..c9dfb1df32706 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -26,6 +26,13 @@ assists people when migrating to a new version. ### Breaking Changes ### Potential Downtime ### Deprecations +- [11509](https://github.com/apache/superset/pull/12491): Dashboard/Charts reports and old Alerts is deprecated. The following config keys are deprecated: + - ENABLE_ALERTS + - SCHEDULED_EMAIL_DEBUG_MODE + - EMAIL_REPORTS_CRON_RESOLUTION + - EMAIL_ASYNC_TIME_LIMIT_SEC + - EMAIL_REPORT_BCC_ADDRESS + - EMAIL_REPORTS_USER ### Other [shillelagh](https://github.com/betodealmeida/shillelagh/) is now the recommended module to connect Superset to Google Spreadsheets, since it's more robust and has extensive test coverage. You should uninstall the `gsheetsdb` module and install the `shillelagh` module in its place. Shillelagh is a drop-in replacement, so no modifications are needed to be done on existing queries, datasets or charts. diff --git a/docs/src/pages/docs/installation/alerts_reports.mdx b/docs/src/pages/docs/installation/alerts_reports.mdx index a8a4e46238749..b6fa9b2d24f8b 100644 --- a/docs/src/pages/docs/installation/alerts_reports.mdx +++ b/docs/src/pages/docs/installation/alerts_reports.mdx @@ -343,7 +343,7 @@ are not accessible to unauthorized requests, that is why the worker needs to tak of an existing user to take a snapshot. ```python -EMAIL_REPORTS_USER = 'username_with_permission_to_access_dashboards' +THUMBNAIL_SELENIUM_USER = 'username_with_permission_to_access_dashboards' ``` **Important notes** diff --git a/superset/app.py b/superset/app.py index feaf0d82c7ee0..432d3fb4639d2 100644 --- a/superset/app.py +++ b/superset/app.py @@ -412,6 +412,10 @@ def init_views(self) -> None: # Conditionally setup email views # if self.config["ENABLE_SCHEDULED_EMAIL_REPORTS"]: + logging.warning( + "ENABLE_SCHEDULED_EMAIL_REPORTS " + "is deprecated and will be removed in version 2.0.0" + ) appbuilder.add_separator("Manage") appbuilder.add_view( DashboardEmailScheduleView, @@ -431,6 +435,9 @@ def init_views(self) -> None: ) if self.config["ENABLE_ALERTS"]: + logging.warning( + "ENABLE_ALERTS is deprecated and will be removed in version 2.0.0" + ) appbuilder.add_view( AlertModelView, "Alerts", diff --git a/superset/config.py b/superset/config.py index 622ff056bc63c..94abd64cd997f 100644 --- a/superset/config.py +++ b/superset/config.py @@ -424,6 +424,7 @@ def _try_json_readsha( # pylint: disable=unused-argument # --------------------------------------------------- # Thumbnail config (behind feature flag) +# Also used by Alerts & Reports # --------------------------------------------------- THUMBNAIL_SELENIUM_USER = "admin" THUMBNAIL_CACHE_CONFIG: CacheConfig = { @@ -891,24 +892,35 @@ class CeleryConfig: # pylint: disable=too-few-public-methods SQL_QUERY_MUTATOR = None # Enable / disable scheduled email reports +# +# Warning: This config key is deprecated and will be removed in version 2.0.0" ENABLE_SCHEDULED_EMAIL_REPORTS = False # Enable / disable Alerts, where users can define custom SQL that # will send emails with screenshots of charts or dashboards periodically # if it meets the criteria +# +# Warning: This config key is deprecated and will be removed in version 2.0.0" ENABLE_ALERTS = False +# --------------------------------------------------- +# Alerts & Reports +# --------------------------------------------------- # Used for Alerts/Reports (Feature flask ALERT_REPORTS) to set the size for the # sliding cron window size, should be synced with the celery beat config minus 1 second ALERT_REPORTS_CRON_WINDOW_SIZE = 59 +# A custom prefix to use on all Alerts & Reports emails +EMAIL_REPORTS_SUBJECT_PREFIX = "[Report] " # Slack API token for the superset reports SLACK_API_TOKEN = None SLACK_PROXY = None -# If enabled, certail features are run in debug mode +# If enabled, certain features are run in debug mode # Current list: # * Emails are sent using dry-run mode (logging only) +# +# Warning: This config key is deprecated and will be removed in version 2.0.0" SCHEDULED_EMAIL_DEBUG_MODE = False # This auth provider is used by background (offline) tasks that need to access @@ -917,26 +929,29 @@ class CeleryConfig: # pylint: disable=too-few-public-methods MACHINE_AUTH_PROVIDER_CLASS = "superset.utils.machine_auth.MachineAuthProvider" # Email reports - minimum time resolution (in minutes) for the crontab +# +# Warning: This config key is deprecated and will be removed in version 2.0.0" EMAIL_REPORTS_CRON_RESOLUTION = 15 # The MAX duration (in seconds) a email schedule can run for before being killed # by celery. +# +# Warning: This config key is deprecated and will be removed in version 2.0.0" EMAIL_ASYNC_TIME_LIMIT_SEC = 300 -# Email report configuration -# From address in emails -EMAIL_REPORT_FROM_ADDRESS = "reports@superset.org" - # Send bcc of all reports to this address. Set to None to disable. # This is useful for maintaining an audit trail of all email deliveries. +# +# Warning: This config key is deprecated and will be removed in version 2.0.0" EMAIL_REPORT_BCC_ADDRESS = None # User credentials to use for generating reports # This user should have permissions to browse all the dashboards and # slices. # TODO: In the future, login as the owner of the item to generate reports +# +# Warning: This config key is deprecated and will be removed in version 2.0.0" EMAIL_REPORTS_USER = "admin" -EMAIL_REPORTS_SUBJECT_PREFIX = "[Report] " # The webdriver to use for generating reports. Use one of the following # firefox diff --git a/superset/tasks/slack_util.py b/superset/tasks/slack_util.py index a646d7df77a84..9cb8c9179eef1 100644 --- a/superset/tasks/slack_util.py +++ b/superset/tasks/slack_util.py @@ -14,6 +14,9 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +""" +DEPRECATION NOTICE: this module is deprecated and will be removed on 2.0. +""" import logging from io import IOBase from typing import cast, Optional, Union diff --git a/superset/views/alerts.py b/superset/views/alerts.py index a72fd6741207a..46538dedd3800 100644 --- a/superset/views/alerts.py +++ b/superset/views/alerts.py @@ -14,8 +14,12 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +""" +DEPRECATION NOTICE: this module is deprecated and will be removed on 2.0. +""" + from croniter import croniter -from flask import abort +from flask import abort, flash, Markup from flask_appbuilder import CompactCRUDMixin, permission_name from flask_appbuilder.api import expose from flask_appbuilder.models.sqla.interface import SQLAInterface @@ -81,7 +85,6 @@ def list(self) -> FlaskResponse: and is_feature_enabled("ALERT_REPORTS") ): return abort(404) - return super().render_app_template() @expose("//log/", methods=["GET"]) @@ -209,6 +212,23 @@ class AlertModelView(SupersetModelView): # pylint: disable=too-many-ancestors AlertLogModelView, ] + @expose("/list/") + @has_access + def list(self) -> FlaskResponse: + flash( + Markup( + _( + "This feature is deprecated and will be removed on 2.0. " + "Take a look at the replacement feature " + "" + "Alerts & Reports documentation" + ) + ), + "warning", + ) + return super().list() + def pre_add(self, item: "AlertModelView") -> None: item.recipients = get_email_address_str(item.recipients) diff --git a/superset/views/schedules.py b/superset/views/schedules.py index d98c339b60ec3..d463390673f58 100644 --- a/superset/views/schedules.py +++ b/superset/views/schedules.py @@ -14,12 +14,16 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +""" +DEPRECATION NOTICE: this module is deprecated and will be removed on 2.0. +""" + import enum from typing import Type, Union import simplejson as json from croniter import croniter -from flask import flash, g +from flask import flash, g, Markup from flask_appbuilder import expose from flask_appbuilder.models.sqla.interface import SQLAInterface from flask_appbuilder.security.decorators import has_access @@ -232,6 +236,23 @@ class DashboardEmailScheduleView( "delivery_type": _("Delivery Type"), } + @expose("/list/") + @has_access + def list(self) -> FlaskResponse: + flash( + Markup( + _( + "This feature is deprecated and will be removed on 2.0. " + "Take a look at the replacement feature " + "" + "Alerts & Reports documentation" + ) + ), + "warning", + ) + return super().list() + def pre_add(self, item: "DashboardEmailScheduleView") -> None: if item.dashboard is None: raise SupersetException("Dashboard is mandatory") @@ -296,6 +317,23 @@ class SliceEmailScheduleView(EmailScheduleView): # pylint: disable=too-many-anc "email_format": _("Email Format"), } + @expose("/list/") + @has_access + def list(self) -> FlaskResponse: + flash( + Markup( + _( + "This feature is deprecated and will be removed on 2.0. " + "Take a look at the replacement feature " + "" + "Alerts & Reports documentation" + ) + ), + "warning", + ) + return super().list() + def pre_add(self, item: "SliceEmailScheduleView") -> None: if item.slice is None: raise SupersetException("Slice is mandatory")