예제 #1
0
def init(repo_path: Text, pipelines_dir: Text = None,
         analytics_opt_in: bool = None):
    """Initialize ZenML on given path."""
    if repo_path is None:
        repo_path = os.getcwd()

    if analytics_opt_in is None:
        analytics_opt_in = confirmation(
            "ZenML collects anonymized usage information. This data helps us "
            "create a better product and understand the needs of the "
            "community better. You can find more information about exactly "
            "why, what and how we collect usage analytics statistics at: "
            "https://docs.zenml.io/misc/usage-analytics. "
            "Would you like to opt-in to usage analytics?")

    try:
        Repository.init_repo(
            repo_path,
            None,
            None,
            pipelines_dir,
            analytics_opt_in,
        )
        click.echo(f'ZenML repo initialized at {repo_path}')
    except git.InvalidGitRepositoryError:
        click.echo(f'{repo_path} is not a valid git repository! Please '
                   f'initialize ZenML within a git repository.')
예제 #2
0
def clean(repo: Repository, yes: bool = False):
    """Clean everything in repository."""
    if not yes:
        confirm = 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?")
    else:
        confirm = True

    click.echo("Not implemented for this version")
예제 #3
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")
예제 #4
0
def clean(git_examples_handler: GitExamplesHandler) -> None:
    """Deletes the ZenML examples directory from your current working
    directory."""
    examples_directory = os.path.join(os.getcwd(), "zenml_examples")
    if (fileio.file_exists(examples_directory)
            and fileio.is_dir(examples_directory) and confirmation(
                "Do you wish to delete the ZenML examples directory? \n"
                f"{examples_directory}")):
        git_examples_handler.clean_current_examples()
        declare(
            "ZenML examples directory was deleted from your current working "
            "directory.")
    elif not fileio.file_exists(examples_directory) and not fileio.is_dir(
            examples_directory):
        logger.error(f"Unable to delete the ZenML examples directory - "
                     f"{examples_directory} - "
                     "as it was not found in your current working directory.")
예제 #5
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}")