예제 #1
0
파일: utils.py 프로젝트: ws1993/superset
def load_configs_from_directory(root: Path,
                                overwrite: bool = True,
                                force_data: bool = False) -> None:
    """
    Load all the examples from a given directory.
    """
    contents: Dict[str, str] = {}
    queue = [root]
    while queue:
        path_name = queue.pop()
        if path_name.is_dir():
            queue.extend(path_name.glob("*"))
        elif path_name.suffix.lower() in YAML_EXTENSIONS:
            with open(path_name) as fp:
                contents[str(path_name.relative_to(root))] = fp.read()

    # removing "type" from the metadata allows us to import any exported model
    # from the unzipped directory directly
    metadata = yaml.load(contents.get(METADATA_FILE_NAME, "{}"))
    if "type" in metadata:
        del metadata["type"]
    contents[METADATA_FILE_NAME] = yaml.dump(metadata)

    command = ImportExamplesCommand(contents,
                                    overwrite=overwrite,
                                    force_data=force_data)
    try:
        command.run()
    except CommandInvalidError as ex:
        _logger.error("An error occurred: %s", ex.normalized_messages())
예제 #2
0
파일: utils.py 프로젝트: yike5460/superset
def load_from_configs(force_data: bool = False,
                      load_test_data: bool = False) -> None:
    contents = load_contents(load_test_data)
    command = ImportExamplesCommand(contents,
                                    overwrite=True,
                                    force_data=force_data)
    command.run()
예제 #3
0
파일: utils.py 프로젝트: ws1993/superset
def load_examples_from_configs(force_data: bool = False,
                               load_test_data: bool = False) -> None:
    """
    Load all the examples inside superset/examples/configs/.
    """
    contents = load_contents(load_test_data)
    command = ImportExamplesCommand(contents,
                                    overwrite=True,
                                    force_data=force_data)
    command.run()
예제 #4
0
파일: utils.py 프로젝트: expanAI/SmartShelf
def load_from_configs() -> None:
    contents = load_contents()
    command = ImportExamplesCommand(contents, overwrite=True)
    command.run()