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: add export_related flag #19215

Merged
merged 2 commits into from
Mar 16, 2022

Conversation

betodealmeida
Copy link
Member

SUMMARY

This PR introduces a new flag export_related to the export commands (databases, datasets, charts, dashboards, saved queries). Usually, when a dataset is exported it will also export its database; when a dashboard is exported, the export will also contain associated charts, datasets, and databases; and so on. When the flag is changed from its default value of True then only the asset itself will be exported, without any associated assets.

This PR is in preparation for creating a command that will export all assets from a given Superset workspace, allowing us to move the configuration to source control.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

Added unit tests for each of the models.

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

@codecov
Copy link

codecov bot commented Mar 16, 2022

Codecov Report

Merging #19215 (5d326a3) into master (bb618a4) will decrease coverage by 0.02%.
The diff coverage is 85.00%.

❗ Current head 5d326a3 differs from pull request most recent head 91e9831. Consider uploading reports for the commit 91e9831 to get more accurate results

@@            Coverage Diff             @@
##           master   #19215      +/-   ##
==========================================
- Coverage   66.55%   66.53%   -0.03%     
==========================================
  Files        1646     1646              
  Lines       63632    63637       +5     
  Branches     6476     6476              
==========================================
- Hits        42353    42341      -12     
- Misses      19597    19614      +17     
  Partials     1682     1682              
Flag Coverage Δ
hive 52.52% <26.41%> (-0.02%) ⬇️
mysql 81.87% <88.67%> (-0.01%) ⬇️
postgres ?
presto 52.36% <26.41%> (-0.02%) ⬇️
python 82.30% <88.67%> (-0.06%) ⬇️
sqlite 81.67% <88.67%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
superset-frontend/src/views/CRUD/utils.tsx 62.71% <0.00%> (ø)
superset-frontend/src/views/components/Menu.tsx 58.97% <ø> (ø)
...perset-frontend/src/views/components/MenuRight.tsx 65.71% <0.00%> (ø)
superset/dashboards/commands/export.py 84.93% <71.42%> (-0.99%) ⬇️
...frontend/src/components/TimezoneSelector/index.tsx 93.93% <80.00%> (ø)
superset/datasets/commands/export.py 87.75% <84.61%> (+0.25%) ⬆️
superset/queries/saved_queries/commands/export.py 94.44% <84.61%> (+0.15%) ⬆️
superset/charts/commands/export.py 94.11% <100.00%> (ø)
superset/commands/export/models.py 96.96% <100.00%> (ø)
superset/databases/commands/export.py 91.48% <100.00%> (+0.18%) ⬆️
... and 11 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 bb618a4...91e9831. Read the comment docs.

@@ -43,7 +43,7 @@ class ExportChartsCommand(ExportModelsCommand):
not_found = ChartNotFoundError

@staticmethod
def _export(model: Slice) -> Iterator[Tuple[str, str]]:
def _export(model: Slice, export_related: bool = True) -> Iterator[Tuple[str, str]]:
Copy link
Member

Choose a reason for hiding this comment

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

nit: i like export_dependencies instead of related

Copy link
Member Author

Choose a reason for hiding this comment

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

I used related to keep the same terminology used by FAB, and also because some of these are not technically dependencies (eg, when we export a database you also get the datasets, though they're not dependencies).

Copy link
Member

@hughhhh hughhhh left a comment

Choose a reason for hiding this comment

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

LGTM

@betodealmeida betodealmeida merged commit d01fdad into apache:master Mar 16, 2022
villebro pushed a commit that referenced this pull request Apr 3, 2022
* feat: add export_related flag

* Fix lint

(cherry picked from commit d01fdad)
@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
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/L 🍒 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.

None yet

4 participants