Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Jul 14, 2021
1 parent a1793f3 commit 1943282
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
11 changes: 10 additions & 1 deletion superset/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

from superset import app, appbuilder, config, security_manager
from superset.app import create_app
from superset.examples.utils import load_from_configs
from superset.extensions import celery_app, db
from superset.utils import core as utils
from superset.utils.celery import session_scope
Expand Down Expand Up @@ -194,10 +195,18 @@ def load_examples(
only_metadata: bool = False,
force: bool = False,
) -> None:
"""Loads a set of Slices and Dashboards and a supporting dataset """
"""Loads a set of Slices and Dashboards and a supporting dataset"""
load_examples_run(load_test_data, load_big_data, only_metadata, force)


@with_appcontext
@superset.command()
@click.argument("directory")
def import_(directory: str) -> None:
"""Imports configs from a given directory"""
load_from_configs(force_data=False, load_test_data=False, root=Path(directory))


@with_appcontext
@superset.command()
@click.option("--database_name", "-d", help="Database name to change")
Expand Down
11 changes: 7 additions & 4 deletions superset/examples/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@
YAML_EXTENSIONS = {".yaml", ".yml"}


def load_from_configs(force_data: bool = False, load_test_data: bool = False) -> None:
contents = load_contents(load_test_data)
def load_from_configs(
force_data: bool = False,
load_test_data: bool = False,
root: Path = Path("examples/configs"),
) -> None:
contents = load_contents(root, load_test_data)
command = ImportExamplesCommand(contents, overwrite=True, force_data=force_data)
command.run()


def load_contents(load_test_data: bool = False) -> Dict[str, Any]:
def load_contents(root: Path, load_test_data: bool = False) -> Dict[str, Any]:
"""Traverse configs directory and load contents"""
root = Path("examples/configs")
resource_names = resource_listdir("superset", str(root))
queue = [root / resource_name for resource_name in resource_names]

Expand Down

0 comments on commit 1943282

Please sign in to comment.