Exemplo n.º 1
0
def create(ctx, name, owner, description, private, init):
    """Create a new project.

    Uses /docs/core/cli/#caching

    Example:

    \b
    $ polyaxon project create --name=cats-vs-dogs --description="Image Classification with DL"
    """
    owner = owner or AuthConfigManager.get_value("username")

    if not owner:
        Printer.print_error(
            "Please login first or provide a valid owner --owner. "
            "`polyaxon login --help`")
        sys.exit(1)

    try:
        project_config = V1Project(name=name,
                                   description=description,
                                   is_public=not private)
        _project = ProjectClient(owner=owner).create(project_config)
    except (ApiException, HTTPError) as e:
        handle_cli_error(e,
                         message="Could not create project `{}`.".format(name))
        sys.exit(1)

    Printer.print_success("Project `{}` was created successfully.".format(
        _project.name))

    if init:
        ctx.obj = {}
        ctx.invoke(init_project, project=name)
Exemplo n.º 2
0
def ls(owner, limit, offset):
    """List projects.

    Uses /docs/core/cli/#caching
    """
    owner = owner or AuthConfigManager.get_value("username")
    if not owner:
        Printer.print_error(
            "Please login first or provide a valid owner --owner. "
            "`polyaxon login --help`")
        sys.exit(1)

    try:
        polyaxon_client = ProjectClient(owner=owner)
        response = polyaxon_client.list(limit=limit, offset=offset)
    except (ApiException, HTTPError) as e:
        handle_cli_error(e, message="Could not get list of projects.")
        sys.exit(1)

    meta = get_meta_response(response)
    if meta:
        Printer.print_header("Projects for current user")
        Printer.print_header("Navigation:")
        dict_tabulate(meta)
    else:
        Printer.print_header("No projects found for current user")

    objects = list_dicts_to_tabulate(
        [o.to_dict() for o in response.results],
        humanize_values=True,
        exclude_attrs=["uuid", "description"],
    )
    if objects:
        Printer.print_header("Projects:")
        dict_tabulate(objects, is_list_dict=True)
Exemplo n.º 3
0
def get_project_info(project):
    parts = project.replace(".", "/").split("/")
    if len(parts) == 2:
        owner, project_name = parts
    else:
        owner = AuthConfigManager.get_value("username")
        project_name = project

    return owner, project_name
Exemplo n.º 4
0
    def get_config_from_manager():
        from polyaxon.managers.client import ClientConfigManager

        config = ClientConfigManager.get_config_or_default()
        config.token = AuthConfigManager.get_value("token")
        return config
Exemplo n.º 5
0
def get_username_or_local(username):
    return username or AuthConfigManager.get_value("username")