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

feat: import/export assets commands #19217

Merged
merged 3 commits into from
Mar 17, 2022
Merged

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Mar 16, 2022

SUMMARY

This PR introduces two new commands (ImportAssetsCommand and ExportAssetsCommand). The commands will be used to export all assets from Superset into a ZIP file, as well as back into Superset, with the objective of managing the assets from source control.

Depends on #19216.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

Added unit tests.

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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

@betodealmeida betodealmeida requested a review from a team as a code owner March 17, 2022 01:02
@betodealmeida betodealmeida changed the base branch from refactor_import_code to master March 17, 2022 01:03
@codecov
Copy link

codecov bot commented Mar 17, 2022

Codecov Report

Merging #19217 (c532d79) into master (a4848a2) will increase coverage by 0.03%.
The diff coverage is 88.07%.

@@            Coverage Diff             @@
##           master   #19217      +/-   ##
==========================================
+ Coverage   66.72%   66.75%   +0.03%     
==========================================
  Files        1667     1669       +2     
  Lines       64222    64331     +109     
  Branches     6484     6484              
==========================================
+ Hits        42849    42943      +94     
- Misses      19692    19705      +13     
- Partials     1681     1683       +2     
Flag Coverage Δ
hive 52.55% <24.77%> (-0.10%) ⬇️
javascript 51.25% <ø> (-0.01%) ⬇️
mysql 81.98% <88.07%> (+0.02%) ⬆️
postgres 82.03% <88.07%> (+0.02%) ⬆️
presto 52.40% <24.77%> (-0.10%) ⬇️
python 82.45% <88.07%> (+0.02%) ⬆️
sqlite 81.78% <88.07%> (+0.02%) ⬆️

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.71% <85.71%> (ø)
superset/commands/export/assets.py 96.00% <96.00%> (ø)
...eFilters/FiltersConfigModal/FiltersConfigModal.tsx 63.04% <0.00%> (-1.64%) ⬇️
superset/common/query_context_processor.py 91.46% <0.00%> (+0.47%) ⬆️

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 a4848a2...c532d79. Read the comment docs.

# pylint: disable=unused-argument
def __init__(self, contents: Dict[str, str], *args: Any, **kwargs: Any):
self.contents = contents
self.passwords: Dict[str, str] = kwargs.get("passwords") or {}
Copy link
Member

@hughhhh hughhhh Mar 17, 2022

Choose a reason for hiding this comment

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

Suggested change
self.passwords: Dict[str, str] = kwargs.get("passwords") or {}
self.passwords: Dict[str, str] = kwargs.get("passwords", {})

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! There's a subtle difference here that I want to capture; if passwords is passed as a keyword argument and is falsy (most likely None) we want it to be a dict, which is why I did the pattern with or instead of .get.

@betodealmeida betodealmeida merged commit 51061f0 into master Mar 17, 2022
villebro pushed a commit that referenced this pull request Apr 3, 2022
* feat: import/export assets commands

* Add overwrite test

* Fix tests

(cherry picked from commit 51061f0)
@mistercrunch mistercrunch added 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 labels Mar 13, 2024
@mistercrunch mistercrunch deleted the export_import_assets branch March 26, 2024 16:11
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 lts-v1 size/XL 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants