Exemplo n.º 1
0
def cache(config_manager, config):
    if config_manager == ProjectManager:
        ProjectManager.set_config(config)
        return
    # Set caching only if we have an initialized project
    if ProjectManager.is_initialized():
        config_manager.set_config(config)
Exemplo n.º 2
0
def _cache_project(config, owner=None, project=None):
    if ProjectManager.is_initialized() and ProjectManager.is_locally_initialized():
        if _is_same_project(owner, project):
            ProjectManager.set_config(config)
            return

    ProjectManager.set_config(config, visibility=ProjectManager.VISIBILITY_GLOBAL)
Exemplo n.º 3
0
def init(project, polyaxonfile, purge):
    """Initialize a new polyaxonfile specification."""
    owner, project_name = get_project_or_local(project)
    try:
        polyaxon_client = PolyaxonClient()
        project_config = polyaxon_client.projects_v1.get_project(
            owner, project_name)
    except (ApiException, HTTPError) as e:
        Printer.print_error(
            "Make sure you have a project with this name `{}`".format(project))
        handle_cli_error(
            e,
            message="You can a create new project with this command: "
            "polyaxon project create "
            "--name={} [--description=...] [--tags=...]".format(project_name),
        )
        sys.exit(1)

    if purge:
        ProjectManager.purge()
        IgnoreManager.purge()
    init_project = False
    if ProjectManager.is_initialized():
        local_project = ProjectManager.get_config()
        click.echo(
            "Warning! This project is already initialized with the following project:"
        )
        with indentation.indent(4):
            indentation.puts("User: {}".format(local_project.user))
            indentation.puts("Project: {}".format(local_project.name))
        if click.confirm("Would you like to override this current config?",
                         default=False):
            init_project = True
    else:
        init_project = True

    if init_project:
        ProjectManager.purge()
        config = polyaxon_client.api_client.sanitize_for_serialization(
            project_config)
        ProjectManager.set_config(config, init=True)
        Printer.print_success("Project was initialized")
    else:
        Printer.print_header("Project config was not changed.")

    init_ignore = False
    if IgnoreManager.is_initialized():
        click.echo("Warning! Found a .polyaxonignore file.")
        if click.confirm("Would you like to override it?", default=False):
            init_ignore = True
    else:
        init_ignore = True

    if init_ignore:
        IgnoreManager.init_config()
        Printer.print_success("New .polyaxonignore file was created.")
    else:
        Printer.print_header(".polyaxonignore file was not changed.")

    if polyaxonfile:
        create_polyaxonfile()
        create_debug_polyaxonfile()