我正在尝试以编程方式在GCP中创建“ AI平台笔记本”。 gcloud sdk确实支持管理这些笔记本,但没有创建它们。而且没有支持Node.js(我正在使用的语言)的客户端库。但是,here中所述的GCP REST API支持创建笔记本。但是,我正在努力找出如何在请求的JSON中指定我想要的笔记本。在GCP网络用户界面中,我想要的设置是:
但是我正在努力将其转换为针对REST API的JSON请求。以下是我到目前为止的内容。我不确定其中的任何一个是正确的,而且我肯定缺少环境(tensorflow 2.1)和仅单用户访问权限。除了随机尝试不同的请求直到可行为止,我不知道如何实现这一目标。 (我留下了一些JSON,只是现在按照文档指定类型,以供参考)。
POST https://notebooks.googleapis.com/v1beta1/projects/my-project/locations/europe-west2/instances
{
"name" : "testing-instance",
"instanceOwners": [
string
],
"serviceAccount": "team@project.iam.gserviceaccount.com",
"machineType": "e2-highmem-2 (Efficient Instance, 2 vCPUs, 16 GB RAM)",
"acceleratorConfig": {
object (AcceleratorConfig)
},
"state": enum (State),
"installGpuDriver": boolean,
"customGpuDriverPath": string,
"bootDiskType": enum (DiskType),
"bootDiskSizeGb": string,
"dataDiskType": enum (DiskType),
"dataDiskSizeGb": string,
"noRemoveDataDisk": boolean,
"diskEncryption": enum (DiskEncryption),
"kmsKey": string,
"noPublicIp": boolean,
"noProxyAccess": boolean,
"network": string,
"subnet": string,
"labels": {
string: string,
...
},
"metadata": {
string: string,
...
},
"createTime": string,
"updateTime": string,
// Union field environment can be only one of the following:
"vmImage": {
object (VmImage)
},
"containerImage": {
object (ContainerImage)
}
// End of list of possible types for union field environment.
}
答案 0 :(得分:2)
此处是必需的JSON
{
"name": "testing-instance",
"machineType": "zones/europe-west2-a/machineTypes/e2-highmem-2",
"guestAccelerators": [],
"metadata": {
"items": [
{
"key": "proxy-mode",
"value": "mail"
},
{
"key": "framework",
"value": "TensorFlow:2.1"
},
{
"key": "proxy-user-mail",
"value": "firstname.surname@email.com"
}
]
},
"disks": [
{
"boot": true,
"autoDelete": true,
"initializeParams": {
"diskType": "zones/europe-west2-a/diskTypes/pd-standard",
"diskSizeGb": "100",
"sourceImage": "projects/deeplearning-platform-release/global/images/family/tf2-2-1-cu101-notebooks-debian-9"
}
}
],
"scheduling": {
"onHostMaintenance": "MIGRATE"
},
"networkInterfaces": [
{
"subnetwork": "https://www.googleapis.com/compute/v1/projects/gbl-imt-homerider-basguillaueb/regions/europe-west2/subnetworks/datalab-network",
"accessConfigs": [
{
"name": "external-nat",
"type": "ONE_TO_ONE_NAT"
}
]
}
],
"serviceAccounts": [
{
"email": "team@project.iam.gserviceaccount.com",
"scopes": [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/userinfo.email"
]
}
],
"tags": {
"items": [
"deeplearning-vm"
]
}
}
无法自行猜测。我怎样做?使用控制台进行操作,然后在提交之前打开Chorme调试器并捕获网络请求。发布请求包含此JSON!
享受