Skip to content

Commit

Permalink
docs: deprecate old alerts and dash/charts reports (#13440)
Browse files Browse the repository at this point in the history
* docs: deprecated old alerts and dash/charts reports

* revert celery default config

* fix lint
  • Loading branch information
dpgaspar authored Mar 5, 2021
1 parent 9fc03f0 commit 94fc5d5
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 10 deletions.
7 changes: 7 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/docs/installation/alerts_reports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
7 changes: 7 additions & 0 deletions superset/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand Down
27 changes: 21 additions & 6 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand All @@ -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 = "[email protected]"

# 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
Expand Down
3 changes: 3 additions & 0 deletions superset/tasks/slack_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions superset/views/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -81,7 +85,6 @@ def list(self) -> FlaskResponse:
and is_feature_enabled("ALERT_REPORTS")
):
return abort(404)

return super().render_app_template()

@expose("/<pk>/log/", methods=["GET"])
Expand Down Expand Up @@ -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 "
"<a href="
"'https://superset.apache.org/docs/installation/alerts-reports'>"
"Alerts & Reports documentation</a>"
)
),
"warning",
)
return super().list()

def pre_add(self, item: "AlertModelView") -> None:
item.recipients = get_email_address_str(item.recipients)

Expand Down
40 changes: 39 additions & 1 deletion superset/views/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "
"<a href="
"'https://superset.apache.org/docs/installation/alerts-reports'>"
"Alerts & Reports documentation</a>"
)
),
"warning",
)
return super().list()

def pre_add(self, item: "DashboardEmailScheduleView") -> None:
if item.dashboard is None:
raise SupersetException("Dashboard is mandatory")
Expand Down Expand Up @@ -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 "
"<a href="
"'https://superset.apache.org/docs/installation/alerts-reports'>"
"Alerts & Reports documentation</a>"
)
),
"warning",
)
return super().list()

def pre_add(self, item: "SliceEmailScheduleView") -> None:
if item.slice is None:
raise SupersetException("Slice is mandatory")
Expand Down

0 comments on commit 94fc5d5

Please sign in to comment.