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 a command to import charts #11743

Merged
merged 2 commits into from
Nov 20, 2020
Merged

Conversation

betodealmeida
Copy link
Member

SUMMARY

This PR adds a new command ImportChartsCommand to import a new bundle with exported charts (#11167).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TEST PLAN

Added unit tests for imports and validation.

ADDITIONAL INFORMATION

Comment on lines -90 to -97
@classmethod
def _parent_foreign_key_mappings(cls) -> Dict[str, str]:
"""Get a mapping of foreign name to the local name of foreign keys"""
parent_rel = cls.__mapper__.relationships.get(cls.export_parent)
if parent_rel:
return {l.name: r.name for (l, r) in parent_rel.local_remote_pairs}
return {}

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not being used anywhere, seems like the result of a bad merge because we have an identical class method called parent_foreign_key_mappings (no leading underscore).

@@ -171,7 +163,7 @@ def import_from_dict(

# Remove fields that should not get imported
for k in list(dict_rep):
if k not in export_fields:
if k not in export_fields and k not in parent_refs:
Copy link
Member Author

Choose a reason for hiding this comment

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

This is necessary to preserve the parent ID in the config when importing, otherwise it gets deleted.

@@ -343,3 +345,32 @@ def test_import_v1_dataset_validation(self):
"database_name": ["Missing data for required field."],
}
}

def test_import_v1_dataset_existing_database(self):
Copy link
Member Author

Choose a reason for hiding this comment

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

This unit test is unrelated, but I thought about this case and decided to add it in this PR.

@codecov-io
Copy link

codecov-io commented Nov 19, 2020

Codecov Report

Merging #11743 (7998a5e) into master (8bdf943) will increase coverage by 0.58%.
The diff coverage is 94.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11743      +/-   ##
==========================================
+ Coverage   66.61%   67.20%   +0.58%     
==========================================
  Files         897      899       +2     
  Lines       43463    43560      +97     
  Branches     4015     4015              
==========================================
+ Hits        28955    29276     +321     
+ Misses      14391    14180     -211     
+ Partials      117      104      -13     
Flag Coverage Δ
cypress 55.39% <ø> (+2.90%) ⬆️
javascript 62.82% <ø> (ø)
python 63.45% <94.23%> (+0.12%) ⬆️

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

Impacted Files Coverage Δ
superset/charts/commands/importers/v1/utils.py 93.33% <93.33%> (ø)
superset/charts/commands/importers/v1/__init__.py 93.82% <93.82%> (ø)
superset/charts/schemas.py 100.00% <100.00%> (ø)
superset/models/helpers.py 89.74% <100.00%> (+1.41%) ⬆️
superset/models/slice.py 85.47% <100.00%> (+0.08%) ⬆️
...rontend/src/visualizations/FilterBox/FilterBox.jsx 58.12% <0.00%> (-9.38%) ⬇️
.../src/dashboard/components/gridComponents/Chart.jsx 82.79% <0.00%> (-2.16%) ⬇️
superset-frontend/src/SqlLab/actions/sqlLab.js 64.52% <0.00%> (+0.21%) ⬆️
... and 34 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 8bdf943...7998a5e. Read the comment docs.

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.

👍

@betodealmeida betodealmeida merged commit 2f4f877 into apache:master Nov 20, 2020
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.0.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/L 🚢 1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants