예제 #1
0
def register_metadata_store(metadata_store_name: str, metadata_store_type: str,
                            args: List[str]) -> None:
    """Register a metadata store."""

    try:
        parsed_args = cli_utils.parse_unknown_options(args)
    except AssertionError as e:
        cli_utils.error(str(e))
        return

    repo: Repository = Repository()
    try:
        # TODO [ENG-187]: Remove when we rework the registry logic
        from zenml.core.component_factory import metadata_store_factory

        comp = metadata_store_factory.get_single_component(metadata_store_type)
    except AssertionError as e:
        cli_utils.error(str(e))
        return

    metadata_store = comp(**parsed_args)
    service = repo.get_service()
    service.register_metadata_store(metadata_store_name, metadata_store)
    cli_utils.declare(
        f"Metadata Store `{metadata_store_name}` successfully registered!")
예제 #2
0
def init(
    repo_path: Optional[str],
) -> None:
    """Initialize ZenML on given path.

    Args:
      repo_path: Path to the repository.

    Raises:
        InvalidGitRepositoryError: If repo is not a git repo.
        AssertionError
    """
    if sys.version_info.minor == 6:
        warning(
            "ZenML support for Python 3.6 will be deprecated soon. Please "
            "consider upgrading your Python version to ensure ZenML works "
            "properly in the future."
        )
    if repo_path is None:
        repo_path = os.getcwd()

    declare(f"Initializing at {repo_path}")

    try:
        Repository.init_repo(repo_path=repo_path)
        declare(f"ZenML repo initialized at {repo_path}")
    except git.InvalidGitRepositoryError:  # type: ignore[attr-defined]
        error(
            f"{repo_path} is not a valid git repository! Please "
            f"initialize ZenML within a git repository using "
            f"`git init `"
        )
    except AssertionError as e:
        error(f"{e}")
예제 #3
0
파일: config.py 프로젝트: zeta1999/zenml
def list_config():
    """Print the current ZenML config to the command line"""
    try:
        repo: Repository = Repository.get_instance()
    except Exception as e:
        error(e)
        return

    click.echo(to_pretty_string(repo.zenml_config))
예제 #4
0
파일: pipeline.py 프로젝트: zeta1999/zenml
def get_pipeline_by_name(repo: Repository, pipeline_name: Text):
    """
    Gets pipeline from current repository by matching a name against a
    pipeline name in the repository.
    """
    try:
        p = repo.get_pipeline_by_name(pipeline_name)
    except Exception as e:
        error(e)
        return

    pretty_print(p)
예제 #5
0
def clean(yes: bool = False) -> None:
    """Clean everything in repository.

    Args:
      yes: bool:  (Default value = False)
    """
    if not yes:
        _ = confirmation(
            "This will completely delete all pipelines, their associated "
            "artifacts and metadata ever created in this ZenML repository. "
            "Are you sure you want to proceed?"
        )

    error("Not implemented for this version")
예제 #6
0
def info(git_examples_handler: GitExamplesHandler, example_name: str) -> None:
    """Find out more about an example."""
    # TODO [ENG-148]: fix markdown formatting so that it looks nicer (not a
    #  pure .md dump)
    example_obj = None
    for example in git_examples_handler.examples:
        if example.name == example_name:
            example_obj = example

    if example_obj is None:
        error(f"Example {example_name} is not one of the available options."
              f"\nTo list all available examples, type: `zenml example list`")
    else:
        title(example_obj.name)
        pretty_print(example_obj.readme_content)
예제 #7
0
파일: pipeline.py 프로젝트: zeta1999/zenml
def run_pipeline(path_to_config: Text):
    """
    Runs pipeline specified by the given config YAML object.

    Args:
        path_to_config: Path to config of the designated pipeline.
         Has to be matching the YAML file name.
    """
    # config has metadata store, backends and artifact store,
    # so no need to specify them
    try:
        config = read_yaml(path_to_config)
        p: TrainingPipeline = TrainingPipeline.from_config(config)
        p.run()
    except Exception as e:
        error(e)
예제 #8
0
def pull(
    git_examples_handler: GitExamplesHandler,
    example_name: str,
    force: bool,
    version: str,
) -> None:
    """Pull examples straight into your current working directory.
    Add the flag --force or -f to redownload all the examples afresh.
    Use the flag --version or -v and the version number to specify
    which version of ZenML you wish to use for the examples."""
    git_examples_handler.pull(force=force, version=version)
    destination_dir = os.path.join(os.getcwd(), "zenml_examples")
    fileio.create_dir_if_not_exists(destination_dir)

    examples = (git_examples_handler.examples if not example_name else [
        Example(
            example_name,
            Path(
                os.path.join(
                    git_examples_handler.examples_repo.examples_dir,
                    example_name,
                )),
        )
    ])

    for example in examples:
        if not fileio.file_exists(str(example.path)):
            error(
                f"Example {example.name} does not exist! Available examples: "
                f"{[e.name for e in git_examples_handler.examples]}")
            return

        example_destination_dir = os.path.join(destination_dir, example.name)
        if fileio.file_exists(example_destination_dir):
            if confirmation(f"Example {example.name} is already pulled. "
                            f"Do you wish to overwrite the directory?"):
                fileio.rm_dir(example_destination_dir)
            else:
                warning(f"Example {example.name} not overwritten.")
                continue

        declare(f"Pulling example {example.name}...")
        git_examples_handler.copy_example(example, example_destination_dir)

        declare(f"Example pulled in directory: {example_destination_dir}")
예제 #9
0
파일: pipeline.py 프로젝트: zeta1999/zenml
def list_pipelines(repo: Repository):
    """Lists pipelines in the current repository."""
    try:
        pipelines = repo.get_pipelines()

        names = [p.name for p in pipelines]
        types = [p.PIPELINE_TYPE for p in pipelines]
        statuses = [p.get_status() for p in pipelines]
        cache_enabled = [p.enable_cache for p in pipelines]
        filenames = [p.file_name for p in pipelines]

        headers = ["name", "type", "cache enabled", "status", "file name"]

        click.echo(
            tabulate(zip(names, types, cache_enabled, statuses, filenames),
                     headers=headers))
    except Exception as e:
        error(e)
예제 #10
0
def register_orchestrator(orchestrator_name: str, orchestrator_type: str,
                          args: List[str]) -> None:
    """Register an orchestrator."""

    try:
        parsed_args = cli_utils.parse_unknown_options(args)
    except AssertionError as e:
        cli_utils.error(str(e))
        return

    repo: Repository = Repository()
    # TODO [ENG-186]: Remove when we rework the registry logic
    from zenml.core.component_factory import orchestrator_store_factory

    comp = orchestrator_store_factory.get_single_component(orchestrator_type)
    orchestrator_ = comp(**parsed_args)
    service = repo.get_service()
    service.register_orchestrator(orchestrator_name, orchestrator_)
    cli_utils.declare(
        f"Orchestrator `{orchestrator_name}` successfully registered!")