feat: Add Area chart migration and tweaks the Timeseries chart migration#25952
Conversation
There was a problem hiding this comment.
Makes pytest display full assertion errors defined in that file.
b6f8bc5 to
2f59321
Compare
john-bodley
left a comment
There was a problem hiding this comment.
Given there's also a refactor in combination with the are chart migration it might be helpful to annotate (via comments) which parts represent new logic.
I'm a tad complexed, given that the PR title states we're adding an area chart migration yet there was an existing "MigrateAreaChart" class.
| @@ -68,30 +69,4 @@ def test_migration() -> None: | |||
|
|
|||
|
|
|||
| def upgrade_downgrade(source, target) -> None: | |||
There was a problem hiding this comment.
This is legacy, but this method name is somewhat confusing, i.e., I'm not entirely sure what it does.
| slc = MigrateDualLine.downgrade_slice(slc) | ||
| assert slc.viz_type == MigrateDualLine.source_viz_type | ||
| assert json.loads(slc.params) == source | ||
| migrate_and_assert(MigrateDualLine, source, target) |
| lambda current, total: print( | ||
| f" Updating {current}/{total} charts", end="\r" | ||
| ), | ||
| lambda current, total: print(f"Upgraded {current}/{total} charts"), |
There was a problem hiding this comment.
Display a log entry for each block creating a log history.
Even though we had a previous migration, it was incomplete and wasn't being used. |
| self.data["metric"] = self.data["metrics"][0] | ||
|
|
||
|
|
||
| class MigrateAreaChart(MigrateViz): |
There was a problem hiding this comment.
Removed the incomplete and unused migration.
|
|
||
| class TimeseriesChart(MigrateViz): | ||
| has_x_axis_control = True | ||
| rename_keys = { |
There was a problem hiding this comment.
This is not new. Just moved from MigrateLineChart.
| class MigrateLineChart(TimeseriesChart): | ||
| source_viz_type = "line" | ||
| target_viz_type = "echarts_timeseries_line" | ||
| rename_keys = { |
There was a problem hiding this comment.
Moved to TimeseriesChart.
| "any_other_key": "untouched", | ||
| "columns": ["state"], | ||
| "combine_metric": True, | ||
| "granularity_sqla": "ds", |
There was a problem hiding this comment.
Moved the time parts to a separate test file called time_related_fields_test.py
|
|
||
|
|
||
| @with_feature_flags(GENERIC_CHART_AXES=False) | ||
| def test_migration_without_generic_chart_axes() -> None: |
There was a problem hiding this comment.
All this came from the pivot_table_v1_v2_test.py
@john-bodley Added comments |
| if isclass(class_) | ||
| and issubclass(class_, MigrateViz) | ||
| and hasattr(class_, "source_viz_type") | ||
| and class_ != processors.MigrateAreaChart # incomplete |
There was a problem hiding this comment.
Added the migration back to import function now that it's complete.
| def _pre_action(self) -> None: | ||
| self.data["contributionMode"] = "row" if self.data.get("contribution") else None | ||
| self.data["zoomable"] = self.data.get("show_brush") != "no" | ||
| self.data["zoomable"] = self.data.get("show_brush") == "yes" |
There was a problem hiding this comment.
@michael-s-molina I see this is an update to the existing TimeseriesChart migration where the zoomable used to be True if show_brush was None whereas now it's False.
I'm not privy to knowing whether this logic (and that on lines 144–146) is correct, but maybe it make more sense to have said logic in a separate PR. Additionally is there anyway to proactively fix previously migrated charts which were wrong? I gather the x_ticks_layout field could be remedied (as it's persisted), but the show_brush was removed.
There was a problem hiding this comment.
@john-bodley These PRs only add the migration logic but there's no migration invoking them directly. We'll have that in 4.0 when we forcefully remove the legacy versions. Right now, these migrations can only be invoked by the viz_migrations command which was not released yet. The command will be available in 3.1.
There was a problem hiding this comment.
@michael-s-molina could we change to PR description to be something of the form,
Add Area chart migration and tweaks the Timeseries chart migration
which will aid developers if they're trying to bisect when/where a possible change occurred.
|
|
||
| self.remove_keys.add("stacked_style") | ||
|
|
||
| self.data["stack"] = self.stacked_map.get( |
There was a problem hiding this comment.
Should the stack key be None or undefined if the resulting key isn't in self.stacked_map?
There was a problem hiding this comment.
Yes. It can be None or undefined as it's optional.
There was a problem hiding this comment.
Do we have a preference or whether we explicitly define None? I guess there's likely so many inconsistencies on both the front- and back-end with regards to when/where to persist values that even if we make it undefined (and thus minimizing the payload) there's no guarantee that the field wont materialize with a value of None on save.
SUMMARY
This PR adds the Area chart migration logic (NVD3 ➡️ ECharts) and tweaks the base class used by timeseries migrations. Users can execute this migration using the #25304 CLI command and disable the legacy version with the VIZ_TYPE_DENYLIST configuration.
@sadpandajoe @jinghua-qa
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
1 - Upgrade a Area chart using the CLI command
2 - Check the new chart
3 - Downgrade a Area chart using the CLI command
4 - Check the legacy chart
ADDITIONAL INFORMATION