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: TreeMap migration #20346

Merged
merged 3 commits into from
Jul 7, 2022
Merged

Conversation

zhaoyongjie
Copy link
Member

SUMMARY

This PR intends to introduce an approach that migrates from v1 viz to v2 viz. The first PR implement TreeMap migration.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

# upgrade
superset db upgrade

# downgrade
superset db downgrade

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

@zhaoyongjie zhaoyongjie requested a review from a team as a code owner June 10, 2022 07:46
Comment on lines -17 to +22
"""adding_advanced_data_type.py
"""adding advanced data type to column models

Revision ID: 6f139c533bea
Revises: cbe71abde154
Create Date: 2021-05-27 16:10:59.567684

Copy link
Member Author

Choose a reason for hiding this comment

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

bycatch: pretty output

image

@codecov
Copy link

codecov bot commented Jun 10, 2022

Codecov Report

Merging #20346 (0aa273e) into master (90d486a) will decrease coverage by 0.03%.
The diff coverage is 69.47%.

❗ Current head 0aa273e differs from pull request most recent head b1d10bd. Consider uploading reports for the commit b1d10bd to get more accurate results

@@            Coverage Diff             @@
##           master   #20346      +/-   ##
==========================================
- Coverage   66.71%   66.68%   -0.04%     
==========================================
  Files        1752     1753       +1     
  Lines       65478    65710     +232     
  Branches     6916     6940      +24     
==========================================
+ Hits        43681    43816     +135     
- Misses      20049    20132      +83     
- Partials     1748     1762      +14     
Flag Coverage Δ
mysql 82.41% <96.27%> (+0.04%) ⬆️
postgres 82.48% <96.27%> (+0.04%) ⬆️
presto ?
python 82.56% <96.27%> (-0.09%) ⬇️
sqlite 82.27% <96.27%> (+0.04%) ⬆️
unit ?

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

Impacted Files Coverage Δ
...t-ui-chart-controls/src/operators/pivotOperator.ts 100.00% <ø> (ø)
...controls/src/operators/timeComparePivotOperator.ts 100.00% <ø> (ø)
...t-controls/src/sections/echartsTimeSeriesQuery.tsx 50.00% <ø> (ø)
...d/packages/superset-ui-chart-controls/src/types.ts 100.00% <ø> (ø)
...superset-ui-core/src/query/types/PostProcessing.ts 100.00% <ø> (ø)
...egacy-preset-chart-deckgl/src/layers/Grid/Grid.jsx 0.00% <0.00%> (ø)
...reset-chart-deckgl/src/layers/Grid/controlPanel.ts 50.00% <0.00%> (-50.00%) ⬇️
.../legacy-preset-chart-deckgl/src/layers/Hex/Hex.jsx 0.00% <0.00%> (ø)
...preset-chart-deckgl/src/layers/Hex/controlPanel.ts 50.00% <0.00%> (-50.00%) ⬇️
...et-chart-deckgl/src/layers/Polygon/controlPanel.ts 33.33% <0.00%> (-16.67%) ⬇️
... and 89 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 90d486a...b1d10bd. Read the comment docs.

Comment on lines -71 to +75
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
app.config["SQLALCHEMY_DATABASE_URI"] = (
os.environ.get("SUPERSET__SQLALCHEMY_DATABASE_URI") or "sqlite://"
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Use integration test database instance for local debugging.

@zhaoyongjie zhaoyongjie requested review from a team and rusackas June 10, 2022 12:15
@zhaoyongjie zhaoyongjie force-pushed the feat/migrate_treemap branch 3 times, most recently from 7b4e0dc to 9e44fa0 Compare June 13, 2022 07:00
@zhaoyongjie zhaoyongjie mentioned this pull request Jun 13, 2022
9 tasks
@zhaoyongjie zhaoyongjie reopened this Jun 13, 2022
treemap_processor = get_migrate_class[MigrateVizEnum.treemap]


def test_treemap_migrate(app_context: SupersetApp) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe have separated tests for upgrade and downgrade?

Copy link
Member Author

Choose a reason for hiding this comment

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

the method of downgrade needs an updated slice so combine upgrade and downgrade in the same unit test case.

return slc


class MigrateTreeMap(MigrateViz):
Copy link
Member

Choose a reason for hiding this comment

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

Maybe move MigrateTreeMap to its own file? I guess we'll have a bunch of these.

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 a one-time script. There is no need to split moudles.

Copy link
Member

Choose a reason for hiding this comment

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

Won't we have other viz types to be migrated? If yes, are you going to add all the viz types to this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, all migrations are placed in this script.

Copy link
Member Author

Choose a reason for hiding this comment

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

Generally, scripts are waterfalls, while libary should be modular.

Comment on lines +57 to +61
if key in self.mapping_keys and self.mapping_keys[key] in rv_data:
raise ValueError("Duplicate key in target viz")

if key in self.mapping_keys:
rv_data[self.mapping_keys[key]] = value
Copy link
Member

Choose a reason for hiding this comment

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

I personally find this more readable, but it's not a blocker.

Suggested change
if key in self.mapping_keys and self.mapping_keys[key] in rv_data:
raise ValueError("Duplicate key in target viz")
if key in self.mapping_keys:
rv_data[self.mapping_keys[key]] = value
if key in self.mapping_keys:
mapped_key = self.mapping_keys[key]
if mapped_key in rv_data:
raise ValueError("Duplicate key in target viz")
rv_data[mapped_key] = value

Copy link
Member Author

Choose a reason for hiding this comment

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

Exception handling is easier to maintain if it can be put together.

@zhaoyongjie zhaoyongjie requested review from betodealmeida and a team June 21, 2022 07:19
@michael-s-molina
Copy link
Member

@zhaoyongjie @rusackas Shouldn't we disable TreeMap v1 after the migration? By that, I mean no more TreeMap v1 on Add Slice and Chart Type filter in the charts list. Right now, the user can still create the old version which kind of defeats the whole purpose of the migration.

@zhaoyongjie
Copy link
Member Author

zhaoyongjie commented Jul 6, 2022

@zhaoyongjie @rusackas Shouldn't we disable TreeMap v1 after the migration? By that, I mean no more TreeMap v1 on Add Slice and Chart Type filter in the charts list. Right now, the user can still create the old version which kind of defeats the whole purpose of the migration.

I intend to do a separated PR that removes the Legacy TreeMap after merged migration PR. the follow-up PR will 1) remove Legacy TreeMap from plugins, 2) remove legacy TreeMap from MainPresent.js.

@michael-s-molina
Copy link
Member

michael-s-molina commented Jul 6, 2022

@zhaoyongjie @rusackas Shouldn't we disable TreeMap v1 after the migration? By that, I mean no more TreeMap v1 on Add Slice and Chart Type filter in the charts list. Right now, the user can still create the old version which kind of defeats the whole purpose of the migration.

I intend to do a separated PR that removes the Legacy TreeMap after merged migration PR. the follow-up PR will 1) remove Legacy TreeMap from plugins, 2) remove legacy TreeMap from MainPresent.js.

May I suggest implementing this in the same PR to avoid the risk of someone executing the script and creating an old TreeMap before the follow-up PR is merged?

@rusackas rusackas requested a review from john-bodley July 6, 2022 16:09
superset/utils/migrate_viz.py Outdated Show resolved Hide resolved
superset/utils/migrate_viz.py Outdated Show resolved Hide resolved
superset/utils/migrate_viz.py Outdated Show resolved Hide resolved
superset/utils/migrate_viz.py Outdated Show resolved Hide resolved
@zhaoyongjie
Copy link
Member Author

@john-bodley thanks for the reviewing, I have addressed comments.

@zhaoyongjie zhaoyongjie merged commit 7626c31 into apache:master Jul 7, 2022
akshatsri pushed a commit to charan1314/superset that referenced this pull request Jul 19, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.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 size/L 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants