-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
chore(explore): Get Explore data from endpoint instead of bootstrap_data #20519
Conversation
Codecov Report
@@ Coverage Diff @@
## master #20519 +/- ##
==========================================
+ Coverage 66.78% 66.80% +0.01%
==========================================
Files 1752 1754 +2
Lines 65461 65562 +101
Branches 6916 6932 +16
==========================================
+ Hits 43719 43799 +80
- Misses 19994 20009 +15
- Partials 1748 1754 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
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.
Thank you for the PR @kgabryje. I left some first-pass comments.
superset-frontend/src/explore/exploreUtils/getParsedExploreURLParams.test.ts
Outdated
Show resolved
Hide resolved
|
||
export const HYDRATE_EXPLORE = 'HYDRATE_EXPLORE'; | ||
export const hydrateExplore = | ||
({ form_data, slice, dataset: datasource }: ExplorePageInitialData) => |
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 endpoint also returns a message
attribute that contains information related to the request. One example is when we request /explore
with an invalid form_data_key
. In this case, message
will contain Form data not found in cache, reverting to chart metadata.
and this should be presented to the user in a toast.
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 some other part of the code is already handling displaying the message in toast - it shows up when form_data_key is wrong. When I manually added danger toast with message, it was displayed twice
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 you confirm what part? I'm only asking because the attribute message
didn't exist previously, I added it to the return type with the new endpoint 🤔
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.
/testenv up |
@stephenLYZ Ephemeral environment spinning up at http://34.216.144.176:8080. Credentials are |
found a bug: blank page when create chart from the + button Screen.Recording.2022-06-29.at.12.19.30.AM.mov |
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.
thanks for your hard work, leave some comments.
const fetchExploreData = async () => { | ||
const { result } = await makeApi<{}, ExploreResponsePayload>({ | ||
method: 'GET', | ||
endpoint: 'api/v1/explore/', | ||
})(exploreUrlParams); | ||
dispatch(hydrateExplore(result)); | ||
setIsLoaded(true); | ||
}; |
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.
We have to process the response that contains the error code, 1) should return a default explore state 2) hide the loading spin.
using the following snippet to debug this case.
(superset) yongjie.zhao@:incubator-superset$ git diff
diff --git a/superset/explore/api.py b/superset/explore/api.py
index 7cce592d3..b697c4a17 100644
--- a/superset/explore/api.py
+++ b/superset/explore/api.py
@@ -105,6 +105,7 @@ class ExploreRestApi(BaseApi):
500:
$ref: '#/components/responses/500'
"""
+ return self.response_404()
try:
params = CommandParameters(
actor=g.user,
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.
Good point!
export const hydrateExplore = | ||
({ form_data, slice, dataset: datasource }: ExplorePageInitialData) => | ||
(dispatch: Dispatch, getState: () => ExplorePageState) => { | ||
const initialFormData = form_data; |
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 we should construct an appropriate/default formData here so that supports to open dataset.
const initialFormData = slice?.form_data ? slice.form_data : form_data;
const initialData = { form_data, slice, datasource };
const initialControls = getControlsState(
initialData,
initialFormData,
) as ControlStateMapping;
const { user, datasources, charts } = getState();
const exploreState = {
....
....
controls: initialControls,
....
}
....
....
const sliceFormData = slice
? getFormDataFromControls(initialControls)
: null;
/testenv up |
@kgabryje Ephemeral environment spinning up at http://52.12.110.64:8080. Credentials are |
7c67a6f
to
24bc86b
Compare
@kgabryje @jinghua-qa I leave a few common use cases so that we can test this PR
|
Also see issue 2 and 4, issue 6 is current issue on master |
Thank you so much @zhaoyongjie @jinghua-qa ! I'll fix issues 2 and 4, let's address issue 6 in separate PR since it's already on master |
Ephemeral environment shutdown and build artifacts deleted. |
Wondering if we should add these cases to Cypress as these seems all scenarios that should have failed in CI. The code LGTM. I am going to pull this branch as I need it as a base to test another PR and I will report all eventual issues that I find, if any. P.S. Sorry didn't mean to close the PR :) |
Agreed. I'll create a task for the next sprint |
/testenv up |
@kgabryje Ephemeral environment spinning up at http://18.236.74.190:8080. Credentials are |
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 main process test passed. continue to polish in the future.
Good idea!! |
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. Thank you for all the hard work @kgabryje! This is amazing and greatly simplifies the application. Thank you for addressing all the comments and bugs as well.
Let's just get QA's approval before merging it because of the high risk 😉
Tried all of the entrypoints to Explore I could think of and nothing broke! |
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.
Code LGTM! Also manual testing didn't show any significant issue. With the OK of QA I think this is ready to go
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.
QA team has check the related regression test and we did not see blocker issue. LGTM!
https://docs.google.com/spreadsheets/d/1aVEM4f4slnwAA-Bv9CMcQyQ9NSfT1vw5V0cXsNMmFUA/edit#gid=0
Ephemeral environment shutdown and build artifacts deleted. |
…ata (apache#20519) * feat(explore): Use v1/explore endpoint data instead of bootstrapData * Add tests * Fix ci * Remove redundant dependency * Use form_data_key in cypress tests * Add auth headers to for data request * Address comments * Remove displaying danger toast * Conditionally add auth headers * Address comments * Fix typing bug * fix * Fix opening dataset * Fix sqllab chart create * Run queries in parallel * Fix dashboard id autofill * Fix lint * Fix test
/testenv up |
@john-bodley Ephemeral environment creation is currently limited to committers. |
SUMMARY
This PR detaches Explore page from bootstrap data.
Getting
slice
,form_data
anddatasource
is done by calling the new/v1/explore
endpoint.This is a prerequisite to Explore SPA project.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Everything should work like before (though a bit slower until we finish the rest of Explore work).
Make sure to test different initial urls (go to explore from charts list, dashboard, permalink...)
ADDITIONAL INFORMATION