更新时间:2023-12-14 GMT+08:00

更新开发环境实例信息

功能介绍

该接口用于更新开发环境实例的描述信息或自动停止信息。

URI

PUT /v1/{project_id}/demanager/instances/{instance_id}

参数说明如表1所示。
表1 参数说明

参数

是否必选

参数类型

说明

project_id

String

用户项目ID。获取方法请参见获取项目ID和名称

instance_id

String

实例ID。

请求消息

请求参数如表2所示
表2 请求参数

参数

是否必选

参数类型

说明

description

String

配置描述,长度限制为512字符,不可包含特殊字符&<>"'/。

spec

Object

实例定义,如表3 spec定义数据结构说明所示。

表3 spec定义数据结构说明

参数

是否必选

参数类型

说明

auto_stop

Object

自动停止参数,如表4所示。

表4 auto_stop定义数据结构说明

参数

是否必选

参数类型

说明

enable

Boolean

是否开启自动停止功能, true表示开启,则会在运行时长到达之后自动停止实例,false表示关闭,默认为false。

duration

Integer

运行时长,单位为秒,取值范围为3600-86400,该参数配置之后,每次启动均有效。如果enable为true时,该参数是必须的。如果当前实例的状态为运行中,修改此参数,只有在下次启动才会生效。

prompt

Boolean

是否需要再次提醒,该参数提供给前台console,用于让console判断是否需要再次弹出弹出框对用户进行提醒,默认是true。

响应消息

响应参数如表5所示。
表5 响应参数

参数

参数类型

说明

id

String

实例ID。

name

String

实例名称。

description

String

实例说明。

status

String

实例状态。

creation_timestamp

String

实例的创建时间。

latest_update_timestamp

String

实例的更新时间。

profile

Object

配置信息,如表12所示。

flavor

String

机器规格。

flavor_details

Object

机器规格详情,如表16所示。

pool

Object

专属资源池,如表17所示。

spec

Object

实例定义。Notebook类型实例,数据结构如表14所示。

workspace

Object

工作空间,如表7所示。

ai_project

Object

AI项目,如表12所示。

error_code

String

错误码。请参考错误码

queuing_info

Object

排队信息,如表26所示。

user

Object

用户信息,如表27所示。

repository

Object

Git仓库信息,如表28所示。该字段不支持使用,在调用接口时会自动返回。

表6 profile字段数据结构说明

参数

参数类型

说明

id

String

配置ID。

name

String

配置名称。

description

String

配置描述。

de_type

String

开发环境类型,当前仅支持Notebook。

provision

Object

部署信息,如表4所示。

labels

Map<String,String>

标签信息。

flavor_type

String

硬件类型。支持CPU,GPU,Ascend。

表7 provision字段数据结构说明

参数

参数类型

说明

type

String

部署类型,当前仅支持Docker。

spec

Object

部署详情,如表8所示。

表8 spec字段数据结构说明

参数

参数类型

说明

engine

String

部署引擎,当前仅支持CCE。

params

Object

部署参数,当前仅支持Docker,如表9所示。

表9 Docker部署参数数据结构说明

参数

参数类型

说明

namespace

String

SWR组织名称,全局唯一。

image_name

String

镜像名称。

image_tag

String

镜像标签。

annotations

Map<String,String>

注解信息,可扩展字段,缺省值为“NULL”

表10 flavor_details参数说明

参数

参数类型

描述

name

String

规格名称。

status

String

规格销售状态。当前支持:

  • onSale
  • soldOut

queuing_num

Integer

“promo_type”“Free”“status”“soldOut”时,该参数必选。

queue_left_time

Integer

排到队的剩余时间,单位为秒。

“promo_type”“Free”“status”“soldOut”时,该参数必选。

storage_list

Array< storageType >

支持的存储类型。默认为全部。

  • obs
  • evs
  • efs

is_permitted

Boolean

当前用户是否有权限使用该规格。

type

String

规格状态。当前支持:

  • GPU
  • CPU
  • ASCEND

params

Dict

描述规格的参数。

promo_type

String

促销类型。包括:

  • Free
  • NoDiscount

instance_num

Integer

当前用户创建地该规格实例的数量。

duration

Integer

启动后设置的自动停止时间,单位为秒。

store_time

Integer

该规格实例处于非活跃状态,在数据库最长保存的时长。单位为小时。

默认为“-1”, 表示可以无限制保存。

billing_flavor

String

计费规格。当该字段为空时,使用规格名称计费。

billing_params

Integer

计费倍率。当billing_flavor不为空时,该字段必选。

表11 pool参数说明

参数

参数类型

描述

id

String

资源池ID。

name

String

资源池名称。

type

String

资源池类型。主要区分类型:USER_DEFINED,表明为专属资源池。

owner

Object

“type”“USER_DEFINED”时是必选项。如表13所示。

表12 AIProject

参数

参数类型

描述

id

String

AI项目ID。

表13 owner参数说明

参数

是否必选

参数类型

描述

project_id

String

项目ID。

表14 notebook字段数据结构说明

参数

参数类型

说明

log_path

String

自定义镜像日志存储路径。

custom_script_path

String

Notebook启动时的自定义初始化脚本路径。

extend_storage

Array<Storage>

扩展存储列表,如表4所示。扩展存储当前仅支持type为“obsfs”的类型,且仅对部分专属资源池开放。

storage

Object

存储路径。表4

credential

Object

访问OBS的AK/SK。表30

repository

Object

Git仓库信息,如表28所示。该字段不支持使用,在调用接口时会自动返回。

resource_reserved_timestamp

Integer

资源预留时间戳。

auto_stop

Object

自动停止参数,如表6所示。

failed_reasons

Object

创建、启动失败原因,如表22所示。

annotations

Map<String,String>

注解信息。

其中,生成的url信息,不可直接访问使用。

extend_params

Map<String,String>

扩展参数。

表15 storage定义数据结构说明

参数

参数类型

说明

type

String

存储类型。当前支持“obs”“obsfs”“evs”,其中,obsfs类型当前仅支持部分专属资源池。若您需要挂载OBS并行文件系统,请提工单。

location

Object

存储位置,如果type为“obs”类型,该参数必须填写,如表16所示数据结构,如缺省值为“NULL”

表16 location定义数据结构说明

参数

是否必选

参数类型

说明

path

String

存储路径。

  • 如果type为“obs”类型,该值必须填写,该值需为有效的OBS桶路径,且以“/”结束。不能指定为OBS桶的根目录,需指定为OBS桶下的具体目录。
  • 如果type为“obsfs”类型,该值需为有效的OBS并行文件系统的桶名(当前CCE不支持挂载子目录)。
  • 如果type为“evs”类型,该值不需要填写。

volume_size

Integer

EVS存储盘大小,最小为5GB,最大为4096GB,缺省值为5GB;如果type为OBS类型,该值不需要填写。

mount_path

String

Notebook内的挂载路径,仅type为“obsfs”类型,该字段有效。

默认值为“/home/ma-user/work”

若希望挂载到指定路径,建议填写“/home/ma-user/work”的子目录,否则可能因权限等问题导致挂载失败或读写异常。

access_modes

String

挂载文件的访问权限,支持读写和只读两种方式,仅type为“obsfs”类型,该字段有效。可选值:

  • ReadOnlyMany:只读方式
  • ReadWriteMany:读写方式(默认值)
表17 auto_stop字段数据结构说明

参数

参数类型

说明

enable

Boolean

是否开启自动停止功能。

duration

Integer

运行时长,单位为秒。

prompt

Boolean

是否需要再次弹框提醒,提供给console使用。

stop_timestamp

Integer

实例停止时间点, 13位时间戳。

remain_time

Integer

实际停止剩余时间,单位为秒。

表18 failed_reasons字段数据结构说明

参数

参数类型

说明

code

String

错误码。

message

String

错误信息。

detail

Map<String,String>

错误详情。

表19 workspace字段数据结构说明

参数

参数类型

描述

id

String

工作空间ID。未创建工作空间时取值默认值为0,存在创建并使用的工作空间,以实际取值为准。

表20 queuing_info参数说明

参数

参数类型

描述

id

String

实例ID。

name

String

实例名称。

de_type

String

开发环境类型,缺省时返回全部类型。

当前仅支持Notebook。

flavor

String

实例的机器规格,缺省时返回全部类型。现在支持的有:

  • modelarts.vm.cpu.free
  • modelarts.vm.gpu.free

flavor_details

Object

规格详情,用于展示规格信息,以及查询规格是否售罄。请参见表16

status

String

实例状态,缺省时返回全部类型。包括:

  • CREATE_QUEUING
  • START_QUEUING

begin_timestamp

Integer

实例排队的开始时间,13位时间戳。

remain_time

Integer

排到队的剩余时间,单位为秒。

end_timestamp

Integer

实例排队的预计停止时间,13位时间戳。

rank

Integer

实例在队列中的排位。

表21 user字段数据结构说明

参数

参数类型

说明

id

String

用户ID。

name

String

用户名。

表22 repository字段数据结构说明

参数

参数类型

说明

id

String

仓库ID。

branch

String

仓库分支。

user_name

String

仓库配置用户名。

user_email

String

仓库配置用户邮箱。

type

String

仓库类型。CodeClub,GitHub。

connection_info

Object

仓库链接信息。请参见表29

表23 connection_info字段数据结构说明

参数

参数类型

说明

protocol

String

链接仓库协议。当前支持:ssh,https。

url

String

链接仓库地址。

credential

Object

证书信息,请参见表30

表24 credential字段数据结构说明

参数

参数类型

说明

ssh_private_key

String

ssh私有证书。

access_token

String

GitHub的oauth token。

请求示例

如下以更新实例ID为“6fa459ea-ee8a-3ca4-894e-db77e160355e”的实例信息为例。

{
  "description": "machine learning python2.7 notebook"
}

响应示例

  • 成功响应示例
    {
        "ai_project": {
            "id": "default-ai-project"
        },
        "creation_timestamp": "1594887749962",
        "description": "update notebook",
        "flavor": "modelarts.bm.gpu.v100NV32",
        "flavor_details": {
            "name": "modelarts.bm.gpu.v100NV32",
            "params": {
                "CPU": 8,
                "GPU": 1,
                "gpu_type": "v100NV32",
                "memory": "64GiB"
            },
            "status": "onSale",
            "type": "GPU"
        },
        "id": "DE-7d558ef8-c73d-11ea-964c-0255ac100033",
        "latest_update_timestamp": "1594888143062",
        "name": "notebook-c6fd",
        "profile": {
            "de_type": "Notebook",
            "description": "multi engine, gpu, python 3.6 for notebook",
            "flavor_type": "GPU",
            "id": "Python3-gpu",
            "name": "Python3",
            "provision": {
                "spec": {
                    "engine": "CCE",
                    "params": {
                        "annotations": null,
                        "image_name": "mul-kernel-gpu-cuda-cp36",
                        "image_tag": "2.0.5-B003",
                        "namespace": "atelier"
                    }
                },
                "type": "Docker"
            }
        },
        "status": "RUNNING",
        "user": {
            "id": "15dda26361214ca2a5953917d2f48ffb",
            "name": "ops_dev_env"
        },
        "workspace": {
            "id": "0"
        }
    }
  • 失败响应示例
    {
        "error_message": "The instance does not exist.",
        "error_code": "ModelArts.6309"
    }

状态码

状态码请参见状态码