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
fix: annotation layer json #9915
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9915 +/- ##
==========================================
- Coverage 71.23% 71.20% -0.04%
==========================================
Files 585 585
Lines 30870 30742 -128
Branches 3239 3239
==========================================
- Hits 21990 21889 -101
+ Misses 8771 8744 -27
Partials 109 109
Continue to review full report at Codecov.
|
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.
@etr2460 could you add/modify a unit test which would prevent this from happening in the future?
I had a lot of trouble building an annotation layer mock for this, but i'll try some more to get a unit test out |
@john-bodley, I tried my best to add a test here, but wasn't able to get it to work due to an issue (maybe with FAB?). Here's my test code (also added in a commit to this PR): def test_annotation_json_endpoint(self):
# Something is broken with annotations and RLS, teardown will undo this
app.config["ENABLE_ROW_LEVEL_SECURITY"] = False
self.login(username="admin")
# Set up an annotation layer and annotation
self.get_resp(
"/annotationlayermodelview/add",
{"form_data": json.dumps({"name": "foo", "descr": "bar"})},
)
self.get_resp(
"/annotationmodelview/add",
{
"form_data": json.dumps(
{
"layer": "1",
"short_descr": "my_annotation",
"start_dttm": "2020-05-20 18:21:51",
"end_dttm": "2020-05-20 18:31:51",
}
)
},
)
resp = self.get_resp(
"/superset/annotation_json/1?form_data=%7B%22time_range%22%3A%22100+years+ago+%3A+now%22%7D"
)
assert "my_annotation" in resp And the error I saw:
It looks like when I'm trying to create an annotation inside the annotation layer, it's rendering a template instead of creating the new annotation. Maybe @dpgaspar has thoughts here? |
Thanks for the test fix @john-bodley! I confirmed that the test fails without my fix, and works with it |
* fix: annotation layer json * attempt to add a test * [tests] Fixing test Co-authored-by: John Bodley <john.bodley@airbnb.com>
SUMMARY
The
annotation_json
API makes use of the TableViz to structure the data returned from it. However, in #9122, we started limiting the columns that were returned, breaking this API. No one caught it because annotations were broken for a variety of other reasons, but I believe that this change should resolve all annotation layer issues remainingBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
After:
TEST PLAN
Test a chart with an annotation layer added and see the annotation display on the chart
ADDITIONAL INFORMATION
to: @john-bodley @graceguo-supercat @villebro