示例#1
0
 def create_run():
     click.echo("Creating a run.")
     try:
         polyaxon_client = RunClient(owner=owner, project=project_name)
         response = polyaxon_client.create(
             name=name, description=description, tags=tags, content=op_spec
         )
         config = polyaxon_client.client.sanitize_for_serialization(response)
         cache.cache(
             config_manager=RunManager,
             config=config,
             owner=owner,
             project=project_name,
         )
         Printer.print_success("A new run `{}` was created".format(response.uuid))
         click.echo(
             "You can view this run on Polyaxon UI: {}".format(
                 get_dashboard_url(
                     subpath="{}/{}/runs/{}".format(
                         owner, project_name, response.uuid
                     )
                 )
             )
         )
     except (ApiException, HTTPError) as e:
         handle_cli_error(e, message="Could not create a run.")
         sys.exit(1)
示例#2
0
def get(ctx):
    """Get info for current project, by project_name, or owner/project_name.

    Uses /docs/core/cli/#caching

    Examples:

    To get current project:

    \b
    $ polyaxon project get

    To get a project by name

    \b
    $ polyaxon project get owner/project
    """
    owner, project_name = get_project_or_local(ctx.obj.get("project"),
                                               is_cli=True)

    try:
        polyaxon_client = ProjectClient(owner=owner, project=project_name)
        polyaxon_client.refresh_data()
        config = polyaxon_client.client.sanitize_for_serialization(
            polyaxon_client.project_data)
        cache.cache(config_manager=ProjectManager, config=config)
    except (ApiException, HTTPError) as e:
        handle_cli_error(
            e, message="Could not get project `{}`.".format(project_name))
        sys.exit(1)

    get_project_details(polyaxon_client.project_data)
示例#3
0
 def cache_run(data):
     config = polyaxon_client.client.sanitize_for_serialization(data)
     cache.cache(
         config_manager=RunConfigManager,
         config=config,
         owner=owner,
         project=project_name,
     )
示例#4
0
def create(ctx, name, description, tags, public, init):
    """Create a new project.

    Uses /docs/core/cli/#caching

    Example:

    \b
    $ polyaxon project create --name=cats-vs-dogs --description="Image Classification with DL"

    \b
    $ polyaxon project create --name=owner/name --description="Project Description"
    """
    if not name:
        Printer.print_error(
            "Please provide a valid name to create a project.",
            command_help="project create",
            sys_exit=True,
        )
    owner, project_name = resolve_entity_info(name or ctx.obj.get("project"),
                                              is_cli=True,
                                              entity_name="project")

    tags = validate_tags(tags)

    if not owner:
        Printer.print_error(
            "Please provide a valid name with an owner namespace: --name=owner/project."
        )
        sys.exit(1)

    try:
        project_config = V1Project(name=project_name,
                                   description=description,
                                   tags=tags,
                                   is_public=public)
        polyaxon_client = ProjectClient(owner=owner)
        _project = polyaxon_client.create(project_config)
        config = polyaxon_client.client.sanitize_for_serialization(_project)
        cache.cache(config_manager=ProjectConfigManager, config=config)
    except (ApiException, HTTPError) as e:
        handle_cli_error(
            e, message="Could not create project `{}`.".format(project_name))
        sys.exit(1)

    Printer.print_success("Project `{}` was created successfully.".format(
        _project.name))
    click.echo("You can view this project on Polyaxon UI: {}".format(
        get_dashboard_url(subpath="{}/{}".format(owner, _project.name))))

    if init:
        ctx.obj = {}
        ctx.invoke(
            init_project,
            project="{}/{}".format(owner, project_name),
            polyaxonignore=True,
        )
示例#5
0
def create(ctx, name, description, tags, private, init):
    """Create a new project.

    Uses /docs/core/cli/#caching

    Example:

    \b
    $ polyaxon project create --project=cats-vs-dogs --description="Image Classification with DL"

    \b
    $ polyaxon project create --project=owner/name --description="Project Description"
    """
    if not name:
        Printer.print_error(
            "Please login provide a name to create a project.",
            command_help="project create",
            sys_exit=True,
        )
    owner, project_name = get_project_or_local(name or ctx.obj.get("project"),
                                               is_cli=True)
    owner = owner or settings.AUTH_CONFIG.username
    if not owner and (not settings.CLI_CONFIG or settings.CLI_CONFIG.is_ce):
        owner = DEFAULT

    tags = validate_tags(tags)

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

    try:
        project_config = V1Project(name=project_name,
                                   description=description,
                                   tags=tags,
                                   is_public=not private)
        polyaxon_client = ProjectClient(owner=owner)
        _project = polyaxon_client.create(project_config)
        config = polyaxon_client.client.sanitize_for_serialization(_project)
        cache.cache(config_manager=ProjectConfigManager, config=config)
    except (ApiException, HTTPError) as e:
        handle_cli_error(
            e, message="Could not create project `{}`.".format(project_name))
        sys.exit(1)

    Printer.print_success("Project `{}` was created successfully.".format(
        _project.name))
    click.echo("You can view this project on Polyaxon UI: {}".format(
        get_dashboard_url(subpath="{}/{}".format(owner, _project.name))))

    if init:
        ctx.obj = {}
        ctx.invoke(init_project, project="{}/{}".format(owner, project_name))
示例#6
0
 def create_run():
     click.echo("Creating a run.")
     run = V1Run(content=specification.config_dump)
     try:
         polyaxon_client = PolyaxonClient()
         response = polyaxon_client.runs_v1.create_run(
             owner, project_name, run)
         cache.cache(config_manager=RunManager, response=response)
         Printer.print_success("A new run `{}` was created".format(
             response.uuid))
     except (ApiException, HTTPError) as e:
         handle_cli_error(e, message="Could not create a run.")
         sys.exit(1)
示例#7
0
 def create_run():
     click.echo("Creating a run.")
     body = V1OperationBody(content=op_spec.to_dict(dump=True))
     try:
         polyaxon_client = PolyaxonClient()
         response = polyaxon_client.runs_v1.create_run(
             owner, project_name, body)
         config = polyaxon_client.sanitize_for_serialization(response)
         cache.cache(config_manager=RunManager, config=config)
         Printer.print_success("A new run `{}` was created".format(
             response.uuid))
     except (ApiException, HTTPError) as e:
         handle_cli_error(e, message="Could not create a run.")
         sys.exit(1)
示例#8
0
def get(ctx, project, uid):
    """Get run.

    Uses /docs/core/cli/#caching

    Examples for getting a run:

    \b
    $ polyaxon ops get  # if run is cached

    \b
    $ polyaxon ops get --uid=8aac02e3a62a4f0aaa257c59da5eab80 # project is cached

    \b
    $ polyaxon ops get --project=cats-vs-dogs -uid 8aac02e3a62a4f0aaa257c59da5eab80

    \b
    $ polyaxon ops get -p alain/cats-vs-dogs --uid=8aac02e3a62a4f0aaa257c59da5eab80
    """

    owner, project_name, run_uuid = get_project_run_or_local(
        project or ctx.obj.get("project"),
        uid or ctx.obj.get("run_uuid"),
        is_cli=True,
    )

    try:
        polyaxon_client = RunClient(owner=owner,
                                    project=project_name,
                                    run_uuid=run_uuid)
        polyaxon_client.refresh_data()
        config = polyaxon_client.client.sanitize_for_serialization(
            polyaxon_client.run_data)
        cache.cache(
            config_manager=RunConfigManager,
            config=config,
            owner=owner,
            project=project_name,
        )
    except (ApiException, HTTPError) as e:
        handle_cli_error(
            e,
            message="Could not load run `{}/{}/{}` info.".format(
                owner, project_name, run_uuid),
        )
        sys.exit(1)

    get_run_details(polyaxon_client.run_data)
示例#9
0
def get(ctx):
    """Get run.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples for getting a run:

    \b
    ```bash
    $ polyaxon runs get  # if run is cached
    ```

    \b
    ```bash
    $ polyaxon runs --uid=8aac02e3a62a4f0aaa257c59da5eab80 get  # project is cached
    ```

    \b
    ```bash
    $ polyaxon runs --project=cats-vs-dogs -id 8aac02e3a62a4f0aaa257c59da5eab80 get
    ```

    \b
    ```bash
    $ polyaxon runs -p alain/cats-vs-dogs --uid=8aac02e3a62a4f0aaa257c59da5eab80 get
    ```
    """

    owner, project_name, run_uuid = get_project_run_or_local(
        ctx.obj.get("project"), ctx.obj.get("run_uuid"), is_cli=True)

    try:
        polyaxon_client = RunClient(owner=owner,
                                    project=project_name,
                                    run_uuid=run_uuid)
        polyaxon_client.refresh_data()
        config = polyaxon_client.client.sanitize_for_serialization(
            polyaxon_client.run_data)
        cache.cache(config_manager=RunManager, config=config)
    except (ApiException, HTTPError) as e:
        handle_cli_error(
            e, message="Could not load run `{}` info.".format(run_uuid))
        sys.exit(1)

    get_run_details(polyaxon_client.run_data)
示例#10
0
def create(ctx, name, owner, description, tags, 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")
    tags = validate_tags(tags)

    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,
                                   tags=tags,
                                   is_public=not private)
        polyaxon_client = ProjectClient(owner=owner)
        _project = polyaxon_client.create(project_config)
        config = polyaxon_client.client.sanitize_for_serialization(
            _project.project_data)
        cache.cache(config_manager=ProjectManager, config=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)
示例#11
0
def get(ctx, project, uid, offline, offline_path):
    """Get run.

    Uses /docs/core/cli/#caching

    Examples for getting a run:

    \b
    $ polyaxon ops get  # if run is cached

    \b
    $ polyaxon ops get --uid=8aac02e3a62a4f0aaa257c59da5eab80 # project is cached

    \b
    $ polyaxon ops get --project=cats-vs-dogs -uid 8aac02e3a62a4f0aaa257c59da5eab80

    \b
    $ polyaxon ops get -p alain/cats-vs-dogs --uid=8aac02e3a62a4f0aaa257c59da5eab80
    """

    uid = uid or ctx.obj.get("run_uuid")

    if offline:
        offline_path = offline_path or container_contexts.CONTEXT_OFFLINE_ROOT
        offline_path = "{}/{}/run_data.json".format(offline_path, uid)
        if not os.path.exists(offline_path):
            Printer.print_error(
                f"Could not get offline run, the path `{offline_path}` "
                f"does not exist.")
            sys.exit(1)
        run_data = RunConfigManager.read_from_path(offline_path)
    else:
        owner, project_name, run_uuid = get_project_run_or_local(
            project or ctx.obj.get("project"),
            uid,
            is_cli=True,
        )

        try:
            polyaxon_client = RunClient(owner=owner,
                                        project=project_name,
                                        run_uuid=run_uuid)
            polyaxon_client.refresh_data()
            config = polyaxon_client.client.sanitize_for_serialization(
                polyaxon_client.run_data)
            cache.cache(
                config_manager=RunConfigManager,
                config=config,
                owner=owner,
                project=project_name,
            )
            run_data = polyaxon_client.run_data
        except (ApiException, HTTPError) as e:
            handle_cli_error(
                e,
                message="Could not load run `{}/{}/{}` info.".format(
                    owner, project_name, run_uuid),
            )
            sys.exit(1)

    get_run_details(run_data)