feat: new import commands for dataset and databases (#11670)

* feat: commands for importing databases and datasets

* Refactor code
This commit is contained in:
Beto Dealmeida
2020-11-16 17:11:20 -08:00
committed by GitHub
parent 871a98abe2
commit 7bc353f8a8
16 changed files with 983 additions and 7 deletions

View File

@@ -304,6 +304,9 @@ def import_datasources(path: str, sync: str, recursive: bool) -> None:
from superset.datasets.commands.importers.v0 import ImportDatasetsCommand
sync_array = sync.split(",")
sync_columns = "columns" in sync_array
sync_metrics = "metrics" in sync_array
path_object = Path(path)
files: List[Path] = []
if path_object.is_file():
@@ -316,7 +319,7 @@ def import_datasources(path: str, sync: str, recursive: bool) -> None:
files.extend(path_object.rglob("*.yml"))
contents = {path.name: open(path).read() for path in files}
try:
ImportDatasetsCommand(contents, sync_array).run()
ImportDatasetsCommand(contents, sync_columns, sync_metrics).run()
except Exception: # pylint: disable=broad-except
logger.exception("Error when importing dataset")