-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Conversation
cda16ef
to
4e9d829
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
@mistercrunch , @mahendra would you be open to review this PR or suggest who else could help with it ? |
@dpgaspar can you take a look when you have a moment? |
@dpgaspar could you please take a look ? |
FYI @bkyryliuk , @dpgaspar is currently on PTO, will be back tomorrow IIRC. I'll ping him when he's back. |
There was a problem hiding this 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", |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
superset/tasks/schedules.py
Outdated
delay = int(ex.response.headers["Retry-After"]) | ||
logger.info(f"Rate limited. Retrying in {delay} seconds") | ||
time.sleep(delay) | ||
client.files_upload( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
superset/views/schedules.py
Outdated
"test_slack_channel": StringField( | ||
"Test Slack Channel", | ||
default=None, | ||
description="A slack channel to send test message to.", |
There was a problem hiding this comment.
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.",
There was a problem hiding this comment.
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."),
...
....
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
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...
superset/tasks/schedules.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
sorry for the delay, will address the comments today |
a901cfa
to
97fa344
Compare
b096d22
to
0b6cfdd
Compare
There was a problem hiding this 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
superset/tasks/schedules.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this 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
* 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)
* 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>
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:

Here are couple examples on how it looks like in slack.
TEST PLAN
[x] unit tests
[x] local testing
[x] dropbox staging
ADDITIONAL INFORMATION