MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

tpu/startVM.js:19–55  ·  view source on GitHub ↗
(tpuClient)

Source from the content-addressed store, hash-verified

17'use strict';
18
19async function main(tpuClient) {
20 // [START tpu_vm_start]
21 // Import the TPUClient
22 // TODO(developer): Uncomment below line before running the sample.
23 // const {TpuClient} = require('@google-cloud/tpu').v2;
24
25 // Instantiate a tpuClient
26 // TODO(developer): Uncomment below line before running the sample.
27 // tpuClient = new TpuClient();
28
29 // TODO(developer): Update these variables before running the sample.
30 // Project ID or project number of the Google Cloud project you want to start a node.
31 const projectId = await tpuClient.getProjectId();
32
33 // The name of TPU to start.
34 const nodeName = 'node-name-1';
35
36 // The zone, where the TPU is created.
37 const zone = 'europe-west4-a';
38
39 async function callStartTpuVM() {
40 const request = {
41 name: `projects/${projectId}/locations/${zone}/nodes/${nodeName}`,
42 };
43
44 const [operation] = await tpuClient.startNode(request);
45
46 // Wait for the operation to complete.
47 const [response] = await operation.promise();
48
49 console.log(`Node: ${nodeName} started.`);
50 return response;
51 }
52
53 return await callStartTpuVM();
54 // [END tpu_vm_start]
55}
56
57module.exports = main;
58

Callers

nothing calls this directly

Calls 2

callStartTpuVMFunction · 0.85
getProjectIdMethod · 0.80

Tested by

no test coverage detected