rusackas commented on code in PR #42339:
URL: https://github.com/apache/superset/pull/42339#discussion_r3772050241
##########
superset/commands/tag/export.py:
##########
@@ -23,33 +23,56 @@
import yaml
from superset.daos.chart import ChartDAO
from superset.daos.dashboard import DashboardDAO
+from superset.daos.tag import TagDAO
from superset.extensions import feature_flag_manager
from superset.tags.models import TagType
+from superset.commands.export.models import ExportModelsCommand
from superset.commands.tag.exceptions import TagNotFoundError
-# pylint: disable=too-few-public-methods
-class ExportTagsCommand:
+class ExportTagsCommand(ExportModelsCommand):
+ dao = TagDAO
not_found = TagNotFoundError
+ def __init__(
+ self,
+ model_ids: Optional[list[int]] = None,
+ export_related: bool = True,
+ *,
+ dashboard_ids: Optional[Union[int, List[Union[int, str]]]] = None,
+ chart_ids: Optional[Union[int, List[Union[int, str]]]] = None,
+ ):
+ self.model_ids = model_ids or []
+ self.export_related = export_related
+ self.dashboard_ids = dashboard_ids
+ self.chart_ids = chart_ids
+ self._models = []
+
+ def run(self) -> Iterator[tuple[str, Callable[[], str]]]:
+ if not feature_flag_manager.is_feature_enabled("TAGGING_SYSTEM"):
+ return
+
+ yield (
+ ExportTagsCommand._file_name(),
+ lambda: ExportTagsCommand._file_content(
+ self.dashboard_ids, self.chart_ids
+ ),
+ )
Review Comment:
This one's stale now, `run()` was updated in `48e4fbf7` to pull
dashboard/chart ids from `self._models` when `model_ids` is passed, so it's not
ignored anymore.
##########
superset/commands/tag/export.py:
##########
@@ -23,33 +23,56 @@
import yaml
from superset.daos.chart import ChartDAO
from superset.daos.dashboard import DashboardDAO
+from superset.daos.tag import TagDAO
from superset.extensions import feature_flag_manager
from superset.tags.models import TagType
+from superset.commands.export.models import ExportModelsCommand
from superset.commands.tag.exceptions import TagNotFoundError
-# pylint: disable=too-few-public-methods
-class ExportTagsCommand:
+class ExportTagsCommand(ExportModelsCommand):
+ dao = TagDAO
not_found = TagNotFoundError
+ def __init__(
+ self,
+ model_ids: Optional[list[int]] = None,
+ export_related: bool = True,
+ *,
+ dashboard_ids: Optional[Union[int, List[Union[int, str]]]] = None,
+ chart_ids: Optional[Union[int, List[Union[int, str]]]] = None,
+ ):
+ self.model_ids = model_ids or []
+ self.export_related = export_related
+ self.dashboard_ids = dashboard_ids
+ self.chart_ids = chart_ids
Review Comment:
`validate()` isn't overridden here, it's inherited from
`ExportModelsCommand` and `run()` calls it, so
`self.dao.find_by_ids(self.model_ids)` still runs and `TagNotFoundError` still
gets raised on a mismatch. And `model_ids or []` in `__init__` keeps the
parent's `list[int]` contract satisfied even though the param stays `Optional`
for the dashboard/chart-ids-only call path. Think this one's covered.
--
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]