Skip to content

Commit

Permalink
Fix load examples
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Mar 15, 2023
1 parent da8a999 commit 3a8d104
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
7 changes: 1 addition & 6 deletions superset/cli/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from flask.cli import with_appcontext

import superset.utils.database as database_utils
from superset import security_manager

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -114,8 +113,4 @@ def load_examples(
force: bool = False,
) -> None:
"""Loads a set of Slices and Dashboards and a supporting dataset"""
# pylint: disable=import-outside-toplevel
from superset.utils.core import override_user

with override_user(security_manager.find_user(username="admin")):
load_examples_run(load_test_data, load_big_data, only_metadata, force)
load_examples_run(load_test_data, load_big_data, only_metadata, force)
24 changes: 9 additions & 15 deletions superset/commands/importers/v1/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from sqlalchemy.orm.exc import MultipleResultsFound
from sqlalchemy.sql import select

from superset import db
from superset import db, security_manager
from superset.charts.commands.importers.v1 import ImportChartsCommand
from superset.charts.commands.importers.v1.utils import import_chart
from superset.charts.schemas import ImportV1ChartSchema
Expand All @@ -42,7 +42,7 @@
from superset.datasets.commands.importers.v1.utils import import_dataset
from superset.datasets.schemas import ImportV1DatasetSchema
from superset.models.dashboard import dashboard_slices
from superset.utils.core import get_example_default_schema
from superset.utils.core import get_example_default_schema, override_user
from superset.utils.database import get_example_database


Expand All @@ -69,12 +69,13 @@ def run(self) -> None:

# rollback to prevent partial imports
try:
self._import(
db.session,
self._configs,
self.overwrite,
self.force_data,
)
with override_user(security_manager.find_user(username="admin")):
self._import(
db.session,
self._configs,
self.overwrite,
self.force_data,
)
db.session.commit()
except Exception as ex:
db.session.rollback()
Expand Down Expand Up @@ -124,13 +125,6 @@ def _import( # pylint: disable=arguments-differ, too-many-locals, too-many-bran
if config["schema"] is None:
config["schema"] = get_example_default_schema()

dataset = import_dataset(
session,
config,
overwrite=overwrite,
force_data=force_data,
)

try:
dataset = import_dataset(
session,
Expand Down

0 comments on commit 3a8d104

Please sign in to comment.