开发环境的应用示例-九游平台
本节通过调用一系列api,以创建开发环境实例为例介绍modelarts api的使用流程。
概述
创建开发环境实例的流程如下:
- 调用认证鉴权接口获取用户token,在后续的请求中需要将token放到请求消息头中作为认证。
- 调用接口查看开发环境的镜像类型和版本。
- 调用创建notebook实例接口创建一个notebook实例。
- 调用接口根据notebook实例的id查询实例的创建详情。
- 调用接口重置notebook实例的使用时长。
- 调用接口停止正在运行的实例。
- 调用接口重新启动实例。
- 当notebook实例不再需要时,调用接口删除实例。
前提条件
- 已获取和modelarts的endpoint。
- 确认服务的部署区域,获取项目id和名称、获取账号名和id和获取用户名和用户id。
操作步骤
- 调用认证鉴权接口获取用户的token。
- 请求消息体:
uri格式:post https://{iam_endpoint}/v3/auth/tokens
请求消息头:content-type →application/json
请求body:{ "auth": { "identity": { "methods": ["password"], "password": { "user": { "name": "user_name", "password": "user_password", "domain": { "name": "domain_name" } } } }, "scope": { "project": { "name": "cn-north-1" } } } }
其中,加粗的斜体字段需要根据实际值填写:- iam_endpoint为iam的终端节点。
- user_name为iam用户名。
- user_password为用户登录密码。
- domain_name为用户所属的账号名。
- cn-north-1为项目名,代表服务的部署区域。
- 返回状态码“201 created”,在响应header中获取“x-subject-token”的值即为token,如下所示:
x-subject-token →miizmgyjkozihvcnaqccoiizizccgyccaqexdtalbglghkgbzqmeagewgxxxxxx...
- 请求消息体:
-
调用接口查看开发环境的镜像类型和版本。
- 请求消息体:
uri格式:get https://{ma_endpoint}/v1/{project_id}/images
请求消息头:- x-auth-token →miizmgyjkozihvcnaqccoiizizccgyccaqexdtalbglghkgbzqmeagewgxxxxxx...
- content-type →application/json
其中,加粗的斜体字段需要根据实际值填写:
- ma_endpoint为modelarts的终端节点。
- project_id为用户的项目id。
- “x-auth-token”的值是上一步获取到的token值。
-
返回状态码为“200”,响应body如下所示:
{ "current": 0, "data": [ { "arch": "x86_64", "description": "cpu and gpu general algorithm development and training, preconfigured with ai engine pytorch1.8", "dev_services": [ "notebook", "ssh" ], "id": "278e88d1-5b71-4766-8502-b3ba72e824d9", "name": "pytorch1.8-cuda10.2-cudnn7-ubuntu18.04", "resource_categories": [ "cpu", "gpu" ], "service_type": "common", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/pytorch_1_8:pytorch_1.8.0-cuda_10.2-py_3.7-ubuntu_18.04-x86_64-20221118143845-d65d817", "tag": "pytorch_1.8.0-cuda_10.2-py_3.7-ubuntu_18.04-x86_64-20221118143845-d65d817", "tags": [], "type": "build_in", "update_at": 1648866992843, "workspace_id": "0" }, { "arch": "x86_64", "description": "cpu and gpu general algorithm development and training, preconfigured with ai engine mindspore1.7.0 and cuda10.1", "dev_services": [ "notebook", "ssh" ], "id": "e1a07296-22a8-4f05-8bc8-e936c8e54202", "name": "mindspore1.7.0-cuda10.1-py3.7-ubuntu18.04", "resource_categories": [ "gpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindspore_1_7_0:mindspore_1.7.0-cuda_10.1-py_3.7-ubuntu_18.04-x86_64-20221118143809-d65d817", "tag": "mindspore_1.7.0-cuda_10.1-py_3.7-ubuntu_18.04-x86_64-20221118143809-d65d817", "tags": [], "type": "build_in", "workspace_id": "0" }, { "arch": "x86_64", "description": "cpu general algorithm development and training, preconfigured with ai engine mindspore1.7.0", "dev_services": [ "notebook", "ssh" ], "id": "c0b31f09-1490-4555-9b8b-ab0b2de35b20", "name": "mindspore1.7.0-py3.7-ubuntu18.04", "resource_categories": [ "cpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindspore_1_7_0:mindspore_1.7.0-cpu-py_3.7-ubuntu_18.04-x86_64-20221118143809-d65d817", "tag": "mindspore_1.7.0-cpu-py_3.7-ubuntu_18.04-x86_64-20221118143809-d65d817", "tags": [], "type": "build_in", "workspace_id": "0" }, { "arch": "x86_64", "description": "cpu and gpu general algorithm development and training, preconfigured with ai engine tensorflow2.1", "dev_services": [ "notebook", "ssh" ], "id": "e1a07296-22a8-4f05-8bc8-e936c8e54100", "name": "tensorflow2.1-cuda10.1-cudnn7-ubuntu18.04", "resource_categories": [ "cpu", "gpu" ], "service_type": "common", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/tensorflow_2_1:tensorflow_2.1.0-cuda_10.1-py_3.7-ubuntu_18.04-x86_64-20221121111529-d65d817", "tag": "tensorflow_2.1.0-cuda_10.1-py_3.7-ubuntu_18.04-x86_64-20221121111529-d65d817", "tags": [], "type": "build_in", "update_at": 1643166780367, "workspace_id": "0" }, { "arch": "x86_64", "description": "cpu and gpu general algorithm development and training, preconfigured with ai engine pytorch1.10 and cuda10.2", "dev_services": [ "notebook", "ssh" ], "id": "d996b661-e127-48c4-a90a-fca29535f201", "name": "pytorch1.10-cuda10.2-cudnn7-ubuntu18.04", "resource_categories": [ "cpu", "gpu" ], "service_type": "unknown", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/pytorch_1_10:pytorch_1.10.2-cuda_10.2-py_3.7-ubuntu_18.04-x86_64-20221118143845-d65d817", "tag": "pytorch_1.10.2-cuda_10.2-py_3.7-ubuntu_18.04-x86_64-20221118143845-d65d817", "tags": [], "type": "build_in", "workspace_id": "0" }, { "arch": "x86_64", "description": "clean user customized base image include cuda10.2, conda", "dev_services": [ "notebook", "ssh" ], "id": "d937149a-785c-4d2d-a568-8dde7c06cca0", "name": "conda3-cuda10.2-cudnn7-ubuntu18.04", "resource_categories": [ "gpu" ], "service_type": "unknown", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/user_defined_base:cuda_10.2-ubuntu_18.04-x86_64-20230404095316-7fcd503", "tag": "cuda_10.2-ubuntu_18.04-x86_64-20230404095316-7fcd503", "tags": [], "type": "build_in", "workspace_id": "0" }, { "arch": "x86_64", "description": "clean user customized base image only include conda", "dev_services": [ "notebook", "ssh" ], "id": "27542a4a-3b37-404d-add9-a7d2d2ce6893", "name": "conda3-ubuntu18.04", "resource_categories": [ "cpu" ], "service_type": "unknown", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/user_defined_base:ubuntu_18.04-x86_64-20230404095316-7fcd503", "tag": "ubuntu_18.04-x86_64-20230404095316-7fcd503", "tags": [], "type": "build_in", "workspace_id": "0" }, { "arch": "x86_64", "description": "cpu and gpu general algorithm development and training, preconfigured with ai engine pytorch1.4", "dev_services": [ "notebook", "ssh" ], "id": "e1a07296-22a8-4f05-8bc8-e936c8e54099", "name": "pytorch1.4-cuda10.1-cudnn7-ubuntu18.04", "resource_categories": [ "cpu", "gpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/pytorch_1_4:pytorch_1.4-cuda_10.1-py37-ubuntu_18.04-x86_64-20221118143845-d65d817", "tag": "pytorch_1.4-cuda_10.1-py37-ubuntu_18.04-x86_64-20221118143845-d65d817", "tags": [], "type": "build_in", "update_at": 1648866992868, "workspace_id": "0" }, { "arch": "x86_64", "description": "gpu algorithm development and training, preconfigured with ai engine tensorflow1.13.1", "dev_services": [ "notebook", "ssh" ], "id": "b80bbf3d-a7af-42f6-ad12-33ff9116ab0d", "name": "tensorflow1.13-cuda10.0-cudnn7-ubuntu18.04", "resource_categories": [ "gpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/tensorflow_1_13:tensorflow_1.13-cuda_10.0-py_3.7-ubuntu_18.04-x86_64-20221118143845-d65d817", "tag": "tensorflow_1.13-cuda_10.0-py_3.7-ubuntu_18.04-x86_64-20221118143845-d65d817", "tags": [], "type": "build_in", "update_at": 1648866992960, "workspace_id": "0" }, { "arch": "aarch64", "create_at": 1608937196685, "description": "ascend arm algorithm development and training. tensorflow and mindspore are preset in the ai engine.", "dev_services": [ "notebook", "ssh" ], "id": "59a6e9f5-93c0-44dd-85b0-82f390c5d53a", "name": "tensorflow1.15-mindspore1.7.0-cann5.1.0-euler2.8-aarch64", "resource_categories": [ "ascend" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mul-kernel-arm-ascend-cp37:5.0.1-c81-20220726", "tag": "5.0.1-c81-20220726", "tags": [], "type": "build_in", "update_at": 1648866992983, "workspace_id": "0" }, { "arch": "x86_64", "description": "ai inference application development, preconfigured modelbox and ai engine libtorch, only ssh connection supported.", "dev_services": [ "ai_flow", "ssh" ], "id": "e1a07296-22a8-4f05-8bc8-e936c8e54103", "name": "modelbox1.3.0-libtorch1.9.1-cuda10.2-cudnn8-euler2.9.6", "resource_categories": [ "gpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/modelarts-modelbox-libtorch-gpu-x86:1.3.0-20221223142251-b3da6d6", "tag": "1.3.0-20221223142251-b3da6d6", "tags": [], "type": "build_in", "update_at": 1648866993005, "workspace_id": "0" }, { "arch": "x86_64", "description": "ai inference application development, preconfigured modelbox and ai engine tensorrt, only ssh connection supported.", "dev_services": [ "ai_flow", "ssh" ], "id": "e1a07296-22a8-4f05-8bc8-e936c8e54101", "name": "modelbox1.3.0-tensorrt7.1.3-cuda10.2-cudnn8-euler2.9.6", "resource_categories": [ "gpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/modelarts-modelbox-tensorrt-gpu-x86:1.3.0-20221223142251-b3da6d6", "tag": "1.3.0-20221223142251-b3da6d6", "tags": [], "type": "build_in", "update_at": 1648866993030, "workspace_id": "0" }, { "arch": "aarch64", "description": "ascend operator development. the professional operator development tool mindstudio is preconfigured, only ssh connection supported.", "dev_services": [ "ssh" ], "id": "e1a07296-22a8-4f05-8bc8-e936c8e54088", "name": "mindstudio5.0.rc1-ascendsnt9-cann5.1.0-euler2.8.3-aarch64", "resource_categories": [ "ascend" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindstudio-modelarts-image:5.0.rc1-20230322101430-75f458a", "tag": "5.0.rc1-20230322101430-75f458a", "tags": [], "type": "build_in", "update_at": 1648866993052, "workspace_id": "0" }, { "arch": "x86_64", "description": "cpu algorithm development and training, preconfigured pyspark 2.4.5 and scala 2.11.12 for code development in local notebook and remote spark cluster including mrs and dli", "dev_services": [ "notebook" ], "id": "0b2d0728-4c01-11ec-994f-001a7dda7112", "name": "spark2.4.5-ubuntu18.04", "resource_categories": [ "cpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/pyspark_2_4_5:develop-remote-pyspark_2.4.5-py_3.7-cpu-ubuntu_18.04-x86_64-uid1000-20221222203856-fcc979e", "tag": "develop-remote-pyspark_2.4.5-py_3.7-cpu-ubuntu_18.04-x86_64-uid1000-20221222203856-fcc979e", "tags": [], "type": "build_in", "update_at": 1648867218663, "workspace_id": "0" }, { "arch": "x86_64", "create_at": 1605759392357, "description": "cpu algorithm development and training, preconfigured with the ai engine mindspore-cpu", "dev_services": [ "notebook", "ssh" ], "id": "65f636a0-56cf-49df-b941-7d2a07ba8c8c", "name": "mindspore1.2.0-openmpi2.1.1-ubuntu18.04", "resource_categories": [ "cpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindspore_1_2_0:mindspore_1.2.0-py_3.7-ubuntu_18.04-x86_64-20221118143809-d65d817", "tag": "mindspore_1.2.0-py_3.7-ubuntu_18.04-x86_64-20221118143809-d65d817", "tags": [], "type": "build_in", "update_at": 1643166780389, "workspace_id": "0" }, { "arch": "x86_64", "create_at": 1664501979865, "description": "", "dev_services": [ "notebook", "ssh" ], "id": "df78b3f7-98a4-4616-aef0-71cfff4195c9", "name": "spark", "namespace": "testdli002", "origin": "customize", "resource_categories": [ "cpu" ], "service_type": "unknown", "size": 1133670676, "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/testdli002/spark:2.4.5.tensorflow", "tag": "2.4.5.tensorflow", "tags": [], "type": "dedicated", "update_at": 1664501979865, "visibility": "private", "workspace_id": "0" }, { "arch": "x86_64", "create_at": 1664513619044, "description": "", "dev_services": [ "notebook", "ssh" ], "id": "836ab55d-4a02-4dbb-b04f-ece555d642a8", "name": "tensorflow2_1_1", "namespace": "hwstaff_pub_cbuinfo_ei", "origin": "image_save", "resource_categories": [ "cpu", "gpu" ], "service_type": "common", "size": 5094544544, "status": "error", "status_message": "", "swr_path": "swr.cn-north-4.myhuaweicloud.com/hwstaff_pub_cbuinfo_ei/tensorflow2_1_1:1.0.0", "tag": "1.0.0", "tags": [], "type": "dedicated", "update_at": 1664513676950, "visibility": "private", "workspace_id": "0" }, { "arch": "x86_64", "create_at": 1668482562290, "description": "test", "dev_services": [ "notebook", "ssh" ], "id": "689c81b3-15dd-4500-b63e-1871e24eb391", "name": "pytorch_1_8", "namespace": "atelier", "origin": "customize", "resource_categories": [ "gpu" ], "service_type": "unknown", "size": 8285974481, "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/pytorch_1_8:pytorch_1.8.2-cuda_11.1-py_3.7-ubuntu_18.04-x86_64-20220926104358-041ba2e", "tag": "pytorch_1.8.2-cuda_11.1-py_3.7-ubuntu_18.04-x86_64-20220926104358-041ba2e", "tags": [], "type": "dedicated", "update_at": 1668482562290, "visibility": "private", "workspace_id": "0" }, { "arch": "aarch64", "description": "ascend arm algorithm development and training. mindspore is preset in the ai engine.", "dev_services": [ "notebook", "ssh" ], "id": "f6d0908e-9596-41f9-9843-83089cbdd0de", "name": "mindspore1.7.0-cann5.1.0-py3.7-euler2.8.3", "namespace": "atelier", "resource_categories": [ "ascend" ], "service_type": "unknown", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindspore_1_7_0:mindspore_1.7.0-cann_5.1.0-py_3.7-euler_2.8.3-aarch64-snt9-20220906", "tag": "mindspore_1.7.0-cann_5.1.0-py_3.7-euler_2.8.3-aarch64-snt9-20220906", "tags": [], "type": "build_in", "workspace_id": "0" }, { "arch": "aarch64", "description": "ascend arm algorithm development and training. tensorflow is preset in the ai engine.", "dev_services": [ "notebook", "ssh" ], "id": "c5b7507b-ca8d-48d5-a373-fe4b42c66ed8", "name": "tensorflow1.15-cann5.1.0-py3.7-euler2.8.3", "namespace": "atelier", "resource_categories": [ "ascend" ], "service_type": "unknown", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/tensorflow_1_15_ascend:tensorflow_1.15-cann_5.1.0-py_3.7-euler_2.8.3-aarch64-snt9-20220906", "tag": "tensorflow_1.15-cann_5.1.0-py_3.7-euler_2.8.3-aarch64-snt9-20220906", "tags": [], "type": "build_in", "workspace_id": "0" }, { "arch": "x86_64", "create_at": 1678261148079, "description": "", "dev_services": [ "notebook", "ssh" ], "id": "e1ab81ef-f452-46b5-9663-6fc1f982f9e9", "name": "grafana", "namespace": "hwstaff_pub_cbuinfo_ei", "origin": "image_save", "resource_categories": [ "cpu", "gpu" ], "service_type": "common", "size": 5247805223, "status": "active", "status_message": "", "swr_path": "swr.cn-north-4.myhuaweicloud.com/hwstaff_pub_cbuinfo_ei/grafana:v1.0", "tag": "v1.0", "tags": [], "type": "dedicated", "update_at": 1678261330238, "visibility": "private", "workspace_id": "0" }, { "arch": "x86_64", "create_at": 1681973786157, "dev_services": [ "notebook", "ssh" ], "id": "a5a43175-30a6-43d2-9596-38bee562f8c0", "name": "pytorch_1_8", "namespace": "sdk-test2", "origin": "customize", "resource_categories": [ "cpu", "gpu" ], "service_type": "unknown", "size": 2308736380, "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/sdk-test2/pytorch_1_8:v2", "tag": "v2", "tags": [], "type": "dedicated", "update_at": 1681973786157, "visibility": "private", "workspace_id": "0" }, { "arch": "aarch64", "create_at": 1682670088194, "description": "ascend arm algorithm development and training. mindspore is preset in the ai engine.", "dev_services": [ "notebook", "ssh" ], "id": "75cbf0f2-0a3e-48c9-b2c4-7e78af18d86e", "name": "mindspore_1.9.0-cann_6.0.0-py_3.7-euler_2.8.3", "namespace": "atelier", "resource_categories": [ "ascend" ], "service_type": "train", "size": 4011027643, "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindspore_1_9_ascend:mindspore_1.9.0-cann_6.0.0-py_3.7-euler_2.8.3-aarch64-snt9-20221116111529", "tag": "mindspore_1.9.0-cann_6.0.0-py_3.7-euler_2.8.3-aarch64-snt9-20221116111529", "tags": [], "type": "build_in", "update_at": 1682670088197, "visibility": "public", "workspace_id": "0" }, { "arch": "x86_64", "description": "notebook2.0 gpu", "dev_services": [ "notebook", "ssh" ], "id": "e1a07296-22a8-4f05-8bc8-e936c8e54092", "name": "notebook2.0-mul-kernel-cpu-cp36", "resource_categories": [ "gpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mul-kernel-gpu-cp36:5.0.1-release-v2-20220505", "tag": "5.0.1-release-v2-20220505", "tags": [], "type": "build_in", "update_at": 1628221753209, "workspace_id": "0" }, { "arch": "aarch64", "create_at": 1683537880541, "description": "ascend arm algorithm development and training. mindspore is preset in the ai engine.", "dev_services": [ "notebook", "ssh" ], "id": "31ae7ba4-63e6-4fa6-8aeb-cb382953e414", "name": "mindspore_1.10.0-cann_6.0.1-py_3.7-euler_2.8.3", "namespace": "atelier", "resource_categories": [ "ascend" ], "service_type": "common", "size": 4057170552, "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindspore_1_10_ascend:mindspore_1.10.0-cann_6.0.1-py_3.7-euler_2.8.3-aarch64-snt9-20230303173945-815d627", "tag": "mindspore_1.10.0-cann_6.0.1-py_3.7-euler_2.8.3-aarch64-snt9-20230303173945-815d627", "tags": [], "type": "build_in", "update_at": 1683537880548, "visibility": "public", "workspace_id": "0" }, { "arch": "x86_64", "description": "cpu algorithm development and training, including the mlstudio tool for graphical ml algorithm development, and preconfigured pyspark 2.3.2", "dev_services": [ "notebook" ], "id": "0e5f9a41-c9c2-4d9a-a190-4e1b17a7782f", "name": "mlstudio-pyspark2.3.2-ubuntu16.04", "resource_categories": [ "cpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mlstudio-cp36:3.3.1.9", "tag": "3.3.1.9", "tags": [], "type": "build_in", "update_at": 1648867218685, "workspace_id": "0" }, { "arch": "x86_64", "description": "notebook2.0 cpu base image", "dev_services": [ "notebook", "ssh" ], "id": "e1a07296-22a8-4f05-8bc8-e936c8e54090", "name": "notebook2.0-mul-kernel-cpu-cp36", "resource_categories": [ "cpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mul-kernel-cpu-cp36:5.0.1-release-v2-20220505", "tag": "5.0.1-release-v2-20220505", "tags": [], "type": "build_in", "update_at": 1628221753345, "workspace_id": "0" }, { "arch": "x86_64", "description": "gpu algorithm development and training, preconfigured with the ai engine mindspore-gpu", "dev_services": [ "notebook", "ssh" ], "id": "d7fb5355-9045-4deb-94c6-4033e1e62728", "name": "mindspore1.2.0-openmpi2.1.1-ubuntu18.04", "resource_categories": [ "gpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindspore_1_2_0:mindspore_1.2.0-py_3.7-ubuntu_18.04-x86_64-20221118143809-d65d817", "tag": "mindspore_1.2.0-py_3.7-ubuntu_18.04-x86_64-20221118143809-d65d817", "tags": [], "type": "build_in", "update_at": 1636963735672, "workspace_id": "0" }, { "arch": "x86_64", "create_at": 1628757809703, "description": "cpu operations research development, preconfigured with cylp, cbcpy, ortools, cplex(community).", "dev_services": [ "notebook", "ssh" ], "id": "b9933af0-3119-4045-a427-5e668327dafd", "name": "cylp0.91.4-cbcpy2.10-ortools9.0-cplex20.1.0-ubuntu18.04", "namespace": "atelier", "resource_categories": [ "cpu" ], "service_type": "train", "size": 2550402546, "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/or_1_0_0:or_1.0.0-py_3.7-ubuntu_18.04-x86_64-roma-20220812093355-e50493d", "tag": "or_1.0.0-py_3.7-ubuntu_18.04-x86_64-roma-20220812093355-e50493d", "tags": [], "type": "build_in", "update_at": 1642836699554, "workspace_id": "0" }, { "arch": "x86_64", "description": "cpu algorithm development and training, including the mlstudio tool for graphical ml algorithm development, and preconfigured pyspark 2.4.5", "dev_services": [ "notebook" ], "id": "0b2d0728-4c01-11ec-994f-001a7dda7111", "name": "mlstudio-pyspark2.4.5-ubuntu18.04", "resource_categories": [ "cpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mlstudio-cp37:5.0.1-mls-20230118153946", "tag": "5.0.1-mls-20230118153946", "tags": [], "type": "build_in", "update_at": 1648867218708, "workspace_id": "0" }, { "arch": "x86_64", "create_at": 1605759392404, "description": "gpu algorithm development and training, preconfigured with the ai engine mindspore-gpu", "dev_services": [ "notebook", "ssh" ], "id": "89de30ec-6871-4f22-84af-be37ef28335d", "name": "mindspore1.2.0-cuda10.1-cudnn7-ubuntu18.04", "resource_categories": [ "gpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindspore_1_2_0:mindspore_1.2.0-py_3.7-cuda_10.1-ubuntu_18.04-x86_64-20221118143809-d65d817", "tag": "mindspore_1.2.0-py_3.7-cuda_10.1-ubuntu_18.04-x86_64-20221118143809-d65d817", "tags": [], "type": "build_in", "update_at": 1648867218639, "workspace_id": "0" }, { "arch": "x86_64", "description": "description", "dev_services": [ "notebook" ], "id": "88bd7bcd-0c91-45b2-ad0e-ef65553d19c5", "name": "dls-feature-engineering", "resource_categories": [ "cpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mul-kernel-dls-feature-engineering-cpu-py37:3.2.0109", "tag": "3.2.0109", "tags": [], "type": "build_in", "update_at": 1623899358020, "workspace_id": "0" }, { "arch": "x86_64", "description": "description", "dev_services": [ "notebook" ], "id": "1d1b1327-b243-425b-ad81-2689584c1acc", "name": "mls-feature-engineering", "resource_categories": [ "cpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mul-kernel-mls-feature-engineering-cpu-py37:3.2.0109", "tag": "3.2.0109", "tags": [], "type": "build_in", "update_at": 1623899357995, "workspace_id": "0" }, { "arch": "x86_64", "description": "mindspore1.7.0 and mindquantum0.6.0", "dev_services": [ "notebook", "ssh" ], "id": "6592fa02-a40a-4054-a05f-f22215e45ec1", "name": "mindquantum0.6.0-mindspore1.7.0-ubuntu18.04", "resource_categories": [ "cpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindspore_1_7_0:mindspore_1.7.0-cpu-py_3.7-ubuntu_18.04-x86_64-20220727174747-6a4cdd5", "tag": "mindspore_1.7.0-cpu-py_3.7-ubuntu_18.04-x86_64-20220727174747-6a4cdd5", "tags": [], "type": "build_in", "workspace_id": "0" }, { "arch": "x86_64", "create_at": 1628757853111, "description": "cpu and gpu algorithm development and training, preconfigured with ai engine ray for reinforcement learning.", "dev_services": [ "notebook", "ssh" ], "id": "4233d6f9-c3b5-4cf2-9ee6-2ef565935d6d", "name": "rlstudio1.0.0-ray1.3.0-cuda10.1-ubuntu18.04", "namespace": "rl-dev", "resource_categories": [ "cpu", "gpu" ], "service_type": "train", "size": 4857883146, "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-rl-1.0.0-kernel-cp37:rl-v1220211203", "tag": "rl-v1220211203", "tags": [], "type": "build_in", "update_at": 1642836699527, "workspace_id": "0" }, { "arch": "aarch64", "description": "ascend arm algorithm development and training. tensorflow and mindspore are preset in the ai engine.", "dev_services": [ "notebook", "ssh" ], "id": "59a6e9f5-93c0-44dd-85b0-82f390c5d53b", "name": "tensorflow1.15-mindspore1.7.0-cann5.1.0-euler2.8-aarch64", "resource_categories": [ "cpu", "ascend" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mul-kernel-arm-ascend-cp37:5.0.1-c81-20220726", "tag": "5.0.1-c81-20220726", "tags": [], "type": "build_in", "update_at": 1640398185602, "workspace_id": "0" }, { "arch": "x86_64", "description": "cpu general algorithm development and training, preconfigured with ai engine mindspore1.7.0", "dev_services": [ "notebook", "ssh" ], "id": "9d63f4d1-dc09-4873-b669-3483cea777c0", "name": "mindspore1.7.0-ubuntu18.04-default", "resource_categories": [ "cpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindspore_1_7_0:mindspore_1.7.0-cpu-py_3.7-ubuntu_18.04-x86_64-20220625205423-5a13f29", "tag": "mindspore_1.7.0-cpu-py_3.7-ubuntu_18.04-x86_64-20220625205423-5a13f29", "tags": [], "type": "build_in", "workspace_id": "0" }, { "arch": "x86_64", "description": "cpu and gpu general algorithm development and training, preconfigured with ai engine mindspore1.7.0 and cuda10.1", "dev_services": [ "notebook", "ssh" ], "id": "e1a07296-22a8-4f05-8bc8-e936c8e54203", "name": "mindspore1.7.0-ubuntu18.04-default", "resource_categories": [ "gpu" ], "service_type": "train", "status": "active", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/mindspore_1_7_0:mindspore_1.7.0-cuda_10.1-py_3.7-ubuntu_18.04-x86_64-20220625205423-5a13f29", "tag": "mindspore_1.7.0-cuda_10.1-py_3.7-ubuntu_18.04-x86_64-20220625205423-5a13f29", "tags": [], "type": "build_in", "workspace_id": "0" } ], "pages": 1, "size": 200, "total": 39 }
根据“description”和“name”字段选择创建notebook实例所需要的镜像,并记录对应的“id”,本章以tensorflow引擎为例创建notebook实例,记录“id”为"e1a07296-22a8-4f05-8bc8-e936c8e54100"
- 请求消息体:
-
调用创建notebook实例接口创建一个notebook实例。
- 请求消息体:
uri格式:post https://{ma_endpoint}/v1/{project_id}/notebooks
请求消息头:- x-auth-token →miizmgyjkozihvcnaqccoiizizccgyccaqexdtalbglghkgbzqmeagewgxxxxxx...
- content-type →application/json
请求body:
{ "name" : "notebooks_test", "feature" : "notebook", "workspace_id" : "0", "description" : "api-test", "flavor" : "modelarts.vm.cpu.2u", "image_id" : "e1a07296-22a8-4f05-8bc8-e936c8e54090", "volume" : { "category" : "efs", "ownership" : "managed", "capacity" : 50 } }
其中,加粗的斜体字段需要根据实际值填写- ma_endpoint为modelarts的终端节点。
- project_id为用户的项目id。
- x-auth-token的值是上一步获取到的token值。
- “flavor”为notebook实例规格
- “image_id”为notebook实例镜像id
- 返回状态码为“200”,响应body如下所示:
{ "action_progress": [ { "step": 4, "status": "waiting", "description": "initialize the notebook instance." }, { "step": 3, "status": "waiting", "description": "configuring the network." }, { "step": 2, "status": "waiting", "description": "prepare the compute resource." }, { "step": 1, "status": "waiting", "description": "prepare the storage." } ], "create_at": 1687656452472, "description": "api-test", "endpoints": [], "feature": "notebook", "flavor": "modelarts.vm.cpu.2u", "id": "936bea3e-d3df-435e-8b58-d817283284ae", "image": { "description": "", "id": "e1a07296-22a8-4f05-8bc8-e936c8e54090", "name": "notebook2.0-mul-kernel-cpu-cp36", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mul-kernel-cpu-cp36:5.0.1-release-v2-20220505", "tag": "5.0.1-release-v2-20220505", "type": "build_in" }, "lease": { "create_at": 1687656452470, "duration": 3600000, "enable": true, "type": "timing", "update_at": 1687656452470 }, "name": "notebooks_test", "status": "running", "tags": [], "token": "3452e0d5-15fe-a20d-18a2-010a574aeaaf", "update_at": 1687656452588, "user_id": "99250e439b33431081xxxxxxxxxxa885", "workspace_id": "0", "billing_items": [] }
根据响应可以了解notebook实例详情,其中“status”为“running”表示notebook实例创建成功。
- 请求消息体:
- 调用接口根据notebook实例的id查询实例的创建详情。
- 请求消息体:
uri格式:get https://{ma_endpoint}/v1/{project_id}/notebooks/{id}
请求消息头:x-auth-token →miizmgyjkozihvcnaqccoiizizccgyccaqexdtalbglghkgbzqmeagewgxxxxxx...
其中,加粗的斜体字段需要根据实际值填写。
- 返回状态码为“200”,响应body如下所示:
{ "create_at": 1687656452472, "data_volumes": [], "description": "api-test", "endpoints": [ { "service": "notebook", "uri": "https://authoring-modelarts-cnnorth4.huaweicloud.com/936bea3e-d3df-435e-8b58-d817283284ae/lab" } ], "feature": "notebook", "flavor": "modelarts.vm.cpu.2u", "id": "936bea3e-d3df-435e-8b58-d817283284ae", "image": { "description": "", "id": "e1a07296-22a8-4f05-8bc8-e936c8e54090", "name": "notebook2.0-mul-kernel-cpu-cp36", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mul-kernel-cpu-cp36:5.0.1-release-v2-20220505", "tag": "5.0.1-release-v2-20220505", "type": "build_in" }, "lease": { "create_at": 1687656452470, "duration": 3627372, "enable": true, "type": "timing", "update_at": 1687656479842 }, "name": "notebooks_test", "status": "running", "tags": [], "token": "3452e0d5-15fe-a20d-18a2-010a574aeaaf", "update_at": 1687656479880, "url": "https://authoring-modelarts-cnnorth4.huaweicloud.com/936bea3e-d3df-435e-8b58-d817283284ae/lab", "user": { "domain": { "id": "878991804cdc4ba597xxxxxxxxxx9dd9", "name": "hwstaff_pub_cbuinfo_ei" }, "id": "99250e439b33431081xxxxxxxxxxa885", "name": "xxxxxxxxxx" }, "user_id": "99250e439b33431081xxxxxxxxxxa885", "volume": { "category": "efs", "ownership": "managed", "mount_path": "/home/ma-user/work/", "capacity": 50, "read_only": false }, "workspace_id": "0", "billing_items": [ "compute" ] }
- 请求消息体:
- 调用接口重置notebook实例的使用时长。
- 请求消息体:
uri格式:patch https://{ma_endpoint}/v1/{project_id}notebooks/{id}/lease
请求消息头:
- x-auth-token →miizmgyjkozihvcnaqccoiizizccgyccaqexdtalbglghkgbzqmeagewgxxxxxx...
- content-type →application/json
请求body:
{ "duration": 3600000, "type": "timing" }
其中,加粗的字段需要根据实际值填写:
- “duration”为实例运行时长,以创建时间为起点计算,即“创建时间 duration > 当前时刻”时,系统会自动停止实例。
- “type”为自定停止类别,默认为timing。
- 返回状态码为“200”表示标注成功,响应body如下所示:
{ "create_at": 1687656452470, "duration": 4657544, "enable": true, "type": "timing", "update_at": 1687657510014 }
- 请求消息体:
- 调用接口停止正在运行的实例。
- 消息请求体:
uri格式:posthttps://{ma_endpoint}//v1/{project_id}/notebooks/{id}/stop
请求消息头:x-auth-token →miizmgyjkozihvcnaqccoiizizccgyccaqexdtalbglghkgbzqmeagewgxxxxxx...
其中,加粗的斜体字段需要根据实际值填写。
- 返回状态码为“200”,响应body如下所示:
{ "create_at": 1687656452472, "data_volumes": [], "description": "api-test", "endpoints": [ { "service": "notebook", "uri": "https://authoring-modelarts-cnnorth4.huaweicloud.com/936bea3e-d3df-435e-8b58-d817283284ae/lab" } ], "feature": "notebook", "flavor": "modelarts.vm.cpu.2u", "id": "936bea3e-d3df-435e-8b58-d817283284ae", "image": { "description": "", "id": "e1a07296-22a8-4f05-8bc8-e936c8e54090", "name": "notebook2.0-mul-kernel-cpu-cp36", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mul-kernel-cpu-cp36:5.0.1-release-v2-20220505", "tag": "5.0.1-release-v2-20220505", "type": "build_in" }, "lease": { "create_at": 1687656452470, "duration": 6199814, "enable": true, "type": "timing", "update_at": 1687659052284 }, "name": "notebooks_test", "status": "stopping", "tags": [], "token": "3452e0d5-15fe-a20d-18a2-010a574aeaaf", "update_at": 1687656479880, "url": "https://authoring-modelarts-cnnorth4.huaweicloud.com/936bea3e-d3df-435e-8b58-d817283284ae/lab", "user": { "domain": { "id": "878991804cdc4ba597xxxxxxxxxx9dd9", "name": "hwstaff_test" }, "id": "99250e439b33431081xxxxxxxxxxa885", "name": "test" }, "user_id": "99250e439b33431081xxxxxxxxxxa885", "volume": { "category": "efs", "ownership": "managed", "mount_path": "/home/ma-user/work/", "capacity": 50, "read_only": false }, "workspace_id": "0", "billing_items": [] }
- 消息请求体:
- 调用接口重新启动实例。
- 消息请求体:
uri格式:get https://{ma_endpoint}/v1/{project_id}/notebooks/{id}/start
请求消息头:x-auth-token →miizmgyjkozihvcnaqccoiizizccgyccaqexdtalbglghkgbzqmeagewgxxxxxx...
其中,加粗的斜体字段需要根据实际值填写。
- 返回状态码为“200”,响应body如下所示:
{ "create_at": 1687656452472, "data_volumes": [], "description": "api-test", "endpoints": [ { "service": "notebook", "uri": "https://authoring-modelarts-cnnorth4.huaweicloud.com/936bea3e-d3df-435e-8b58-d817283284ae/lab" } ], "feature": "notebook", "flavor": "modelarts.vm.cpu.2u", "id": "936bea3e-d3df-435e-8b58-d817283284ae", "image": { "description": "", "id": "e1a07296-22a8-4f05-8bc8-e936c8e54090", "name": "notebook2.0-mul-kernel-cpu-cp36", "swr_path": "swr.cn-north-4.myhuaweicloud.com/atelier/notebook2.0-mul-kernel-cpu-cp36:5.0.1-release-v2-20220505", "tag": "5.0.1-release-v2-20220505", "type": "build_in" }, "lease": { "create_at": 1687656452470, "duration": 6540099, "enable": true, "type": "timing", "update_at": 1687659392569 }, "name": "notebooks_test", "status": "starting", "tags": [], "token": "6f773860-21d4-9fe8-75c8-a38ea13ebf08", "update_at": 1687659203630, "url": "https://authoring-modelarts-cnnorth4.huaweicloud.com/936bea3e-d3df-435e-8b58-d817283284ae/lab", "user": { "domain": { "id": "878991804cdc4ba597xxxxxxxxxx9dd9", "name": "hwstaff_test" }, "id": "99250e439b33431081xxxxxxxxxxa885", "name": "test" }, "user_id": "99250e439b33431081xxxxxxxxxxa885", "volume": { "category": "efs", "ownership": "managed", "mount_path": "/home/ma-user/work/", "capacity": 50, "read_only": false }, "workspace_id": "0", "billing_items": [] }
- 消息请求体:
- 当notebook实例不再需要时,调用接口删除实例。
- 请求消息体:
uri格式:delete https://{ma_endpoint}/v1/{project_id}/notebooks/{id}
请求消息头:
- x-auth-token →miizmgyjkozihvcnaqccoiizizccgyccaqexdtalbglghkgbzqmeagewgxxxxxx...
- content-type →application/json
其中,加粗的斜体字段需要根据实际值填写。
- 返回状态码“200”表示实例删除成功。
- 请求消息体:
相关文档
意见反馈
文档内容是否对您有帮助?
如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨