-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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(alerts): Select tabs to send backend #17749
feat(alerts): Select tabs to send backend #17749
Conversation
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.
awesome tests! a few minor comments, but everything makes sense to me
superset/models/reports.py
Outdated
@@ -16,6 +16,8 @@ | |||
# under the License. | |||
"""A collection of ORM sqlalchemy models for Superset""" | |||
import enum | |||
import json | |||
import typing |
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.
i think in most of the code we do from typing import Any, Optional, etc.
superset/reports/commands/create.py
Outdated
tab_id for tab_id in dashboard_tab_ids if tab_id not in position_data | ||
] | ||
if invalid_tab_ids: | ||
exceptions.append(ValidationError("Invalid tab IDs selected", "extra")) |
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.
should we append the invalid tab ids to the error message? If not, then we don't need to find all of them, and can instead just check if dashboard_tab_ids is a subset of position_data. Like this:
if not set(dashboard_tab_ids).issubset.(set(position_data.keys())):
raise Exception
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.
i think let owners know which tab_id is invalid is important. So i prefer to keep invalid_tab_ids
and add it to error message.
superset/reports/commands/execute.py
Outdated
for screenshot in screenshots: | ||
image = screenshot.get_screenshot(user=user) | ||
if image is not None: | ||
image_data.append(image) | ||
except SoftTimeLimitExceeded as ex: |
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 is a bit concerning, because now we're asking you to complete all the screenshots in the same time originally alotted to a single one. I guess we could either increase the time limit, or try to do them in parallel
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 try add time limit on each of screenshot?
04a154f
to
4683f5c
Compare
Codecov Report
@@ Coverage Diff @@
## master #17749 +/- ##
==========================================
- Coverage 67.07% 67.05% -0.03%
==========================================
Files 1609 1610 +1
Lines 64899 65073 +174
Branches 6866 6866
==========================================
+ Hits 43533 43634 +101
- Misses 19500 19573 +73
Partials 1866 1866
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
7163167
to
ed53f56
Compare
ed53f56
to
d954835
Compare
@dpgaspar @betodealmeida we are trying to implements an improvement for dashboard email report: allow user to select one or more dashboard tabs, and send them in a single email report. see description in this issue. This PR is backend part and we have another one for front-end tab selector. Ajay started the project but left, so I will take over the rest and finish it. i saw you had some commits for the Alert and Report feature. please let me know if you have any concerns on our solution. Thanks. |
Ajay will not work for Superset anymore...i will update description. |
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 looks great! I left a few minor nits, but this looks solid!
else "" | ||
) | ||
img_tag = "" | ||
for msgid, _ in images.items(): |
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.
Nit:
for msgid, _ in images.items(): | |
for msgid in images.keys(): |
(Or just images
instead of images.keys()
, though I think explicit is better.)
@@ -27,7 +27,7 @@ | |||
class NotificationContent: | |||
name: str | |||
csv: Optional[bytes] = None # bytes for csv file | |||
screenshot: Optional[bytes] = None # bytes for the screenshot | |||
screenshots: Optional[List[bytes]] = None # bytes for the screenshot |
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.
Nit:
screenshots: Optional[List[bytes]] = None # bytes for the screenshot | |
screenshots: Optional[List[bytes]] = None # bytes for the screenshots |
) | ||
img_tag = "" | ||
for msgid, _ in images.items(): | ||
img_tag = img_tag + ( |
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.
Nit, it's more idiomatic to do this by join
ing a List[str]
:
img_tags = []
for msgid in images.keys():
img_tags.append('<div ...>')
img_tag = ''.join(img_tags)
Thanks @betodealmeida! i added extra fixes per comments, will merge after CI passed. |
* Adding the extra config and validation * wip * reports working * Tests working * fix type * Fix lint errors * Fixing type issues * add licence header * fix the fixture deleting problem * scope to session * fix integration test * fix review comments * fix review comments patch 2 Co-authored-by: Grace Guo <grace.guo@airbnb.com>
* Adding the extra config and validation * wip * reports working * Tests working * fix type * Fix lint errors * Fixing type issues * add licence header * fix the fixture deleting problem * scope to session * fix integration test * fix review comments * fix review comments patch 2 Co-authored-by: Grace Guo <grace.guo@airbnb.com>
SUMMARY
For a large dashboard that have multiple tabs, users want to get email report on a specific tabs (or nested tabs). So we proposed a feature request to allow user select tab(s) when setup dashboard report. This PR is a backend piece for validating tab selection, store the selected tab with report schedule, and taking a list of selected tabs screenshot for a dashboard report.
TESTING INSTRUCTIONS
added integration tests.
ADDITIONAL INFORMATION