Skip to content
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

fix: remove keys in dashboard export #12115

Merged
merged 1 commit into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions superset/dashboards/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import logging
import random
import string
from typing import Any, Dict, Iterator, List, Tuple
from typing import Any, Dict, Iterator, List, Optional, Tuple

import yaml
from werkzeug.utils import secure_filename
Expand Down Expand Up @@ -108,8 +108,8 @@ def _export(model: Dashboard) -> Iterator[Tuple[str, str]]:
# TODO (betodealmeida): move this logic to export_to_dict once this
# becomes the default export endpoint
for key, new_name in JSON_KEYS.items():
if payload.get(key):
value = payload.pop(key)
value: Optional[str] = payload.pop(key, None)
if value:
try:
payload[new_name] = json.loads(value)
except (TypeError, json.decoder.JSONDecodeError):
Expand Down
4 changes: 2 additions & 2 deletions superset/dashboards/commands/importers/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def update_id_refs(config: Dict[str, Any], chart_ids: Dict[str, int]) -> Dict[st
id_map = {old_id: chart_ids[uuid] for uuid, old_id in old_ids.items()}

# fix metadata
metadata = fixed["metadata"]
metadata = fixed.get("metadata", {})
if "timed_refresh_immune_slices" in metadata:
metadata["timed_refresh_immune_slices"] = [
id_map[old_id] for old_id in metadata["timed_refresh_immune_slices"]
Expand Down Expand Up @@ -82,7 +82,7 @@ def update_id_refs(config: Dict[str, Any], chart_ids: Dict[str, int]) -> Dict[st
}

# fix position
position = fixed["position"]
position = fixed.get("position", {})
for child in position.values():
if (
isinstance(child, dict)
Expand Down