Skip to content

Commit

Permalink
feat: updates enhanced client library veneer and samples (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
telpirion authored Feb 12, 2021
1 parent 66ff554 commit 4dc0382
Show file tree
Hide file tree
Showing 31 changed files with 60 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ async function main(
// const project = 'YOUR_PROJECT_ID';
// const location = 'YOUR_PROJECT_LOCATION';
const aiplatform = require('@google-cloud/aiplatform');
const {
params,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.predict;
const {params} = aiplatform.protos.google.cloud.aiplatform.v1.schema.predict;

// Imports the Google Cloud Job Service Client library
const {JobServiceClient} = require('@google-cloud/aiplatform');
const {JobServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ async function main(
// const project = 'YOUR_PROJECT_ID';
// const location = 'YOUR_PROJECT_LOCATION';
const aiplatform = require('@google-cloud/aiplatform');
const {
params,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.predict;
const {params} = aiplatform.protos.google.cloud.aiplatform.v1.schema.predict;

// Imports the Google Cloud Job Service Client library
const {JobServiceClient} = require('@google-cloud/aiplatform');
const {JobServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function main(

const {
definition,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.trainingjob;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob;
const ModelType = definition.AutoMlImageClassificationInputs.ModelType;

// Specifies the location of the api endpoint
Expand All @@ -49,9 +49,8 @@ function main(
};

// Instantiates a client
const pipelineServiceClient = new aiplatform.PipelineServiceClient(
clientOptions
);
const {PipelineServiceClient} = aiplatform.v1;
const pipelineServiceClient = new PipelineServiceClient(clientOptions);

async function createTrainingPipelineImageClassification() {
// Configure the parent resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ async function main(
const aiplatform = require('@google-cloud/aiplatform');
const {
definition,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.trainingjob;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob;
const ModelType = definition.AutoMlImageObjectDetectionInputs.ModelType;

// Imports the Google Cloud Pipeline Service Client library
const {PipelineServiceClient} = aiplatform;
const {PipelineServiceClient} = aiplatform.v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ async function main(
const aiplatform = require('@google-cloud/aiplatform');
const {
definition,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.trainingjob;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob;

// Imports the Google Cloud Pipeline Service Client library
const {PipelineServiceClient} = aiplatform;
const {PipelineServiceClient} = aiplatform.v1;
// Specifies the location of the api endpoint
const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ async function main(
const aiplatform = require('@google-cloud/aiplatform');
const {
definition,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.trainingjob;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob;

// Imports the Google Cloud Pipeline Service Client library
const {PipelineServiceClient} = aiplatform;
const {PipelineServiceClient} = aiplatform.v1;
// Specifies the location of the api endpoint
const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ async function main(
const aiplatform = require('@google-cloud/aiplatform');
const {
definition,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.trainingjob;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob;

// Imports the Google Cloud Pipeline Service Client library
const {PipelineServiceClient} = aiplatform;
const {PipelineServiceClient} = aiplatform.v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ async function main(
const aiplatform = require('@google-cloud/aiplatform');
const {
definition,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.trainingjob;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob;

// Imports the Google Cloud Pipeline Service Client library
const {PipelineServiceClient} = aiplatform;
const {PipelineServiceClient} = aiplatform.v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ async function main(
const aiplatform = require('@google-cloud/aiplatform');
const {
definition,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.trainingjob;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob;

// Imports the Google Cloud Pipeline Service Client library
const {PipelineServiceClient} = aiplatform;
const {PipelineServiceClient} = aiplatform.v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ async function main(
const aiplatform = require('@google-cloud/aiplatform');
const {
definition,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.trainingjob;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob;

// Imports the Google Cloud Pipeline Service Client library
const {PipelineServiceClient} = aiplatform;
const {PipelineServiceClient} = aiplatform.v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ async function main(
const aiplatform = require('@google-cloud/aiplatform');
const {
definition,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.trainingjob;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob;
const ModelType = definition.AutoMlVideoObjectTrackingInputs.ModelType;

// Imports the Google Cloud Pipeline Service Client library
const {PipelineServiceClient} = aiplatform;
const {PipelineServiceClient} = aiplatform.v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ async function main(modelId, evaluationId, project, location = 'us-central1') {

const modelExplanation = response.modelExplanation;
console.log('\tModel explanation');
if (modelExplanation === null) {
if (!modelExplanation) {
console.log('\t\t{}');
} else {
const meanAttributions = modelExplanation.meanAttributions;
if (meanAttributions === null) {
if (!meanAttributions) {
console.log('\t\t\t []');
} else {
for (const meanAttribution of meanAttributions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ async function main(modelId, evaluationId, project, location = 'us-central1') {

const modelExplanation = response.modelExplanation;
console.log('\tModel explanation');
if (modelExplanation === null) {
if (!modelExplanation) {
console.log('\t\t{}');
} else {
const meanAttributions = modelExplanation.meanAttributions;
if (meanAttributions === null) {
if (!meanAttributions) {
console.log('\t\t\t []');
} else {
for (const meanAttribution of meanAttributions) {
Expand Down
4 changes: 2 additions & 2 deletions ai-platform/snippets/predict-image-classification.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ function main(filename, endpointId, project, location = 'us-central1') {
instance,
params,
prediction,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.predict;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.predict;

// Imports the Google Cloud Prediction Service Client library
const {PredictionServiceClient} = aiplatform;
const {PredictionServiceClient} = aiplatform.v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
4 changes: 2 additions & 2 deletions ai-platform/snippets/predict-image-object-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ async function main(filename, endpointId, project, location = 'us-central1') {
instance,
params,
prediction,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.predict;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.predict;

// Imports the Google Cloud Prediction Service Client library
const {PredictionServiceClient} = aiplatform;
const {PredictionServiceClient} = aiplatform.v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
9 changes: 6 additions & 3 deletions ai-platform/snippets/predict-tabular-classification.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ async function main(endpointId, project, location = 'us-central1') {
const aiplatform = require('@google-cloud/aiplatform');
const {
prediction,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.predict;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.predict;

// Imports the Google Cloud Prediction Service Client library
const {PredictionServiceClient, helpers} = aiplatform;
// Imports the Google Cloud Prediction service client
const {PredictionServiceClient} = aiplatform.v1;

// Import the helper module for converting arbitrary protobuf.Value objects.
const {helpers} = aiplatform;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
9 changes: 6 additions & 3 deletions ai-platform/snippets/predict-tabular-regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ async function main(endpointId, project, location = 'us-central1') {
const aiplatform = require('@google-cloud/aiplatform');
const {
prediction,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.predict;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.predict;

// Imports the Google Cloud Prediction Service Client library
const {PredictionServiceClient, helpers} = aiplatform;
// Imports the Google Cloud Prediction service client
const {PredictionServiceClient} = aiplatform.v1;

// Import the helper module for converting arbitrary protobuf.Value objects.
const {helpers} = aiplatform;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
4 changes: 2 additions & 2 deletions ai-platform/snippets/predict-text-classification.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ async function main(text, endpointId, project, location) {
const {
instance,
prediction,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.predict;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.predict;

// Imports the Google Cloud Model Service Client library
const {PredictionServiceClient} = aiplatform;
const {PredictionServiceClient} = aiplatform.v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
4 changes: 2 additions & 2 deletions ai-platform/snippets/predict-text-entity-extraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ async function main(text, endpointId, project, location = 'us-central1') {
const {
instance,
prediction,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.predict;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.predict;

// Imports the Google Cloud Model Service Client library
const {PredictionServiceClient} = aiplatform;
const {PredictionServiceClient} = aiplatform.v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
4 changes: 2 additions & 2 deletions ai-platform/snippets/predict-text-sentiment-analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ async function main(text, endpointId, project, location = 'us-central1') {
const {
instance,
prediction,
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.predict;
} = aiplatform.protos.google.cloud.aiplatform.v1.schema.predict;

// Imports the Google Cloud Model Service Client library
const {PredictionServiceClient} = aiplatform;
const {PredictionServiceClient} = aiplatform.v1;

// Specifies the location of the api endpoint
const clientOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

const jobServiceClient = new aiplatform.JobServiceClient(clientOptions);
const jobServiceClient = new aiplatform.v1.JobServiceClient(clientOptions);

const batchPredictionDisplayName = `temp_create_batch_prediction_video_classification_test${uuid()}`;
const modelId = '8596984660557299712';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

const jobServiceClient = new aiplatform.JobServiceClient(clientOptions);
const jobServiceClient = new aiplatform.v1.JobServiceClient(clientOptions);

const batchPredictionDisplayName = `temp_create_batch_prediction_video_object_tracking_test${uuid()}`;
const modelId = '8609932509485989888';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

const pipelineServiceClient = new aiplatform.PipelineServiceClient(
const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient(
clientOptions
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

const pipelineServiceClient = new aiplatform.PipelineServiceClient(
const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient(
clientOptions
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

const pipelineServiceClient = new aiplatform.PipelineServiceClient(
const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient(
clientOptions
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

const pipelineServiceClient = new aiplatform.PipelineServiceClient(
const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient(
clientOptions
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

const pipelineServiceClient = new aiplatform.PipelineServiceClient(
const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient(
clientOptions
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

const pipelineServiceClient = new aiplatform.PipelineServiceClient(
const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient(
clientOptions
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

const pipelineServiceClient = new aiplatform.PipelineServiceClient(
const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient(
clientOptions
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

const pipelineServiceClient = new aiplatform.PipelineServiceClient(
const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient(
clientOptions
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const clientOptions = {
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

const pipelineServiceClient = new aiplatform.PipelineServiceClient(
const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient(
clientOptions
);

Expand Down

0 comments on commit 4dc0382

Please sign in to comment.