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

refactor: remove slice level label_colors from dashboard init load #10603

Merged

Conversation

graceguo-supercat
Copy link

@graceguo-supercat graceguo-supercat commented Aug 14, 2020

SUMMARY

When dashboard is loaded, it loaded bootstrap data for render dashboard. it includes: datasources, slice metadata, and dashboard metadata.

When dashboard has set color_scheme, its metadata will have color_labels section and set color for each label in the dashboard. This attribute will overwrite slice level color_label in its form_data. So when used in dashboard, slice's own color_label has no use. But this section could be pretty big and repeated by all the slices in the dashboard, which make the dashboard initial bootstrap data size very big.

This PR is to remove slice level color_label attribute (in its form_data) in the dashboard bootstrap data.

TEST PLAN

CI and manually load some dashboards.

@etr2460

@mistercrunch
Copy link
Member

I think that chart-level colors were a mistake and that we should revisit this. @nytai got tangled into this in the past and in some cases really makes the chart payload gigantic for no super good reason.

I think Kim's intent originally was to preserve the dashboard-assigned colors when exploring the chart, but it really bloats the chart's properties. Plus it doesn't really play well with the many-to-many aspect of charts/dashboards, what if the chart is in two dashboards using different color schemes?

Even if we wanted to preserve that context, we may want for the chart to only have a reference to the dashboard it's associated with (in that particular context), and use the metadata / color scheme from that dashboard.

@graceguo-supercat
Copy link
Author

graceguo-supercat commented Aug 14, 2020

yes, i agree this label_colors props is inappropriately populated into slice.
If i run db migration and remove all of them from form_data, dashboard will still generate new entries.
I think we should find a better solution for allowing user customize label color in dashboard. Maybe a good project when working/refactoring dashboard UI toward SIP-34.

@mistercrunch
Copy link
Member

If the intention was to keep the same colors when going from the dashboard to explore, I think we should pass the context to explore of which dashboard the user came from, and explore can retrieve whatever dashboard metadata (ie colors) that can affect the context of the chart itself.

@graceguo-supercat
Copy link
Author

graceguo-supercat commented Aug 17, 2020

I want to use this PR as a short term solution, to see how big impact those redundant label_colors in slices' form_data to dashboard performance (mostly for large dashboard used in airbnb).

If the impact is big, we should do some refactoring for label_colors logic (long term solution):

  1. instead of persist label_colors in form_data, we should pass the context to explore of which dashboard the user came from, and explore can retrieve whatever dashboard metadata (ie colors) that can affect the context of the chart itself.
  2. do not save label_colors passed from dashboard when user save / copy slices (this is current behavior).
  3. db migration to remove label_colors from form_data. -- not sure we should do this...what if user edit slice and want to set fixed color scheme for a slice?

for both long term and short term solution, dashboard should not carry slice level color_labels.

@graceguo-supercat
Copy link
Author

ping @mistercrunch @etr2460

@etr2460
Copy link
Member

etr2460 commented Aug 18, 2020

Sorry, one clarification i'm not 100% sure of:

Does this change affect the current user experience in any way? If a dashboard doesn't have colors defined, do we fall back to slice colors which will now be removed?

I'd say, if this could change the user experience, then it might be safer to put this in a feature flag. If not, then i'm good to stamp this as an awesome optimization

@graceguo-supercat graceguo-supercat changed the base branch from master to airbnb August 18, 2020 22:03
@graceguo-supercat graceguo-supercat changed the base branch from airbnb to master August 18, 2020 22:06
@graceguo-supercat
Copy link
Author

graceguo-supercat commented Aug 19, 2020

if dashboard don't have label_colors setting, after this PR, the label color will be assigned randomly, because slice-level label_color is not carried by dashboard. So I wrap this change into a feature flag, by default is not enable it.

This is a short term solution. if we see perf impact for large dashboard, should go with a long term solution.

@codecov-commenter
Copy link

Codecov Report

Merging #10603 into master will decrease coverage by 3.39%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10603      +/-   ##
==========================================
- Coverage   64.06%   60.66%   -3.40%     
==========================================
  Files         771      418     -353     
  Lines       36391    13650   -22741     
  Branches     3429     3482      +53     
==========================================
- Hits        23314     8281   -15033     
+ Misses      12964     5180    -7784     
- Partials      113      189      +76     
Flag Coverage Δ
#cypress ?
#javascript 60.66% <ø> (+0.78%) ⬆️
#python ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/SqlLab/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/dashboard/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/index.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/dashboard/index.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/setup/setupColors.js 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/chart/ChartContainer.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/setup/setupFormatters.js 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/reducers/index.js 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/setup/setupPluginsExtra.js 0.00% <0.00%> (-100.00%) ⬇️
... and 523 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 a3fd2b4...8367da4. Read the comment docs.

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

one comment, otherwise lgtm!

@@ -304,6 +304,7 @@ def _try_json_readsha( # pylint: disable=unused-argument
# Exposes API endpoint to compute thumbnails
"THUMBNAILS": False,
"REDUCE_DASHBOARD_BOOTSTRAP_PAYLOAD": True,
"REDUCE_SLICE_LEVEL_LABEL_COLORS": False,
Copy link
Member

Choose a reason for hiding this comment

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

naming nit, REMOVE instead of REDUCE probably

Copy link
Author

Choose a reason for hiding this comment

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

thanks. fixed!

@graceguo-supercat graceguo-supercat merged commit 3bc7919 into apache:master Aug 19, 2020
amitmiran137 pushed a commit to amitmiran137/incubator-superset that referenced this pull request Aug 21, 2020
* master: (43 commits)
  feat: Getting fancier with Storybook (apache#10647)
  fix: dedup groupby in viz.py while preserving order (apache#10633)
  feat: bump superset-ui for certified tag (apache#10650)
  feat: setup react page with submenu for datasources listview  (apache#10642)
  feat: add certification to metrics (apache#10630)
  feat(viz-plugins): add date formatting to pivot-table (apache#10637)
  fix: controls scroll issue (apache#10644)
  feat: Allow tests files in  /src (plus Label component tests) (apache#10634)
  fix: remove duplicated params and cache_timeout from list_columns; add viz_type to list_columns (apache#10643)
  chore: splitting button stories into separate stories (apache#10631)
  refactor: remove slice level label_colors from dashboard init load (apache#10603)
  feat: card view bulk select (apache#10607)
  style: Label styling/storybook touchups (apache#10627)
  fix: removing unsupported modal sizes (apache#10625)
  feat(datasource): remove deleted columns and update column type on metadata refresh (apache#10619)
  improve documentation for country maps (apache#10621)
  chore: npm audit fix as of 2020-08-15 (apache#10613)
  feat: dataset REST API for distinct values (apache#10595)
  chore: bump react-redux to 5.1.2, whittling console noise (apache#10602)
  fixing console error about bad html attribute (apache#10604)
  ...

# Conflicts:
#	superset-frontend/src/explore/components/ExploreViewContainer.jsx
#	superset-frontend/src/views/App.tsx
#	superset/config.py
@graceguo-supercat graceguo-supercat deleted the gg-ReduceDashboardLoad branch September 11, 2020 03:33
Ofeknielsen pushed a commit to ofekisr/incubator-superset that referenced this pull request Oct 5, 2020
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.38.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/XS 🚢 0.38.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants