aminghadersohi commented on code in PR #39922:
URL: https://github.com/apache/superset/pull/39922#discussion_r3203060654
##########
superset/mcp_service/chart/chart_utils.py:
##########
@@ -318,29 +318,32 @@ def map_config_to_form_data(
| BigNumberChartConfig,
dataset_id: int | str | None = None,
) -> Dict[str, Any]:
- """Map chart config to Superset form_data."""
- if isinstance(config, TableChartConfig):
- return map_table_config(config)
- elif isinstance(config, XYChartConfig):
- return map_xy_config(config, dataset_id=dataset_id)
- elif isinstance(config, PieChartConfig):
- return map_pie_config(config)
- elif isinstance(config, PivotTableChartConfig):
- return map_pivot_table_config(config)
- elif isinstance(config, MixedTimeseriesChartConfig):
- return map_mixed_timeseries_config(config, dataset_id=dataset_id)
- elif isinstance(config, HandlebarsChartConfig):
- return map_handlebars_config(config)
- elif isinstance(config, BigNumberChartConfig):
- if config.show_trendline and config.temporal_column:
- if not is_column_truly_temporal(config.temporal_column,
dataset_id):
- raise ValueError(
- f"Big Number trendline requires a temporal SQL column; "
- f"'{config.temporal_column}' is not temporal."
- )
- return map_big_number_config(config)
- else:
- raise ValueError(f"Unsupported config type: {type(config)}")
+ """Map chart config to Superset form_data via the plugin registry.
+
+ The previous if/elif chain across all 7 chart types has been replaced by a
+ single registry lookup. Cross-field constraints (e.g. BigNumber trendline
+ temporal check) are now owned by each plugin's post_map_validate() method
+ rather than being baked into this dispatcher.
+ """
+ from superset.mcp_service.chart.registry import get_registry
Review Comment:
Yes, this must stay local. is imported by plugins inside their
`to_form_data()` methods, so it loads before plugins finish registering. A
top-level import of `registry` here would trigger plugin loading mid-import and
create a circular dependency. Added an explanatory comment in f746051.
##########
superset/mcp_service/chart/validation/dataset_validator.py:
##########
@@ -443,22 +311,20 @@ def normalize_column_names(
if not dataset_context:
return config
- # Create a mutable copy of the config
- config_dict = config.model_dump()
+ from superset.mcp_service.chart.registry import get_registry
Review Comment:
Same pattern as chart_utils.py — plugins call `DatasetValidator` helpers
from their `normalize_column_refs()` methods. Making this a top-level import
would trigger plugin registration when `dataset_validator` first loads,
creating a circular dependency. Added an explanatory comment in f746051.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]