( modelDisplayName, imageUri, artifactUri, project, location = 'us-central1' )
| 17 | 'use strict'; |
| 18 | |
| 19 | async function main( |
| 20 | modelDisplayName, |
| 21 | imageUri, |
| 22 | artifactUri, |
| 23 | project, |
| 24 | location = 'us-central1' |
| 25 | ) { |
| 26 | // [START aiplatform_upload_model_sample] |
| 27 | /** |
| 28 | * TODO(developer): Uncomment these variables before running the sample.\ |
| 29 | */ |
| 30 | |
| 31 | // const modelDisplayName = 'YOUR_MODEL_DISPLAY_NAME'; |
| 32 | // const metadataSchemaUri = 'YOUR_METADATA_SCHEMA_URI'; |
| 33 | // const imageUri = 'YOUR_IMAGE_URI'; |
| 34 | // const artifactUri = 'YOUR_ARTIFACT_URI'; |
| 35 | // const project = 'YOUR_PROJECT_ID'; |
| 36 | // const location = 'YOUR_PROJECT_LOCATION'; |
| 37 | |
| 38 | // Imports the Google Cloud Model Service Client library |
| 39 | const {ModelServiceClient} = require('@google-cloud/aiplatform'); |
| 40 | |
| 41 | // Specifies the location of the api endpoint |
| 42 | const clientOptions = { |
| 43 | apiEndpoint: 'us-central1-aiplatform.googleapis.com', |
| 44 | }; |
| 45 | |
| 46 | // Instantiates a client |
| 47 | const modelServiceClient = new ModelServiceClient(clientOptions); |
| 48 | |
| 49 | async function uploadModel() { |
| 50 | // Configure the parent resources |
| 51 | const parent = `projects/${project}/locations/${location}`; |
| 52 | // Configure the model resources |
| 53 | const model = { |
| 54 | displayName: modelDisplayName, |
| 55 | metadataSchemaUri: '', |
| 56 | artifactUri: artifactUri, |
| 57 | containerSpec: { |
| 58 | imageUri: imageUri, |
| 59 | command: [], |
| 60 | args: [], |
| 61 | env: [], |
| 62 | ports: [], |
| 63 | predictRoute: '', |
| 64 | healthRoute: '', |
| 65 | }, |
| 66 | }; |
| 67 | const request = { |
| 68 | parent, |
| 69 | model, |
| 70 | }; |
| 71 | |
| 72 | console.log('PARENT AND MODEL'); |
| 73 | console.log(parent, model); |
| 74 | // Upload Model request |
| 75 | const [response] = await modelServiceClient.uploadModel(request); |
| 76 | console.log(`Long running operation : ${response.name}`); |
no test coverage detected