rusackas commented on code in PR #37120:
URL: https://github.com/apache/superset/pull/37120#discussion_r3653910602
##########
superset/commands/query/export.py:
##########
@@ -67,8 +67,12 @@ def _file_content(model: SavedQuery) -> str:
@staticmethod
def _export(
- model: SavedQuery, export_related: bool = True
+ model: SavedQuery, export_related: bool = True, seen: set[str] | None
= None
) -> Iterator[tuple[str, Callable[[], str]]]:
+ # Initialize seen set if not provided
+ if seen is None:
+ seen = set()
+
yield (
ExportSavedQueriesCommand._file_name(model),
Review Comment:
Same as the other "seen not updated" comments on this PR, `run()`'s wrapping
loop already adds every yielded filename to `seen` after the fact, so nothing's
actually missing here.
##########
superset/commands/query/export.py:
##########
@@ -79,21 +83,23 @@ def _export(
database_slug = secure_filename(model.database.database_name)
file_name = f"databases/{database_slug}.yaml"
- payload = model.database.export_to_dict(
- recursive=False,
- include_parent_ref=False,
- include_defaults=True,
- export_uuids=True,
- )
- # TODO (betodealmeida): move this logic to export_to_dict once this
- # becomes the default export endpoint
- if "extra" in payload:
- try:
- payload["extra"] = json.loads(payload["extra"])
- except json.JSONDecodeError:
- logger.info("Unable to decode `extra` field: %s",
payload["extra"])
+ # Only yield if not already seen (similar to dataset export)
+ if file_name not in seen:
+ payload = model.database.export_to_dict(
+ recursive=False,
+ include_parent_ref=False,
+ include_defaults=True,
+ export_uuids=True,
+ )
+ # TODO (betodealmeida): move this logic to export_to_dict once
this
+ # becomes the default export endpoint
+ if "extra" in payload:
+ try:
+ payload["extra"] = json.loads(payload["extra"])
+ except json.JSONDecodeError:
Review Comment:
Good catch, fixed! `extra` can be `None` for databases that never got that
column populated, and `json.loads(None)` raises `TypeError`, not
`JSONDecodeError`. Added it to the except tuple, matching the pattern already
used elsewhere in the export commands.
##########
superset/commands/theme/export.py:
##########
@@ -67,8 +67,12 @@ def _file_content(model: Theme) -> str:
@staticmethod
def _export(
- model: Theme, export_related: bool = True
+ model: Theme, export_related: bool = True, seen: set[str] | None = None
) -> Iterator[tuple[str, Callable[[], str]]]:
+ # Initialize seen set if not provided (for consistency)
+ if seen is None:
+ seen = set()
+
yield (
ExportThemesCommand._file_name(model),
lambda: ExportThemesCommand._file_content(model),
Review Comment:
This only yields once, not in a loop, so there's nothing late-binding could
actually get wrong here.
##########
superset/commands/dashboard/export.py:
##########
@@ -189,7 +193,8 @@ def _export(
dashboard_ids = model.id
command = ExportChartsCommand(chart_ids)
command.disable_tag_export()
- yield from command.run()
+ # Pass the shared seen set to the chart export command
+ yield from command.run(seen=seen)
command.enable_tag_export()
if feature_flag_manager.is_feature_enabled("TAGGING_SYSTEM"):
yield from ExportTagsCommand.export(
Review Comment:
Whatever `_export()` yields, including this `yield from`, still passes
through `run()`'s wrapping loop, which dedupes on filename. This is 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]