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

fix(assets api): import replaces dashboard #22208

Merged
merged 5 commits into from
Dec 21, 2022

Conversation

Stanhoucke
Copy link
Contributor

SUMMARY

For existing dashboards, modifications imported via /api/v1/assets/import/ are only appended if the modified dashboard contains a new chart. Modifications to dashboards that remove a chart are not implemented when imported through the assets API.

This change updates the assets API import method to remove all existing references to chart ids for the imported dashboard(s) before inserting the new chart ids. The change should benefit the management of Superset assets under source control.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Remove a chart from a dashboard:

  • Export a dashboard and unzip assets bundle.
  • Remove a chart and all references to it from the exported yaml files
  • Import modified assets bundle as a zip by posting to /api/v1/assets/import/ (see https://superset.apache.org/docs/api/#api)
  • Navigate to the modified dashboard in the Superset UI and observe the deleted chart is no longer visible

Add a chart to a dashboard:

  • In the same dashboard, remove a chart using the UI and save the dashboard
  • Import the previously exported assets bundle as a zip by posting to /api/v1/assets/import/
  • Navigate to the modified dashboard in the Superset UI and observe the deleted chart is now reinstated

ADDITIONAL INFORMATION

  • Has associated issue: Import dashboard/assets with overwrite flag does not replace dashboards #22127
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️
We hope to see you in our Slack community too!

@Stanhoucke Stanhoucke changed the title [WIP] fix(assets api): import replaces dashboard fix(assets api): import replaces dashboard Nov 24, 2022
@nytai
Copy link
Member

nytai commented Nov 29, 2022

Can we add a unit test for this behavior? there should already be some for import/export you can expand on

@Stanhoucke
Copy link
Contributor Author

Sure, I'll add a test 👍

@pull-request-size pull-request-size bot added size/L and removed size/M labels Dec 2, 2022
@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Merging #22208 (92df588) into master (a77b2d6) will increase coverage by 1.44%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #22208      +/-   ##
==========================================
+ Coverage   65.49%   66.94%   +1.44%     
==========================================
  Files        1835     1836       +1     
  Lines       69927    70077     +150     
  Branches     7590     7590              
==========================================
+ Hits        45802    46913    +1111     
+ Misses      22159    21198     -961     
  Partials     1966     1966              
Flag Coverage Δ
hive 52.53% <28.57%> (?)
mysql 77.95% <100.00%> (-0.13%) ⬇️
postgres 78.02% <100.00%> (-0.13%) ⬇️
presto 52.42% <28.57%> (?)
python 81.23% <100.00%> (+2.95%) ⬆️
sqlite 76.48% <100.00%> (-0.13%) ⬇️
unit 51.09% <100.00%> (?)

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

Impacted Files Coverage Δ
superset/commands/importers/v1/assets.py 85.54% <100.00%> (-0.18%) ⬇️
superset/db_engine_specs/databricks.py 64.96% <0.00%> (-17.97%) ⬇️
superset/charts/data/api.py 88.34% <0.00%> (-1.47%) ⬇️
superset/views/database/views.py 31.27% <0.00%> (-0.09%) ⬇️
superset/models/helpers.py 38.19% <0.00%> (-0.09%) ⬇️
superset/charts/schemas.py 99.35% <0.00%> (ø)
superset/utils/pandas_postprocessing/sort.py 100.00% <0.00%> (ø)
superset/db_engine_specs/risingwave.py 100.00% <0.00%> (ø)
superset/connectors/base/models.py 87.20% <0.00%> (+0.07%) ⬆️
superset/views/database/forms.py 85.89% <0.00%> (+0.18%) ⬆️
... and 66 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@nicolas-gaillard
Copy link

hello @eschutho, will this fix be available in 2.1.0? Thank you very much

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 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/L 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants