-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
feat: Adds CLI commands to execute viz migrations #25304
Conversation
e38a560
to
990bb2a
Compare
990bb2a
to
3585b25
Compare
783f368
to
5adc898
Compare
superset/cli/viz_migrations.py
Outdated
|
||
|
||
@click.group() | ||
def viz_migrations() -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def viz_migrations() -> None: | |
def viz_migrate() -> None: |
Should this be a verb?
There was a problem hiding this comment.
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
.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
superset/cli/viz_migrations.py
Outdated
migrate_viz(VizTypes(viz_type), is_downgrade=True) | ||
|
||
|
||
def migrate_viz(viz_type: VizTypes, is_downgrade: bool = False) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
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.
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.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