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: Adds CLI commands to execute viz migrations #25304

Merged
merged 6 commits into from
Sep 19, 2023

Conversation

michael-s-molina
Copy link
Member

SUMMARY

Adds a new CLI command called viz-migrations to allow users to migrate charts of a specific type. This command is particularly helpful to migrate visualizations to the latest version and at the same time disable their legacy versions with the VIZ_TYPE_DENYLIST configuration.

Usage: superset viz-migrations [OPTIONS] COMMAND [ARGS]...

  Migrates a viz from one type to another.

Commands:
  downgrade  Downgrades a viz to the previous version.
  upgrade    Upgrade a viz to the latest version.

TESTING INSTRUCTIONS

1 - Execute an upgrade of a particular viz type.
2 - Downgrade the previously upgraded viz type.
3 - Check the viz versions between these steps.

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

@michael-s-molina michael-s-molina marked this pull request as draft September 15, 2023 14:20
@john-bodley john-bodley self-requested a review September 15, 2023 16:48
@michael-s-molina michael-s-molina marked this pull request as ready for review September 15, 2023 17:56


@click.group()
def viz_migrations() -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def viz_migrations() -> None:
def viz_migrate() -> None:

Should this be a verb?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I changed it to migrate_viz.

superset/cli/viz_migrations.py Outdated Show resolved Hide resolved
def upgrade(cls) -> None:
bind = op.get_bind()
session = db.Session(bind=bind)
def upgrade(cls, session: Session) -> None:
slices = session.query(Slice).filter(Slice.viz_type == cls.source_viz_type)
Copy link
Member

Choose a reason for hiding this comment

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

Can this not be db.session for all occurrences, i.e., CLI and Alembic migration?

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 tried using db.session but it completely broke CI. I decided to remove session creation from the base class and leave that responsibility with the migration callers. This preserves the current behavior of Alembic migrations and at the same time allows the migration to be called from commands.

migrate_viz(VizTypes(viz_type), is_downgrade=True)


def migrate_viz(viz_type: VizTypes, is_downgrade: bool = False) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def migrate_viz(viz_type: VizTypes, is_downgrade: bool = False) -> None:
def migrate_viz(viz_type: VizTypes, is_upgrade: bool = True) -> None:

I thought upgrading is more typical than downgrading and thus naming the flag is_upgrade seems more appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, upgrading is more typical. The reason I named it is_downgrade is because it's an optional parameter which generally is not set.

@michael-s-molina michael-s-molina merged commit b722a95 into apache:master Sep 19, 2023
eschutho pushed a commit to Superset-Community-Partners/superset that referenced this pull request Sep 21, 2023
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
@mistercrunch mistercrunch added the 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels label Mar 8, 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 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants