feat: Adds CLI commands to execute viz migrations#25304
Conversation
e38a560 to
990bb2a
Compare
990bb2a to
3585b25
Compare
783f368 to
5adc898
Compare
|
|
||
|
|
||
| @click.group() | ||
| def viz_migrations() -> None: |
There was a problem hiding this comment.
| def viz_migrations() -> None: | |
| def viz_migrate() -> None: |
Should this be a verb?
There was a problem hiding this comment.
Yes. I changed it to migrate_viz.
| 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.
Can this not be db.session for all occurrences, i.e., CLI and Alembic migration?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
| 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.
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-migrationsto 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