云服务器内容精选

  • 响应参数 表2 参数说明 参数 参数类型 描述 histories Array of objects 应用记录列表,具体参数请参考表3。 total_count Integer 总记录数。 表3 histories字段数据结构说明 参数 参数类型 描述 instance_id String 实例ID。 instance_name String 实例名称。 apply_result String 应用状态。 SUCCESS FAILED APPLYING applied_at String 应用时间,格式为“yyyy-mm-ddThh:mm:ssZ”。 其中,T指某个时间的开始;Z指时区偏移量,例如北京时间偏移显示为+0800。 error_code String 失败原因错误码,如DBS.280005。
  • 响应示例 查询参数模板的应用记录成功。 { "total_count": 2, "histories": [ { "instance_id": "1995a67680474481b3e42ac1474e32e0in14", "instance_name": "gauss-a283", "apply_result" : "SUCCESS", "applied_at" : "2022-08-09T03:06:52+0800", "error_code" : null }, { "instance_id": "8303819fd8744ef69f34595e9710a33din14", "instance_name": "gauss-2423-lt-master", "apply_result" : "FAILED", "applied_at" : "2022-08-09T03:06:52+0800", "error_code" : "DBS.280005" } ] }
  • URI GET https://{Endpoint}/v3/{project_id}/configurations/{config_id}/applied-histories 表1 参数说明 参数 是否必选 参数类型 描述 project_id 是 String 租户在某一Region下的项目ID。 获取方法请参见获取项目ID。 config_id 是 String 参数模板ID。 offset 否 Integer 索引位置,偏移量。从第一条数据偏移offset条数据后开始查询,默认为0(偏移0条数据,表示从第一条数据开始查询),必须为数字,不能为负数。例如:该参数指定为0,limit指定为10,则只展示第1-10条数据。 limit 否 Integer 查询记录数。默认为100,不能为负数,最小值为1,最大值为100。例如该参数设定为10,则查询结果最多只显示10条记录。
  • 响应消息 参数说明 表4 响应Body参数 名称 参数类型 描述 configuration ParamGroupInfoResult object 参数模板列表。 表5 configuration字段数据结构说明 名称 参数类型 说明 id String 参数模板ID。 name String 参数模板名称。 description String 参数模板描述。 datastore_version String 数据库版本。 datastore_name String 数据库类型。 created String 创建时间,格式为“yyyy-MM-ddTHH:mm:ssZ”。 其中,T指某个时间的开始;Z指时区偏移量,例如北京时间偏移显示为+0800。 updated String 更新时间,格式为“yyyy-MM-ddTHH:mm:ssZ”。 其中,T指某个时间的开始;Z指时区偏移量,例如北京时间偏移显示为+0800。 响应示例 { "configuration": { "id": "7b4e07852bd54016906e89461b3182cdpr02", "name": "myparameter", "description": "parameter1", "datastore_version": "3.4", "datastore_name": "mongodb", "created": "2018-09-19T02:54:21", "updated": "2018-09-19T02:54:21" } }
  • 请求示例 创建一个参数模板,名称为myparameter,node_type为shard,version为3.4,最大连接数为10 { "name" : "myparameter", "description" : "parameter1", "datastore" : { "node_type" : "shard", "version" : "3.4" }, "parameter_values" : { "max_connections" : "10" } }
  • 响应示例 成功响应示例 { "spec_code": "modelarts.vm.gpu.v100", "user_image_url": "100.125.5.235:20202/jobmng/custom-cpu-base:1.0", "user_command": "bash -x /home/work/run_train.sh python /home/work/user-job-dir/app/mnist/mnist_softmax.py --data_url /home/work/user-job-dir/app/mnist_data", "gpu_type": "nvidia-v100", "dataset_version_id": "2ff0d6ba-c480-45ae-be41-09a8369bfc90", "engine_name": "TensorFlow", "is_success": true, "nas_mount_path": "/home/work/nas", "worker_server_num": 1, "nas_share_addr": "192.168.8.150:/", "train_url": "/test/minst/train_out/out1/", "nas_type": "nfs", "spec_id": 4, "parameter": [ { "label": "learning_rate", "value": 0.01 } ], "log_url": "/usr/log/", "config_name": "config123", "app_url": "/usr/app/", "create_time": 1559045426000, "dataset_id": "38277e62-9e59-48f4-8d89-c8cf41622c24", "volumes": [ { "nfs": { "id": "43b37236-9afa-4855-8174-32254b9562e7", "src_path": "192.168.8.150:/", "dest_path": "/home/work/nas", "read_only": false } }, { "host_path": { "src_path": "/root/work", "dest_path": "/home/mind", "read_only": false } } ], "cpu": "64", "model_id": 4, "boot_file_url": "/usr/app/boot.py", "dataset_name": "dataset-test", "pool_id": "pool9928813f", "config_desc": "This is a config desc test", "gpu_num": 1, "data_source": [ { "type": "obs", "data_url": "/test/minst/data/" } ], "pool_name": "p100", "dataset_version_name": "dataset-version-test", "core": "8", "engine_type": 1, "engine_id": 3, "engine_version": "TF-1.8.0-python2.7", "data_url": "/test/minst/data/" } 失败响应示例 { "is_success": false, "error_message": "Error string", "error_code": "ModelArts.0105" }
  • 响应消息 响应参数如表3所示。 表3 响应参数 参数 参数类型 说明 is_success Boolean 请求是否成功。 error_message String 调用失败时的错误信息。 调用成功时无此字段。 error_code String 调用失败时的错误码,具体请参见错误码。调用成功时无此字段。 config_name String 训练作业参数的名称。 config_desc String 训练作业参数的描述信息。 worker_server_num Integer 训练作业worker的个数。 app_url String 训练作业的代码目录。 boot_file_url String 训练作业的代码启动文件。 model_id Long 训练作业的模型ID。 parameter JSON Array 训练作业的运行参数,为“label-value”格式;当为自定义镜像训练作业的时候,此参数为容器环境变量。详情请查看表8 spec_id Long 训练作业资源规格ID。 data_url String 训练作业的数据集。 dataset_id String 训练作业的数据集ID。 dataset_version_id String 训练作业的数据集版本ID。 data_source JSON Array 训练作业使用的多数据集。详情请查看表4。 engine_type Integer 训练作业的引擎类型。 engine_name String 训练作业的引擎名称。 engine_id Long 训练作业的引擎ID。 engine_version String 训练作业使用的引擎版本。 train_url String 训练作业的输出文件OBS路径URL,默认为空,如“/usr/train/”。 log_url String 训练作业的日志OBS输出路径URL,默认为空。如:“/usr/train/”。 user_image_url String 自定义镜像训练作业的自定义镜像的SWR-URL。 user_command String 自定义镜像训练作业的自定义镜像的容器的启动命令。 spec_code String 训练作业资源规格。 gpu_type String 资源规格gpu的类型。 create_time Long 训练作业参数创建时间 。 cpu String 资源规格CPU内存。 gpu_num Integer 资源规格gpu的个数。 core String 资源规格的核数。 dataset_name String 训练作业的数据集名称。 dataset_version_name String 训练作业的数据集名称。 pool_id String 资源池ID。 pool_name String 资源池名称。 volumes JSON Array 训练作业可使用的存储卷。具体请参见表5。 nas_mount_path String SFS Turbo (NAS) 训练本地挂载路径。如:“/home/work/nas”。 nas_share_addr String SFS Turbo (NAS) 共享路径。如:“192.168.8.150:/”。 nas_type String 当前仅支持 nfs。如:“nfs”。 表4 data_source属性列表 参数 参数类型 说明 dataset_id String 训练作业的数据集ID。 dataset_version String 训练作业的数据集版本ID。 type String 数据集类型。 “obs”:表示使用OBS的数据。 “dataset”:表示使用数据集的数据。 data_url String OBS的桶路径。
  • URI GET /v1/{project_id}/training-job-configs/{config_name} 参数说明如表1所示。 表1 路径参数 参数 是否必选 参数类型 说明 project_id 是 String 用户项目ID。获取方法请参见获取项目ID和名称。 config_name 是 String 训练作业参数的名称。 表2 Query参数 参数 是否必选 参数类型 说明 config_type 否 String 指定要查询的配置类型,可选值有以下两种 “custom”为查询用户自定义配置。 “sample”为查询示例配置,默认为“custom”。
  • 请求示例 如下以更新名为“config”的作业参数为例。 PUT https://endpoint/v1/{project_id}/training-job-configs/config { "config_desc": "This is config", "worker_server_num": 1, "app_url": "/usr/app/", "boot_file_url": "/usr/app/boot.py", "parameter": [ { "label": "learning_rate", "value": 0.01 }, { "label": "batch_size", "value": 32 } ], "spec_id": 1, "dataset_id": "38277e62-9e59-48f4-8d89-c8cf41622c24", "dataset_version_id": "2ff0d6ba-c480-45ae-be41-09a8369bfc90", "engine_id": 1, "train_url": "/usr/train/", "log_url": "/usr/log/", "model_id": 1 }
  • 参数说明 表1 Estimator请求参数说明 参数 是否必选 参数类型 描述 modelarts_session 是 Object 会话对象,初始化方法见Session鉴权。 train_instance_count 是 Long 训练作业worker的个数。 code_dir 否 String 训练作业的代码目录,如“/bucket/src/”。当填入model_name时不需要填写。 boot_file 否 String 训练作业的代码启动文件,需要在代码目录下,如“/bucket/src/boot.py”。当填入model_name时不需要填写。 model_name 否 Long 训练作业的内置算法模型名称。填入model_name后app_url与boot_file_url不需填写,framework_type和framework_version也不需要填写。 output_path 是 String 训练作业的输出位置。 hyperparameters 否 JSON Array 训练作业的运行参数,为label-value格式;当为自定义镜像训练作业的时候,此参数为容器环境变量。 log_url 否 String 训练作业的日志OBS输出路径URL,默认为空。如:“/usr/log/”。 train_instance_type 是 Long 训练作业选择的资源规格。若选择在训练平台训练,请从查询资源规格列表接口获取。 framework_type 否 String 训练作业选择的引擎规格。请从查询引擎规格列表接口获取引擎规格。当填入model_name时不需要填写。 framework_version 否 String 训练作业选择的引擎版本。请从查询引擎规格列表接口获取引擎版本。当填入model_name时不需要填写。 job_description 否 String 训练作业的描述。 user_image_url 否 String 自定义镜像训练作业的自定义镜像的SWR-URL。如:“100.125.5.235:20202/jobmng/custom-cpu-base:1.0”。 user_command 否 String 自定义镜像训练作业的自定义镜像的容器的启动命令。形式为:“bash /home/work/run_train.sh python /home/work/user-job-dir/app/train.py {python_file_parameter}”。 表2 update_job_configs请求参数说明 参数 是否必选 参数类型 描述 config_name 是 String 训练作业参数名称。限制为1-20位只含数字、字母、下划线或者中划线的名称。当不填写时,默认会按日期动态生成。 config_desc 否 String 对训练作业的描述,默认为空,字符串的长度限制为[0,256]。 inputs 否 String 训练作业的OBS数据存储位置。 dataset_id 否 String 训练作业的数据集ID。应与dataset_version_id同时出现,但不可与inputs同时出现。 dataset_version_id 否 String 训练作业的数据集版本ID。应与dataset_id同时出现,但不可与inputs同时出现。 data_source 否 JSON Array 训练作业使用的数据集。不可与inputs、dataset_id、dataset_version_id同时使用。 表3 data_source属性列表 参数 是否必选 参数类型 描述 dataset_id 否 String 训练作业的数据集ID。 dataset_version 否 String 训练作业的数据集版本ID。 type 是 String 数据集类型。可选值:“obs”、“dataset”。 data_url 否 String obs的桶路径,不可与dataset_id/dataset_version同时出现。 表4 update_job_configs返回参数说明 参数 参数类型 描述 error_msg String 调用失败时的错误信息。 调用成功时无此字段。 error_code String 调用失败时的错误码,具体请参见错误码。 调用成功时无此字段。 is_success Boolean 接口调用是否成功。
  • 示例代码 在ModelArts notebook平台,Session鉴权无需输入鉴权参数。其它平台的Session鉴权请参见Session鉴权。 示例一:使用OBS存储位置更新训练作业参数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 from modelarts.session import Session from modelarts.estimator import Estimator session = Session() estimator = Estimator( modelarts_session=session, framework_type='PyTorch', # AI引擎名称 framework_version='PyTorch-1.0.0-python3.6', # AI引擎版本 code_dir='/bucket/src/', # 训练脚本目录 boot_file='/bucket/src/pytorch_sentiment.py', # 训练启动脚本目录 log_url='/bucket/log/', # 训练日志目录 hyperparameters=[ {"label":"classes", "value": "10"}, {"label":"lr", "value": "0.001"} ], output_path='/bucket/output/', # 训练输出目录 train_instance_type='modelarts.vm.gpu.p100', # 训练环境规格 train_instance_count=1) # 训练节点个数 update_info = estimator.update_job_configs(config_name='my_job_config', inputs='/bucket/dataset/', config_desc='update') 示例二:使用数据集更新训练作业参数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 from modelarts.session import Session from modelarts.estimator import Estimator session = Session() estimator = Estimator( modelarts_session=session, framework_type='PyTorch', # AI引擎名称 framework_version='PyTorch-1.0.0-python3.6', # AI引擎版本 code_dir='/bucket/src/', # 训练脚本目录 boot_file='/bucket/src/pytorch_sentiment.py', # 训练启动脚本目录 log_url='/bucket/log/', # 训练日志目录 hyperparameters=[ {"label":"classes", "value": "10"}, {"label":"lr", "value": "0.001"} ], output_path='/bucket/output/', # 训练输出目录 train_instance_type='modelarts.vm.gpu.p100', # 训练环境规格 train_instance_count=1) # 训练节点个数 update_info = estimator.update_job_configs(config_name='my_job_config', dataset_id='4AZNvFkN7KYr5EdhFkH', dataset_version_id='UOF9BIeSGArwVt0oI6T', config_desc='update')
  • 响应消息 参数说明 表4 响应Body参数 参数 参数类型 说明 histories Array of 表5-5 objects 参数模板应用历史列表。 表5 ApplicableInstancesInfo 参数 参数类型 说明 instance_id String 实例ID。 instance_name String 实例名称。 applied_at String 应用时间,格式为"yyyy-MM-ddTHH:mm:ssZ"。其中,T指某个时间的开始;Z指时区偏移量,例如北京时间偏移显示为+0800。 apply_result String 应用结果。 SUCCESS:应用成功,FAILED:应用失败,APPLYING:应用中。 failure_reason String 失败原因。 响应示例 { "histories" : [ { "instance_id" : "1967d9d9d6ef4c5ea38bd5a754f5737ein02", "instance_name" : "dds-4525", "applied_at" : "2022-06-07T09:25:45+0000", "apply_result" : "SUCCESS" } ] }
  • URI URI格式 GET https://{Endpoint}/v3/{project_id}/configurations/{config_id}/applied-histories URI样例 https://dds.cn-north-1.myhuaweicloud.com/v3/056538411200d4cd2f79c003c7606412/configurations/7a8d539ba30f43adaf1b16d08b1df4bdpr02/applied-histories?offset=0&limit=10
  • 响应参数 状态码: 200 表2 响应Body参数 参数 参数类型 描述 configurations Object 集群参数配置列表。该对象中key值以具体获取为准,value拥有以下属性。 id: 参数配置ID。 key: 参数名称。 vlaue: 参数值。 defaultValue: 参数默认值。 regex: 参数约束限制。 desc: 参数中文描述。 type: 参数类型描述。 moduleDesc: 参数功能中文描述。 modifyEnable: 参数是否可修改 true: 可以修改。 false:不可修改。 enableValue: 参数支持修改的值。 fileName: 参数存在的文件名称。默认为elasticsearch.yml。 version: 版本信息。 descENG: 参数英文描述。 moduleDescENG: 参数功能英文描述。
  • 响应示例 状态码: 200 请求已成功。 { "configurations" : { "http.cors.allow-credentials" : { "id" : "b462d13c-294b-4e0f-91d3-58be2ad02b99", "key" : "http.cors.allow-credentials", "value" : "false", "defaultValue" : "false", "regex" : "^(true|false)$", "desc" : "跨域访问是否返回头部的Access-Control-Allow-Credentials,布尔类型,包括true和false", "type" : "Boolean", "moduleDesc" : "跨域访问", "modifyEnable" : "true", "enableValue" : "true,false", "fileName" : "elasticsearch.yml", "version" : null, "descENG" : "Whether to return the Access-Control-Allow-Credentials of the header during cross-domain access. The value is a Boolean value and the options are true and false.", "moduleDescENG" : "Cross-domain Access" } }}