Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: superset report slack integration #9810

Merged
merged 3 commits into from
Jun 17, 2020

Conversation

bkyryliuk
Copy link
Member

@bkyryliuk bkyryliuk commented May 14, 2020

SUMMARY

Implements slack support for the superset scheduled reports. This is a simple extension of the existing email functionality.

It also includes a some refactor that decouple the utility functions from the email schedule object to keep them reusable for other features, e.g. alerting

Form:
image

Here are couple examples on how it looks like in slack.

image
image
image

TEST PLAN

[x] unit tests
[x] local testing
[x] dropbox staging

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@bkyryliuk bkyryliuk marked this pull request as draft May 14, 2020 21:47
@mistercrunch
Copy link
Member

omg

@bkyryliuk bkyryliuk closed this May 18, 2020
@bkyryliuk bkyryliuk reopened this May 18, 2020
@bkyryliuk bkyryliuk force-pushed the bogdan/slack branch 6 times, most recently from cda16ef to 4e9d829 Compare May 18, 2020 21:45
@codecov-io
Copy link

codecov-io commented May 18, 2020

Codecov Report

Merging #9810 into master will decrease coverage by 0.03%.
The diff coverage is 65.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9810      +/-   ##
==========================================
- Coverage   71.01%   70.98%   -0.04%     
==========================================
  Files         586      583       -3     
  Lines       30635    30643       +8     
  Branches     3159     3154       -5     
==========================================
- Hits        21756    21751       -5     
- Misses       8768     8781      +13     
  Partials      111      111              
Flag Coverage Δ
#cypress 53.55% <ø> (-0.03%) ⬇️
#javascript 59.25% <ø> (+0.01%) ⬆️
#python 71.22% <65.15%> (-0.05%) ⬇️
Impacted Files Coverage Δ
superset/views/schedules.py 59.29% <0.00%> (-1.62%) ⬇️
superset/tasks/schedules.py 75.94% <67.79%> (-3.87%) ⬇️
superset/config.py 89.66% <100.00%> (+0.08%) ⬆️
superset/models/schedules.py 89.79% <100.00%> (+0.21%) ⬆️
superset-frontend/src/SqlLab/actions/sqlLab.js 66.81% <0.00%> (ø)
...rset-frontend/src/components/ListView/ListView.tsx 98.07% <0.00%> (ø)
...frontend/src/components/ListView/LegacyFilters.tsx 75.00% <0.00%> (ø)
...rontend/src/explore/components/PropertiesModal.tsx 16.17% <0.00%> (ø)
...src/SqlLab/components/ExploreCtasResultsButton.jsx 13.33% <0.00%> (ø)
...rset-frontend/src/components/OptionDescription.jsx
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a95c52...4e9d829. Read the comment docs.

@codecov-commenter
Copy link

codecov-commenter commented May 19, 2020

Codecov Report

Merging #9810 into master will increase coverage by 0.02%.
The diff coverage is 85.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9810      +/-   ##
==========================================
+ Coverage   70.41%   70.43%   +0.02%     
==========================================
  Files         585      586       +1     
  Lines       31058    31090      +32     
  Branches     3267     3277      +10     
==========================================
+ Hits        21868    21899      +31     
- Misses       9079     9080       +1     
  Partials      111      111              
Flag Coverage Δ
#cypress 53.93% <ø> (+0.07%) ⬆️
#javascript 59.36% <ø> (ø)
#python 70.03% <85.07%> (+0.03%) ⬆️
Impacted Files Coverage Δ
superset/views/schedules.py 59.32% <0.00%> (-1.55%) ⬇️
superset/tasks/schedules.py 79.91% <86.36%> (+0.47%) ⬆️
superset/config.py 89.95% <100.00%> (+0.08%) ⬆️
superset/models/schedules.py 89.79% <100.00%> (+0.21%) ⬆️
superset/tasks/slack_util.py 100.00% <100.00%> (ø)
...rontend/src/SqlLab/components/QueryAutoRefresh.jsx 72.72% <0.00%> (+6.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 280b4dc...0b6cfdd. Read the comment docs.

@bkyryliuk bkyryliuk changed the title feat: [WIP] Superset report slack integration feat: superset report slack integration May 19, 2020
@bkyryliuk bkyryliuk marked this pull request as ready for review May 19, 2020 17:06
@bkyryliuk
Copy link
Member Author

@mistercrunch , @mahendra would you be open to review this PR or suggest who else could help with it ?

@mistercrunch
Copy link
Member

@dpgaspar can you take a look when you have a moment?

@bkyryliuk
Copy link
Member Author

@dpgaspar could you please take a look ?
It is in dbx production and has been working fine for a while

@villebro villebro requested a review from dpgaspar May 28, 2020 05:56
@villebro
Copy link
Member

FYI @bkyryliuk , @dpgaspar is currently on PTO, will be back tomorrow IIRC. I'll ping him when he's back.

Copy link
Member

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass, also it would be really nice to add some documentation around this new feature

setup.py Outdated
@@ -102,6 +102,7 @@ def get_git_sha():
"retry>=0.9.2",
"selenium>=3.141.0",
"simplejson>=3.15.0",
"slackclient>=2.5.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we bump to the latest 2.6.2, and what do you think about making this requirement optional (extras)

requirements.txt Outdated
@@ -83,6 +83,7 @@ six==1.14.0 # via bleach, cryptography, flask-jwt-extended, flask-
sqlalchemy-utils==0.36.4 # via apache-superset (setup.py), flask-appbuilder
sqlalchemy==1.3.16 # via alembic, apache-superset (setup.py), flask-sqlalchemy, marshmallow-sqlalchemy, sqlalchemy-utils
sqlparse==0.3.1 # via apache-superset (setup.py)
slackclient==2.5.0 # via apache-superset (setup.py)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we bump to the latest 2.6.2

delay = int(ex.response.headers["Retry-After"])
logger.info(f"Rate limited. Retrying in {delay} seconds")
time.sleep(delay)
client.files_upload(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second retry can fail again, also I wonder how will this behave on high concurrency. May be over optimisation but we could consider a simple loop count or a simple form of exponential backoff

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, will keep it simple

"test_slack_channel": StringField(
"Test Slack Channel",
default=None,
description="A slack channel to send test message to.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description="A slack channel to send a test message to.",

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also missing translations:

 from flask_babel import lazy_gettext as _

"test_slack_channel": StringField(
            _("Test Slack Channel"),
            default=None,
            description=_("A slack channel to send test message to."),
...
....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file doesn't have translations, should probably be a separate PR

superset/tasks/schedules.py Outdated Show resolved Hide resolved
Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slack

requirements.txt Outdated
@@ -4,92 +4,87 @@
#
# pip-compile --output-file=requirements.txt setup.py
#
alembic==1.4.2 # via flask-migrate
alembic==1.3.2 # via flask-migrate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a bad rebase here, lots of downgrades...

@@ -33,24 +33,25 @@
from flask import render_template, Response, session, url_for
from flask_babel import gettext as __
from flask_login import login_user
from retry.api import retry_call
from retry.api import retry, retry_call
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

schedules.py is getting pretty big, would it make sense to have autils/slack.py?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good suggestion, moved slack to tasks/slack_util.py for now as there is a single use case, once we have new use case like alerting -> will move to the shared util.
Also added TODO to do the same for email functions

@bkyryliuk
Copy link
Member Author

sorry for the delay, will address the comments today

@bkyryliuk bkyryliuk force-pushed the bogdan/slack branch 5 times, most recently from a901cfa to 97fa344 Compare June 9, 2020 22:20
@bkyryliuk bkyryliuk force-pushed the bogdan/slack branch 8 times, most recently from b096d22 to 0b6cfdd Compare June 10, 2020 01:03
Copy link
Member Author

@bkyryliuk bkyryliuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mistercrunch , @dpgaspar ready for more feedback

@@ -33,24 +33,25 @@
from flask import render_template, Response, session, url_for
from flask_babel import gettext as __
from flask_login import login_user
from retry.api import retry_call
from retry.api import retry, retry_call
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good suggestion, moved slack to tasks/slack_util.py for now as there is a single use case, once we have new use case like alerting -> will move to the shared util.
Also added TODO to do the same for email functions

Copy link
Member

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Fix slack

another typo

another typo

Fix slack

Add channels to the form

another typo

Another set of changes

Make code more transparent

Fix tests

Add logging

logging

use logger

import logging

import logging

import logging

add assert

more logging

Fix channels

Fix channels
@bkyryliuk bkyryliuk merged commit 29e9f2c into apache:master Jun 17, 2020
@bkyryliuk bkyryliuk deleted the bogdan/slack branch June 17, 2020 18:01
john-bodley pushed a commit to airbnb/superset-fork that referenced this pull request Jun 24, 2020
* First draft for the slack integration

Fix slack

another typo

another typo

Fix slack

Add channels to the form

another typo

Another set of changes

Make code more transparent

Fix tests

Add logging

logging

use logger

import logging

import logging

import logging

add assert

more logging

Fix channels

Fix channels

* Address comments

* Move slack into a separate module

Co-authored-by: bogdan kyryliuk <bogdankyryliuk@dropbox.com>
(cherry picked from commit 29e9f2c)
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* First draft for the slack integration

Fix slack

another typo

another typo

Fix slack

Add channels to the form

another typo

Another set of changes

Make code more transparent

Fix tests

Add logging

logging

use logger

import logging

import logging

import logging

add assert

more logging

Fix channels

Fix channels

* Address comments

* Move slack into a separate module

Co-authored-by: bogdan kyryliuk <bogdankyryliuk@dropbox.com>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.37.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L v0.37 🚢 0.37.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants