-
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: Add Area chart migration and tweaks the Timeseries chart migration #25952
feat: Add Area chart migration and tweaks the Timeseries chart migration #25952
Conversation
@@ -17,4 +17,4 @@ | |||
[pytest] | |||
testpaths = | |||
tests | |||
python_files = *_test.py test_*.py *_tests.py | |||
python_files = *_test.py test_*.py *_tests.py *viz/utils.py |
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.
Makes pytest
display full assertion errors defined in that file.
b6f8bc5
to
2f59321
Compare
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is legacy, but this method name is somewhat confusing, i.e., I'm not entirely sure what it does.
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.
Removed 👍🏼
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) |
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.
Thanks for the refactor.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@@ -36,40 +36,6 @@ def _pre_action(self) -> None: | |||
self.data["metric"] = self.data["metrics"][0] | |||
|
|||
|
|||
class MigrateAreaChart(MigrateViz): |
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.
Removed the incomplete and unused migration.
@@ -137,10 +103,22 @@ class MigrateSunburst(MigrateViz): | |||
|
|||
class TimeseriesChart(MigrateViz): | |||
has_x_axis_control = True | |||
rename_keys = { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to TimeseriesChart.
"any_other_key": "untouched", | ||
"columns": ["state"], | ||
"combine_metric": True, | ||
"granularity_sqla": "ds", |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this came from the pivot_table_v1_v2_test.py
@john-bodley Added comments |
@@ -75,7 +75,6 @@ def migrate_chart(config: dict[str, Any]) -> dict[str, Any]: | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It can be None
or undefined
as it's optional.
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.
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.
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.
Exactly 😆
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