From 32593375f75f0209e78c5e04f40acd5da00e67bb Mon Sep 17 00:00:00 2001 From: Chris Frater Date: Thu, 16 Aug 2018 16:12:55 -0700 Subject: [PATCH 01/10] initial translation commit --- .../automl/AutoML Translation Tutorial.docx | Bin 0 -> 22371 bytes samples/automl/automlTranslationDataset.js | 362 +++++++++++++ samples/automl/automlTranslationModel.js | 481 ++++++++++++++++++ samples/automl/automlTranslationPredict.js | 142 ++++++ samples/automl/resources/testInput.txt | 1 + samples/package.json | 2 + samples/system-test/automlTranslation.test.js | 147 ++++++ 7 files changed, 1135 insertions(+) create mode 100755 samples/automl/AutoML Translation Tutorial.docx create mode 100755 samples/automl/automlTranslationDataset.js create mode 100755 samples/automl/automlTranslationModel.js create mode 100755 samples/automl/automlTranslationPredict.js create mode 100644 samples/automl/resources/testInput.txt create mode 100644 samples/system-test/automlTranslation.test.js diff --git a/samples/automl/AutoML Translation Tutorial.docx b/samples/automl/AutoML Translation Tutorial.docx new file mode 100755 index 0000000000000000000000000000000000000000..6a0ea603d857b3e9b23bc9ed82dd0c8ed6ce7981 GIT binary patch literal 22371 zcma&M1yo$ywyll3y99T4cXux=xCeI#?(XjHg}b}E6C4s;6Wqxod+&4Jx%dA6ZLfN@ zViv4LE17eSzP>(`<-j2@Kww~CK<=H+Qc!fQ7ED+I3ehl5bKUuQD!7wU+GtRN~8gT&G^51i|M|D%2;x?}42@U(qFcrGw^aXp|`sjfr_A zZ0|)%nkE8TqndAMOhD!FvUy9%yjSAMpuIe$F11*cig>y2lJ?7Z+GbZci3n@Uu1_xFv<6O zwtmK|H1igDnI&&&GKKUu4D7T8rvXl7meWhBTqpJj zK~t>sxVSNS-<150`aOAkb*D$q))r0b?iZXmb2Z0nB$xD&cixxTo}rcHpkaPicZ`67 zfq-;Cfq*Fg|4tvYe@!1dS6gEb}aFBN&1mB3)&*)m&LCEyx{vkx*d_#i_ZrfVliPA>Up? zbwpqTO9TQIMFC3;7)>?;8-Gegv;py}j9d^NCn7*xEI1*1&93r52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}oE?i4gu0c0Q%Q<@w-xv4m_LJ5V` znupuJpqtN^i%fuQE|;!Qw8a{lcTDz|uTXfp0HQMLXAQOCZ2~NG!kQRPXBC!+-j zL*yA1k?~>DtGg(o)fnynD>vk*a-%PUB3hyND@K~mwr2K*rx=zZ1X$%vm(CiE~0;f%Z&U53+224 z#iCYE)B2swYUhLreQ-ScyOQ6wPWY5 zN3YYy0fxCF)@}099H1a@VYwYm+dg)qEdnGz`<_YKkj6(Oy=pdci6vATQK{C;>pLr?3>1GIPn%NL!GXoer&V7)d6Vmz9(=H7I_0SROE zxkiEA6zWaDf^3mG`gp>1q_Q;Bn5<(%!k232_lRc8Y { + const dataset = responses[0]; + + // Display the dataset information + console.log('Dataset name:', dataset.name); + console.log('Dataset id: ', dataset.name.split('/').pop(-1)); + console.log('Dataset display name: ', dataset.displayName); + console.log('Dataset example count: ', dataset.exampleCount); + console.log('Translation dataset specification:'); + console.log( + '\tSource language code: ', + dataset.translationDatasetMetadata.sourceLanguageCode + ); + console.log( + '\tTarget language code: ', + dataset.translationDatasetMetadata.targetLanguageCode + ); + console.log('Dataset create time:'); + console.log('\tseconds: ', dataset.createTime.seconds); + console.log('\tnanos: ', dataset.createTime.nanos); + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_createDataset] +} + +function listDatasets(projectId, computeRegion, filter_) { + // [START automl_translation_listDatasets] + const automl = require('@google-cloud/automl'); + + const client = new automl.v1beta1.AutoMlClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; + // const computeRegion = `region-name, e.g. "us-central1"`; + // const filter_ = `filter expressions, must specify field e.g. “imageClassificationModelMetadata:*”`; + + // A resource that represents Google Cloud Platform location. + const projectLocation = client.locationPath(projectId, computeRegion); + + // List all the datasets available in the region by applying filter. + client + .listDatasets({parent: projectLocation, filter: filter_}) + .then(responses => { + const dataset = responses[0]; + + // Display the dataset information. + console.log('List of datasets:'); + for (let i = 0; i < dataset.length; i += 1) { + console.log('Dataset name:', dataset[i].name); + console.log('Dataset id: ', dataset[i].name.split('/').pop(-1)); + console.log('Dataset display name: ', dataset[i].displayName); + console.log('Dataset example count: ', dataset[i].exampleCount); + console.log('Translation dataset specification:'); + console.log( + '\tSource language code: ', + dataset[i].translationDatasetMetadata.sourceLanguageCode + ); + console.log( + '\tTarget language code: ', + dataset[i].translationDatasetMetadata.targetLanguageCode + ); + console.log('Dataset create time:'); + console.log('\tseconds: ', dataset[i].createTime.seconds); + console.log('\tnanos: ', dataset[i].createTime.nanos); + } + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_listDatasets] +} + +function getDataset(projectId, computeRegion, datasetId) { + // [START automl_translation_getDataset] + const automl = require('@google-cloud/automl'); + + const client = new automl.v1beta1.AutoMlClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; + // const computeRegion = `region-name, e.g. "us-central1"`; + // const datasetId = `Id of the dataset`; + + // Get the full path of the dataset. + const datasetFullId = client.datasetPath(projectId, computeRegion, datasetId); + + // Get complete detail of the dataset. + client + .getDataset({name: datasetFullId}) + .then(responses => { + const dataset = responses[0]; + + // Display the dataset information. + console.log('Dataset name:', dataset.name); + console.log('Dataset id: ', dataset.name.split('/').pop(-1)); + console.log('Dataset display name: ', dataset.displayName); + console.log('Dataset example count: ', dataset.exampleCount); + console.log('Translation dataset specification:'); + console.log( + '\tSource language code: ', + dataset.translationDatasetMetadata.sourceLanguageCode + ); + console.log( + '\tTarget language code: ', + dataset.translationDatasetMetadata.targetLanguageCode + ); + console.log('Dataset create time:'); + console.log('\tseconds: ', dataset.createTime.seconds); + console.log('\tnanos: ', dataset.createTime.nanos); + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_getDataset] +} + +function importData(projectId, computeRegion, datasetId, path) { + // [START automl_translation_importData] + const automl = require('@google-cloud/automl'); + + const client = new automl.v1beta1.AutoMlClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; + // const computeRegion = `region-name, e.g. "us-central1"`; + // const datasetId = `Id of the dataset`; + // const path = `string or array of .csv paths in AutoML Vision CSV format, e.g. “gs://myproject/mytraindata.csv”;` + + // Get the full path of the dataset. + const datasetFullId = client.datasetPath(projectId, computeRegion, datasetId); + + // Get the multiple Google Cloud Storage URIs. + const inputUris = path.split(','); + const inputConfig = { + gcsSource: { + inputUris: inputUris, + }, + }; + + // Import data from the input URI. + client + .importData({name: datasetFullId, inputConfig: inputConfig}) + .then(responses => { + const operation = responses[0]; + console.log('Processing import...'); + return operation.promise(); + }) + .then(responses => { + // The final result of the operation. + if (responses[2].done === true) console.log(`Data imported.`); + console.log('Dataset imported.'); + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_importData] +} + +function deleteDataset(projectId, computeRegion, datasetId) { + // [START automl_translation_deleteDataset] + const automl = require('@google-cloud/automl'); + + const client = new automl.v1beta1.AutoMlClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; + // const computeRegion = `region-name, e.g. "us-central1"`; + // const datasetId = `Id of the dataset`; + + // Get the full path of the dataset. + const datasetFullId = client.datasetPath(projectId, computeRegion, datasetId); + + // Delete a dataset. + client + .deleteDataset({name: datasetFullId}) + .then(responses => { + const operation = responses[0]; + return operation.promise(); + }) + .then(responses => { + // The final result of the operation. + if (responses[2].done === true) console.log('Dataset deleted.'); + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_deleteDataset] +} + +require(`yargs`) + .demand(1) + .options({ + computeRegion: { + alias: `c`, + type: `string`, + default: process.env.REGION_NAME, + requiresArg: true, + description: `region name e.g. "us-central1"`, + }, + datasetName: { + alias: `n`, + type: `string`, + default: `testDataSet`, + requiresArg: true, + description: `Name of the Dataset`, + }, + datasetId: { + alias: `i`, + type: `string`, + requiresArg: true, + description: `Id of the dataset`, + }, + filter_: { + alias: `f`, + default: `translationDatasetMetadata:*`, + type: `string`, + requiresArg: true, + description: `Name of the Dataset to search for`, + }, + multilabel: { + alias: `m`, + type: `string`, + default: false, + requiresArg: true, + description: + `Type of the classification problem, ` + + `False - MULTICLASS, True - MULTILABEL.`, + }, + outputUri: { + alias: `o`, + type: `string`, + requiresArg: true, + description: `URI (or local path) to export dataset`, + }, + path: { + alias: `p`, + type: `string`, + global: true, + default: `gs://nodejs-docs-samples-vcm/en-ja.csv`, + requiresArg: true, + description: `URI or local path to input .csv, or array of .csv paths`, + }, + projectId: { + alias: `z`, + type: `number`, + default: process.env.GCLOUD_PROJECT, + requiresArg: true, + description: `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`, + }, + source: { + alias: `s`, + type: `string`, + requiresArg: true, + description: `The source language to be translated from`, + }, + target: { + alias: `t`, + type: `string`, + requiresArg: true, + description: `The target language to be translated to`, + }, + }) + .command(`createDataset`, `creates a new Dataset`, {}, opts => + createDataset( + opts.projectId, + opts.computeRegion, + opts.datasetName, + opts.source, + opts.target + ) + ) + .command(`listDatasets`, `list all Datasets`, {}, opts => + listDatasets(opts.projectId, opts.computeRegion, opts.filter_) + ) + .command(`getDataset`, `Get a Dataset`, {}, opts => + getDataset(opts.projectId, opts.computeRegion, opts.datasetId) + ) + .command(`deleteDataset`, `Delete a dataset`, {}, opts => + deleteDataset(opts.projectId, opts.computeRegion, opts.datasetId) + ) + .command(`importData`, `Import labeled items into dataset`, {}, opts => + importData(opts.projectId, opts.computeRegion, opts.datasetId, opts.path) + ) + .example(`node $0 createDataset -n "newDataSet" -s "en" -t "ja"`) + .example(`node $0 listDatasets -f "translationDatasetMetadata:*"`) + .example(`node $0 getDataset -i "DATASETID"`) + .example(`node $0 deleteDataset -i "DATASETID"`) + .example( + `node $0 importData -i "dataSetId" -p "gs://myproject/mytraindata.csv"` + ) + .wrap(120) + .recommendCommands() + .help() + .strict().argv; diff --git a/samples/automl/automlTranslationModel.js b/samples/automl/automlTranslationModel.js new file mode 100755 index 00000000..9c4d3fde --- /dev/null +++ b/samples/automl/automlTranslationModel.js @@ -0,0 +1,481 @@ +/** + * Copyright 2018, Google, LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This application demonstrates how to perform basic operations on model + * with the Google AutoML Translation API. + * + * For more information, see the documentation at + * https://cloud.google.com/translate/automl/docs + */ + +'use strict'; + +function createModel(projectId, computeRegion, datasetId, modelName) { + // [START automl_translation_createModel] + const automl = require('@google-cloud/automl'); + + const client = new automl.v1beta1.AutoMlClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; + // const computeRegion = `region-name, e.g. "us-central1"`; + // const datasetId = `Id of the dataset`; + // const modelName = `Name of the model, e.g. "myModel"`; + + // A resource that represents Google Cloud Platform location. + const projectLocation = client.locationPath(projectId, computeRegion); + + // Set model name and dataset. + const myModel = { + displayName: modelName, + datasetId: datasetId, + translationModelMetadata: {}, + }; + + // Create a model with the model metadata in the region. + client + .createModel({parent: projectLocation, model: myModel}) + .then(responses => { + const operation = responses[0]; + const initialApiResponse = responses[1]; + + console.log('Training operation name: ', initialApiResponse.name); + console.log('Training started...'); + return operation.promise(); + }) + .then(responses => { + // The final result of the operation. + const model = responses[0]; + console.log(model); + // Retrieve deployment state. + var deploymentState = ''; + if (model.deploymentState === 1) { + deploymentState = 'deployed'; + } else if (model.deploymentState === 2) { + deploymentState = 'undeployed'; + } + + // Display the model information. + console.log('Model name: ', model.name); + console.log('Model id: ', model.name.split('/').pop(-1)); + console.log('Model display name: ', model.displayName); + console.log('Model create time:'); + console.log('\tseconds: ', model.createTime.seconds); + console.log('\tnanos: ', model.createTime.nanos); + console.log('Model deployment state: ', deploymentState); + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_createModel] +} + +function listModels(projectId, computeRegion, filter_) { + // [START automl_translation_listModels] + const automl = require('@google-cloud/automl'); + + const client = new automl.v1beta1.AutoMlClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; + // const computeRegion = `region-name, e.g. "us-central1"`; + // const filter_ = `filter expressions, must specify field, e.g. "translationDatasetMetadata:*”`; + + // A resource that represents Google Cloud Platform location. + const projectLocation = client.locationPath(projectId, computeRegion); + + // List all the models available in the region by applying filter. + client + .listModels({parent: projectLocation, filter: filter_}) + .then(responses => { + const model = responses[0]; + + // Display the model information. + console.log('List of models:'); + for (let i = 0; i < model.length; i += 1) { + console.log('Model name: ', model[i].name); + console.log('Model id: ', model[i].name.split('/').pop(-1)); + console.log('Model display name: ', model[i].displayName); + console.log('Model dataset id: ', model[i].datasetId); + if (model[i].modelMetadata === 'translationModelMetadata') { + console.log('Translation model metadata:'); + console.log( + '\tBase model: ', + model[i].translationModelMetadata.baseModel + ); + console.log( + '\tSource language code: ', + model[i].translationModelMetadata.sourceLanguageCode + ); + console.log( + '\tTarget language code: ', + model[i].translationModelMetadata.targetLanguageCode + ); + } else if ( + model[i].modelMetadata === 'textClassificationModelMetadata' + ) { + console.log( + 'Text classification model metadata: ', + model[i].textClassificationModelMetadata + ); + } else if ( + model[i].modelMetadata === 'imageClassificationModelMetadata' + ) { + console.log('Image classification model metadata:'); + console.log( + '\tBase model id: ', + model[i].imageClassificationModelMetadata.baseModelId + ); + console.log( + '\tTrain budget: ', + model[i].imageClassificationModelMetadata.trainBudget + ); + console.log( + '\tTrain cost: ', + model[i].imageClassificationModelMetadata.trainCost + ); + console.log( + '\tStop reason: ', + model[i].imageClassificationModelMetadata.stopReason + ); + } + console.log('Model create time:'); + console.log('\tseconds: ', model[i].createTime.seconds); + console.log('\tnanos: ', model[i].createTime.nanos); + console.log('Model update time:'); + console.log('\tseconds: ', model[i].updateTime.seconds); + console.log('\tnanos: ', model[i].updateTime.nanos); + console.log('Model deployment state: ', model[i].deploymentState); + console.log('\n'); + } + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_listModels] +} + +function getModel(projectId, computeRegion, modelId) { + // [START automl_translation_getModel] + const automl = require('@google-cloud/automl'); + + const client = new automl.v1beta1.AutoMlClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; + // const computeRegion = `region-name, e.g. "us-central1"`; + // const modelId = `id of the model, e.g. “ICN12345”`; + + // Get the full path of the model. + const modelFullId = client.modelPath(projectId, computeRegion, modelId); + + // Get complete detail of the model. + client + .getModel({name: modelFullId}) + .then(responses => { + const model = responses[0]; + + // Display the model information. + console.log('Model name: ', model.name); + console.log('Model id: ', model.name.split('/').pop(-1)); + console.log('Model display name: ', model.displayName); + console.log('Model dataset id: ', model.datasetId); + if (model.modelMetadata === 'translationModelMetadata') { + console.log('Translation model metadata:'); + console.log('\tBase model: ', model.translationModelMetadata.baseModel); + console.log( + '\tSource language code: ', + model.translationModelMetadata.sourceLanguageCode + ); + console.log( + '\tTarget language code: ', + model.translationModelMetadata.targetLanguageCode + ); + } else if (model.modelMetadata === 'textClassificationModelMetadata') { + console.log( + 'Text classification model metadata: ', + model.textClassificationModelMetadata + ); + } else if (model.modelMetadata === 'imageClassificationModelMetadata') { + console.log('Image classification model metadata:'); + console.log( + '\tBase model id: ', + model.imageClassificationModelMetadata.baseModelId + ); + console.log( + '\tTrain budget: ', + model.imageClassificationModelMetadata.trainBudget + ); + console.log( + '\tTrain cost: ', + model.imageClassificationModelMetadata.trainCost + ); + console.log( + '\tStop reason: ', + model.imageClassificationModelMetadata.stopReason + ); + } + console.log('Model create time:'); + console.log('\tseconds: ', model.createTime.seconds); + console.log('\tnanos: ', model.createTime.nanos); + console.log('Model update time:'); + console.log('\tseconds: ', model.updateTime.seconds); + console.log('\tnanos: ', model.updateTime.nanos); + console.log('Model deployment state: ', model.deploymentState); + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_getModel] +} + +function listModelEvaluations(projectId, computeRegion, modelId, filter_) { + // [START automl_translation_listModelEvaluations] + const automl = require('@google-cloud/automl'); + + const client = new automl.v1beta1.AutoMlClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; + // const computeRegion = `region-name, e.g. "us-central1"`; + // const modelId = `id of the model, e.g. “ICN12345”`; + // const filter_ = `filter expressions, must specify field, e.g. “imageClassificationModelMetadata:*”`; + + // Get the full path of the model. + const modelFullId = client.modelPath(projectId, computeRegion, modelId); + + // List all the model evaluations in the model by applying filter. + client + .listModelEvaluations({parent: modelFullId, filter: filter_}) + .then(responses => { + const element = responses[0]; + console.log('List of model evaluations:'); + for (let i = 0; i < element.length; i += 1) { + console.log(element[i]); + } + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_listModelEvaluations] +} + +function getModelEvaluation( + projectId, + computeRegion, + modelId, + modelEvaluationId +) { + // [START automl_translation_getModelEvaluation] + const automl = require('@google-cloud/automl'); + + const client = new automl.v1beta1.AutoMlClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; + // const computeRegion = `region-name, e.g. "us-central1"`; + // const modelId = `id of the model, e.g. “ICN12345”`; + // const modelEvaluationId = `Id of your model evaluation, e.g “ICN12345” + + // Get the full path of the model evaluation. + const modelEvaluationFullId = client.modelEvaluationPath( + projectId, + computeRegion, + modelId, + modelEvaluationId + ); + + // Get complete detail of the model evaluation. + client + .getModelEvaluation({name: modelEvaluationFullId}) + .then(responses => { + const response = responses[0]; + console.log(response); + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_getModelEvaluation] +} + +function deleteModel(projectId, computeRegion, modelId) { + // [START automl_translation_deleteModel] + const automl = require('@google-cloud/automl'); + + const client = new automl.v1beta1.AutoMlClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; + // const computeRegion = `region-name, e.g. "us-central1"`; + // const modelId = `id of the model, e.g. “ICN12345”`; + + // Get the full path of the model. + const modelFullId = client.modelPath(projectId, computeRegion, modelId); + + // Delete a model. + client + .deleteModel({name: modelFullId}) + .then(responses => { + const operation = responses[0]; + return operation.promise(); + }) + .then(responses => { + // The final result of the operation. + if (responses[2].done === true) console.log(`Model deleted.`); + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_deleteModel] +} + +function getOperationStatus(operationFullId) { + // [START automl_translation_getOperationStatus] + const automl = require('@google-cloud/automl'); + + const client = new automl.v1beta1.AutoMlClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const operationFullId = `Full name of an operation, eg. “Projects//locations/us-central1/operations/ + + // Get the latest state of a long-running operation. + client.operationsClient.getOperation(operationFullId).then(responses => { + const response = responses[0]; + console.log('Operation status: ', response); + }); + // [END automl_translation_getOperationStatus] +} + +require(`yargs`) + .demand(1) + .options({ + computeRegion: { + alias: `c`, + type: `string`, + default: process.env.REGION_NAME, + requiresArg: true, + description: `region name e.g. "us-central1"`, + }, + datasetId: { + alias: `i`, + type: `string`, + requiresArg: true, + description: `Id of the dataset`, + }, + filter_: { + alias: `f`, + default: ``, + type: `string`, + requiresArg: true, + description: `Name of the Dataset to search for`, + }, + modelName: { + alias: `m`, + type: `string`, + default: false, + requiresArg: true, + description: `Name of the model`, + }, + modelId: { + alias: `a`, + type: `string`, + default: ``, + requiresArg: true, + description: `Id of the model`, + }, + modelEvaluationId: { + alias: `e`, + type: `string`, + default: ``, + requiresArg: true, + description: `Id of the model evaluation`, + }, + operationFullId: { + alias: `o`, + type: `string`, + default: ``, + requiresArg: true, + description: `Full name of an operation`, + }, + projectId: { + alias: `z`, + type: `number`, + default: process.env.GCLOUD_PROJECT, + requiresArg: true, + description: `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`, + }, + }) + .command(`createModel`, `creates a new Model`, {}, opts => + createModel( + opts.projectId, + opts.computeRegion, + opts.datasetId, + opts.modelName + ) + ) + .command(`getOperationStatus`, `Gets status of current operation`, {}, opts => + getOperationStatus(opts.operationFullId) + ) + .command(`listModels`, `list all Models`, {}, opts => + listModels(opts.projectId, opts.computeRegion, opts.filter_) + ) + .command(`getModel`, `Get a Model`, {}, opts => + getModel(opts.projectId, opts.computeRegion, opts.modelId) + ) + .command(`listModelEvaluations`, `List model evaluations`, {}, opts => + listModelEvaluations( + opts.projectId, + opts.computeRegion, + opts.modelId, + opts.filter_ + ) + ) + .command(`getModelEvaluation`, `Get model evaluation`, {}, opts => + getModelEvaluation( + opts.projectId, + opts.computeRegion, + opts.modelId, + opts.modelEvaluationId + ) + ) + .command(`deleteModel`, `Delete a Model`, {}, opts => + deleteModel(opts.projectId, opts.computeRegion, opts.modelId) + ) + .example(`node $0 createModel -i "DatasetID" -m "myModelName"`) + .example(`node $0 getOperationStatus -i "datasetId" -o "OperationFullID"`) + .example(`node $0 listModels -f "translationModelMetadata:*"`) + .example(`node $0 getModel -a "ModelID"`) + .example(`node $0 listModelEvaluations -a "ModelID"`) + .example(`node $0 getModelEvaluation -a "ModelId" -e "ModelEvaluationID"`) + .example(`node $0 deleteModel -a "ModelID"`) + .wrap(120) + .recommendCommands() + .help() + .strict().argv; diff --git a/samples/automl/automlTranslationPredict.js b/samples/automl/automlTranslationPredict.js new file mode 100755 index 00000000..2896a3cf --- /dev/null +++ b/samples/automl/automlTranslationPredict.js @@ -0,0 +1,142 @@ +/** + * Copyright 2018, Google, LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This application demonstrates how to perform basic operations on prediction + * with the Google AutoML Translation API. + * + * For more information, see the documentation at + * https://cloud.google.com/translate/automl/docs + */ + +'use strict'; + +function predict( + projectId, + computeRegion, + modelId, + filePath, + translationAllowFallback +) { + // [START automl_translation_predict] + const automl = require('@google-cloud/automl'); + const fs = require('fs'); + + // Create client for prediction service. + const client = new automl.v1beta1.PredictionServiceClient(); + + /** + * TODO(developer): Uncomment the following line before running the sample. + */ + // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; + // const computeRegion = `region-name, e.g. "us-central1"`; + // const modelId = `id of the model, e.g. “ICN12345”`; + // const filePath = `local text file path of content to be classified, e.g. "./resources/test.txt"`; + // const translationAllowFallback = `use Google translation model as fallback, e.g. "False" or "True"'; + + // Get the full path of the model. + const modelFullId = client.modelPath(projectId, computeRegion, modelId); + + // Read the file content for translation. + const content = fs.readFileSync(filePath, 'utf8'); + + // Set the payload by giving the content of the file. + const payload = { + textSnippet: { + content: content, + }, + }; + + // params is additional domain-specific parameters. + // translationAllowFallback allows to use Google translation model. + var params = {}; + if (translationAllowFallback) { + params = { + translationAllowFallback: true, + }; + } + + client + .predict({name: modelFullId, payload: payload, params: params}) + .then(responses => { + const response = responses[0]; + console.log( + 'Translated Content: ', + response.payload[0].translation.translatedContent.content + ); + }) + .catch(err => { + console.error(err); + }); + // [END automl_translation_predict] +} + +require(`yargs`) + .demand(1) + .options({ + computeRegion: { + alias: `c`, + type: `string`, + default: process.env.REGION_NAME, + requiresArg: true, + description: `region name e.g. "us-central1"`, + }, + filePath: { + alias: `f`, + default: `./resources/testInput.txt`, + type: `string`, + requiresArg: true, + description: `local text file path of the content to be classified`, + }, + modelId: { + alias: `i`, + type: `string`, + requiresArg: true, + description: `Id of the model which will be used for text classification`, + }, + projectId: { + alias: `z`, + type: `number`, + default: process.env.PROJECT_ID, + requiresArg: true, + description: `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`, + }, + translationAllowFallback: { + alias: `t`, + type: `string`, + default: `False`, + requiresArg: true, + description: + `Use true if AutoML will fallback to use a Google translation model for` + + `translation requests if the specified AutoML translation model cannot` + + `serve the request. Use false to not use Google translation model.`, + }, + }) + .command(`predict`, `classify the content`, {}, opts => + predict( + opts.projectId, + opts.computeRegion, + opts.modelId, + opts.filePath, + opts.translationAllowFallback + ) + ) + .example( + `node $0 predict -i "modelId" -f "./resources/testInput.txt" -t "False"` + ) + .wrap(120) + .recommendCommands() + .help() + .strict().argv; diff --git a/samples/automl/resources/testInput.txt b/samples/automl/resources/testInput.txt new file mode 100644 index 00000000..acea9380 --- /dev/null +++ b/samples/automl/resources/testInput.txt @@ -0,0 +1 @@ +Tell me how this ends diff --git a/samples/package.json b/samples/package.json index 0d59c797..ec02e239 100644 --- a/samples/package.json +++ b/samples/package.json @@ -14,7 +14,9 @@ "test": "npm run cover" }, "dependencies": { + "@google-cloud/automl": "^0.1.1", "@google-cloud/translate": "^1.1.0", + "mathjs": "^5.1.0", "yargs": "^12.0.1" }, "devDependencies": { diff --git a/samples/system-test/automlTranslation.test.js b/samples/system-test/automlTranslation.test.js new file mode 100644 index 00000000..4681039c --- /dev/null +++ b/samples/system-test/automlTranslation.test.js @@ -0,0 +1,147 @@ +/** + * Copyright 2018, Google, LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint node/no-extraneous-require: off */ +/* eslint node/no-unsupported-features/es-syntax: off */ + +'use strict'; + +const test = require(`ava`); +const tools = require(`@google-cloud/nodejs-repo-tools`); + +const cmdDataset = `node ./automl/automlTranslationDataset.js`; +const cmdModel = `node ./automl/automlTranslationModel.js`; +const cmdPredict = `node ./automl/automlTranslationPredict.js`; + +// const flowerTrainData = `gs://`; +// const cwd = path.join(__dirname, `..`); + +const testDataSetName = `testDataSet`; +const dummyDataSet = `dummyDataSet`; +const testModelName = 'dummyModel'; +const sampleText = `./automl/resources/testInput.txt`; + +const donotdeleteModelId = `TRL188026453969732486`; +//const donotdeleteDatasetId = `TRL2551826603472450019`; + +// skipped because it's been taking too long to delete datasets +test.skip(`It should create a create, list, and delete a dataset`, async t => { + // Check to see that this dataset does not yet exist + let output = await tools.runAsync(`${cmdDataset} listDatasets`); + t.false(output.includes(testDataSetName)); + + // Create dataset + output = await tools.runAsync( + `${cmdDataset} createDataset -n "${testDataSetName}"` + ); + const dataSetId = output + .split(`\n`)[1] + .split(`:`)[1] + .trim(); + t.true(output.includes(`Dataset display name: ${testDataSetName}`)); + + // delete dataset + output = await tools.runAsync( + `${cmdDataset} deleteDataset -i "${dataSetId}"` + ); + t.true(output.includes(`Dataset deleted.`)); +}); + +// we make too models running this test, see hard-coded workaround below +test.skip(`It should create a dataset, import data, and start making a model`, async t => { + // Check to see that this dataset does not yet exist + let output = await tools.runAsync(`${cmdDataset} listDatasets`); + t.false(output.includes(dummyDataSet)); + + // Create dataset + output = await tools.runAsync( + `${cmdDataset} createDataset -n "${dummyDataSet}"` + ); + const dataSetId = output + .split(`\n`)[1] + .split(`:`)[1] + .trim(); + t.true(output.includes(`Dataset display name: ${dummyDataSet}`)); + + // Import Data + output = await tools.runAsync( + `${cmdDataset} importData -i "${dataSetId}" -p "gs://nodejs-docs-samples-vcm/flowerTraindata20lines.csv"` + ); + t.true(output.includes(`Data imported.`)); + + // Check to make sure model doesn't already exist + output = await tools.runAsync(`${cmdModel} listModels`); + t.false(output.includes(`${testModelName}`)); + + // begin training dataset, getting operation ID for next operation + output = await tools.runAsync( + `${cmdModel} createModel -i "${dataSetId}" -m "${testModelName}" -t "2"` + ); + const operationName = output + .split(`\n`)[0] + .split(`:`)[1] + .trim(); + t.true(output.includes(`Training started...`)); + + // poll operation status, here confirming that operation is not complete yet + output = await tools.runAsync( + `${cmdModel} getOperationStatus -i "${dataSetId}" -o "${operationName}"` + ); + t.true(output.includes(`done: false`)); +}); + +test(`It should run get model (from a prexisting model)`, async t => { + //confirm dataset exists + let output = await tools.runAsync(`${cmdDataset} listDatasets`); + t.true(output.includes(`me_do_not_delete`)); + + //list model evaluations, confirm model exists + output = await tools.runAsync( + `${cmdModel} listModelEvaluations -a "${donotdeleteModelId}"` + ); + t.true(output.includes(`translationEvaluationMetrics:`)); + + //get model evaluation + output = await tools.runAsync( + `${cmdModel} getModel -a "${donotdeleteModelId}"` + ); + t.true(output.includes(`Model deployment state: DEPLOYED`)); +}); + +test(`It should run Prediction from prexisting model`, async t => { + //confirm dataset exists + let output = await tools.runAsync(`${cmdDataset} listDatasets`); + t.true(output.includes(`me_do_not_delete`)); + + //list model evaluations, confirm model exists + output = await tools.runAsync( + `${cmdModel} listModelEvaluations -a "${donotdeleteModelId}"` + ); + t.true(output.includes(`translationEvaluationMetrics:`)); + + // run prediction on 'testImage.jpg' in resources folder + output = await tools.runAsync( + `${cmdPredict} predict -i "${donotdeleteModelId}" -f "${sampleText}" -t "False"` + ); + t.true( + output.includes(`Translated Content: これがどのように終わるか教えて`) + ); +}); + +//list datasets +test(`should list datasets`, async t => { + const output = await tools.runAsync(`${cmdDataset} listDatasets`); + t.true(output.includes(`List of datasets:`)); +}); From e2ffd61a8d4e0aea68e6b462ae28d8b1d0af4f59 Mon Sep 17 00:00:00 2001 From: Chris Frater Date: Wed, 22 Aug 2018 14:42:25 -0700 Subject: [PATCH 02/10] readme fix - check cloud link --- samples/README.md | 139 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/samples/README.md b/samples/README.md index d967f6cb..cc0b7e36 100644 --- a/samples/README.md +++ b/samples/README.md @@ -64,3 +64,142 @@ For more information, see https://cloud.google.com/translate/docs [shell_img]: //gstatic.com/cloudssh/images/open-btn.png [shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-translate&page=editor&open_in_editor=samples/README.md + +### automlTranslationDataset + +View the [source code][automlTranslationDataset_code]. + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-translate&page=editor&open_in_editor=samples/automl/automlTranslationDataset.js,samples/README.md) + +__Usage:__ `node automlTranslationDataset.js --help` + +``` +automlTranslationDataset.js + +Commands: + automlTranslationDataset.js createDataset creates a new Dataset + automlTranslationDataset.js listDatasets list all Datasets + automlTranslationDataset.js getDataset Get a Dataset + automlTranslationDataset.js deleteDataset Delete a dataset + automlTranslationDataset.js importData Import labeled items into dataset + +Options: + --version Show version number [boolean] + --computeRegion, -c region name e.g. "us-central1" [string] [default: "us-central1"] + --datasetName, -n Name of the Dataset [string] [default: "testDataSet"] + --datasetId, -i Id of the dataset [string] + --filter_, -f Name of the Dataset to search for [string] [default: "translationDatasetMetadata:*"] + --multilabel, -m Type of the classification problem, False - MULTICLASS, True - MULTILABEL. + [string] [default: false] + --outputUri, -o URI (or local path) to export dataset [string] + --path, -p URI or local path to input .csv, or array of .csv paths + [string] [default: "gs://nodejs-docs-samples-vcm/en-ja.csv"] + --projectId, -z The GCLOUD_PROJECT string, e.g. "my-gcloud-project" [number] [default: "nodejs-docs-samples"] + --source, -s The source language to be translated from [string] + --target, -t The target language to be translated to [string] + --help Show help [boolean] + +Examples: + node automlTranslationDataset.js createDataset -n "newDataSet" -s "en" -t "ja" + node automlTranslationDataset.js listDatasets -f "translationDatasetMetadata:*" + node automlTranslationDataset.js getDataset -i "DATASETID" + node automlTranslationDataset.js deleteDataset -i "DATASETID" + node automlTranslationDataset.js importData -i "dataSetId" -p "gs://myproject/mytraindata.csv" + +For more information, see https://cloud.google.com/translate/docs +``` + +[automlTranslationDataset_docs]: https://cloud.google.com/translate/docs +[automlTranslationDataset_code]: automl/automlTranslationDataset.js + +[shell_img]: //gstatic.com/cloudssh/images/open-btn.png +[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-translate&page=editor&open_in_editor=samples/README.md + +### automlTranslationModel + +View the [source code][automlTranslationModel_code]. + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-translate&page=editor&open_in_editor=samples/automl/automlTranslationModel.js,samples/README.md) + +__Usage:__ `node translate.js --help` + +``` +automlTranslationModel.js + +Commands: + automlTranslationModel.js createModel creates a new Model + automlTranslationModel.js getOperationStatus Gets status of current operation + automlTranslationModel.js listModels list all Models + automlTranslationModel.js getModel Get a Model + automlTranslationModel.js listModelEvaluations List model evaluations + automlTranslationModel.js getModelEvaluation Get model evaluation + automlTranslationModel.js deleteModel Delete a Model + +Options: + --version Show version number [boolean] + --computeRegion, -c region name e.g. "us-central1" [string] [default: "us-central1"] + --datasetId, -i Id of the dataset [string] + --filter_, -f Name of the Dataset to search for [string] [default: ""] + --modelName, -m Name of the model [string] [default: false] + --modelId, -a Id of the model [string] [default: ""] + --modelEvaluationId, -e Id of the model evaluation [string] [default: ""] + --operationFullId, -o Full name of an operation [string] [default: ""] + --projectId, -z The GCLOUD_PROJECT string, e.g. "my-gcloud-project" [number] [default: "nodejs-docs-samples"] + --help Show help [boolean] + +Examples: + node automlTranslationModel.js createModel -i "DatasetID" -m "myModelName" + node automlTranslationModel.js getOperationStatus -i "datasetId" -o "OperationFullID" + node automlTranslationModel.js listModels -f "translationModelMetadata:*" + node automlTranslationModel.js getModel -a "ModelID" + node automlTranslationModel.js listModelEvaluations -a "ModelID" + node automlTranslationModel.js getModelEvaluation -a "ModelId" -e "ModelEvaluationID" + node automlTranslationModel.js deleteModel -a "ModelID" + +For more information, see https://cloud.google.com/translate/docs +``` + +[automlTranslationModel_docs]: https://cloud.google.com/translate/docs +[automlTranslationModel_code]: automl/automlTranslationModel.js + +[shell_img]: //gstatic.com/cloudssh/images/open-btn.png +[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-translate&page=editor&open_in_editor=samples/README.md + +### automlTranslationPredict + +View the [source code][automlTranslationPredict_code]. + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-translate&page=editor&open_in_editor=samples/automl/automlTranslationPredict.js,samples/README.md) + +__Usage:__ `node translate.js --help` + +``` +automlTranslationPredict.js + +Commands: + automlTranslationPredict.js predict classify the content + +Options: + --version Show version number [boolean] + --computeRegion, -c region name e.g. "us-central1" [string] [default: "us-central1"] + --filePath, -f local text file path of the content to be classified + [string] [default: "./resources/testInput.txt"] + --modelId, -i Id of the model which will be used for text classification [string] + --projectId, -z The GCLOUD_PROJECT string, e.g. "my-gcloud-project" [number] [default: "203278707824"] + --translationAllowFallback, -t Use true if AutoML will fallback to use a Google translation model fortranslation + requests if the specified AutoML translation model cannotserve the request. Use false + to not use Google translation model. [string] [default: "False"] + --help Show help [boolean] + +Examples: + node automlTranslationPredict.js predict -i "modelId" -f "./resources/testInput.txt" -t "False" + +For more information, see https://cloud.google.com/translate/docs +``` + +[automlTranslationPredict_docs]: https://cloud.google.com/translate/docs +[automlTranslationPredict_code]: automl/automlTranslationPredict.js + +[shell_img]: //gstatic.com/cloudssh/images/open-btn.png +[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-translate&page=editor&open_in_editor=samples/README.md + From 779b2d2673dc4324409db4338a0678218a7f2f7c Mon Sep 17 00:00:00 2001 From: Chris Frater Date: Wed, 22 Aug 2018 15:38:16 -0700 Subject: [PATCH 03/10] first round style fixes --- samples/automl/automlTranslationDataset.js | 102 +++++----- samples/automl/automlTranslationModel.js | 185 +++++++----------- samples/automl/automlTranslationPredict.js | 6 +- samples/system-test/automlTranslation.test.js | 2 +- 4 files changed, 134 insertions(+), 161 deletions(-) diff --git a/samples/automl/automlTranslationDataset.js b/samples/automl/automlTranslationDataset.js index 62b62488..89aacee9 100755 --- a/samples/automl/automlTranslationDataset.js +++ b/samples/automl/automlTranslationDataset.js @@ -21,11 +21,11 @@ * https://cloud.google.com/translate/automl/docs */ -'use strict'; +`use strict`; function createDataset(projectId, computeRegion, datasetName, source, target) { // [START automl_translation_createDataset] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -60,22 +60,24 @@ function createDataset(projectId, computeRegion, datasetName, source, target) { const dataset = responses[0]; // Display the dataset information - console.log('Dataset name:', dataset.name); - console.log('Dataset id: ', dataset.name.split('/').pop(-1)); - console.log('Dataset display name: ', dataset.displayName); - console.log('Dataset example count: ', dataset.exampleCount); - console.log('Translation dataset specification:'); + console.log(`Dataset name: ${dataset.name}`); + console.log(`Dataset id: ${dataset.name.split(`/`).pop(-1)}`); + console.log(`Dataset display name: ${dataset.displayName}`); + console.log(`Dataset example count: ${dataset.exampleCount}`); + console.log(`Translation dataset specification:`); console.log( - '\tSource language code: ', - dataset.translationDatasetMetadata.sourceLanguageCode + `\tSource language code: ${ + dataset.translationDatasetMetadata.sourceLanguageCode + }` ); console.log( - '\tTarget language code: ', - dataset.translationDatasetMetadata.targetLanguageCode + `\tTarget language code: ${ + dataset.translationDatasetMetadata.targetLanguageCode + }` ); - console.log('Dataset create time:'); - console.log('\tseconds: ', dataset.createTime.seconds); - console.log('\tnanos: ', dataset.createTime.nanos); + console.log(`Dataset create time:`); + console.log(`\tseconds: ${dataset.createTime.seconds}`); + console.log(`\tnanos: ${dataset.createTime.nanos}`); }) .catch(err => { console.error(err); @@ -85,7 +87,7 @@ function createDataset(projectId, computeRegion, datasetName, source, target) { function listDatasets(projectId, computeRegion, filter_) { // [START automl_translation_listDatasets] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -106,24 +108,26 @@ function listDatasets(projectId, computeRegion, filter_) { const dataset = responses[0]; // Display the dataset information. - console.log('List of datasets:'); - for (let i = 0; i < dataset.length; i += 1) { - console.log('Dataset name:', dataset[i].name); - console.log('Dataset id: ', dataset[i].name.split('/').pop(-1)); - console.log('Dataset display name: ', dataset[i].displayName); - console.log('Dataset example count: ', dataset[i].exampleCount); - console.log('Translation dataset specification:'); + console.log(`List of datasets:`); + for (let i of dataset) { + console.log(`Dataset name: ${i.name}`); + console.log(`Dataset id: ${i.name.split(`/`).pop(-1)}`); + console.log(`Dataset display name: ${i.displayName}`); + console.log(`Dataset example count: ${i.exampleCount}`); + console.log(`Translation dataset specification:`); console.log( - '\tSource language code: ', - dataset[i].translationDatasetMetadata.sourceLanguageCode + `\tSource language code: ${ + i.translationDatasetMetadata.sourceLanguageCode + }` ); console.log( - '\tTarget language code: ', - dataset[i].translationDatasetMetadata.targetLanguageCode + `\tTarget language code: ${ + i.translationDatasetMetadata.targetLanguageCode + }` ); - console.log('Dataset create time:'); - console.log('\tseconds: ', dataset[i].createTime.seconds); - console.log('\tnanos: ', dataset[i].createTime.nanos); + console.log(`Dataset create time:`); + console.log(`\tseconds: ${i.createTime.seconds}`); + console.log(`\tnanos: ${i.createTime.nanos}`); } }) .catch(err => { @@ -134,7 +138,7 @@ function listDatasets(projectId, computeRegion, filter_) { function getDataset(projectId, computeRegion, datasetId) { // [START automl_translation_getDataset] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -155,22 +159,24 @@ function getDataset(projectId, computeRegion, datasetId) { const dataset = responses[0]; // Display the dataset information. - console.log('Dataset name:', dataset.name); - console.log('Dataset id: ', dataset.name.split('/').pop(-1)); - console.log('Dataset display name: ', dataset.displayName); - console.log('Dataset example count: ', dataset.exampleCount); - console.log('Translation dataset specification:'); + console.log(`Dataset name: ${dataset.name}`); + console.log(`Dataset id: ${dataset.name.split(`/`).pop(-1)}`); + console.log(`Dataset display name: ${dataset.displayName}`); + console.log(`Dataset example count: ${dataset.exampleCount}`); + console.log(`Translation dataset specification:`); console.log( - '\tSource language code: ', - dataset.translationDatasetMetadata.sourceLanguageCode + `\tSource language code: ${ + dataset.translationDatasetMetadata.sourceLanguageCode + }` ); console.log( - '\tTarget language code: ', - dataset.translationDatasetMetadata.targetLanguageCode + `\tTarget language code: ${ + dataset.translationDatasetMetadata.targetLanguageCode + }` ); - console.log('Dataset create time:'); - console.log('\tseconds: ', dataset.createTime.seconds); - console.log('\tnanos: ', dataset.createTime.nanos); + console.log(`Dataset create time:`); + console.log(`\tseconds: ${dataset.createTime.seconds}`); + console.log(`\tnanos: ${dataset.createTime.nanos}`); }) .catch(err => { console.error(err); @@ -180,7 +186,7 @@ function getDataset(projectId, computeRegion, datasetId) { function importData(projectId, computeRegion, datasetId, path) { // [START automl_translation_importData] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -196,7 +202,7 @@ function importData(projectId, computeRegion, datasetId, path) { const datasetFullId = client.datasetPath(projectId, computeRegion, datasetId); // Get the multiple Google Cloud Storage URIs. - const inputUris = path.split(','); + const inputUris = path.split(`,`); const inputConfig = { gcsSource: { inputUris: inputUris, @@ -208,13 +214,13 @@ function importData(projectId, computeRegion, datasetId, path) { .importData({name: datasetFullId, inputConfig: inputConfig}) .then(responses => { const operation = responses[0]; - console.log('Processing import...'); + console.log(`Processing import...`); return operation.promise(); }) .then(responses => { // The final result of the operation. if (responses[2].done === true) console.log(`Data imported.`); - console.log('Dataset imported.'); + console.log(`Dataset imported.`); }) .catch(err => { console.error(err); @@ -224,7 +230,7 @@ function importData(projectId, computeRegion, datasetId, path) { function deleteDataset(projectId, computeRegion, datasetId) { // [START automl_translation_deleteDataset] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -247,7 +253,7 @@ function deleteDataset(projectId, computeRegion, datasetId) { }) .then(responses => { // The final result of the operation. - if (responses[2].done === true) console.log('Dataset deleted.'); + if (responses[2].done === true) console.log(`Dataset deleted.`); }) .catch(err => { console.error(err); diff --git a/samples/automl/automlTranslationModel.js b/samples/automl/automlTranslationModel.js index 9c4d3fde..c91cc81b 100755 --- a/samples/automl/automlTranslationModel.js +++ b/samples/automl/automlTranslationModel.js @@ -21,11 +21,11 @@ * https://cloud.google.com/translate/automl/docs */ -'use strict'; +`use strict`; function createModel(projectId, computeRegion, datasetId, modelName) { // [START automl_translation_createModel] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -54,8 +54,8 @@ function createModel(projectId, computeRegion, datasetId, modelName) { const operation = responses[0]; const initialApiResponse = responses[1]; - console.log('Training operation name: ', initialApiResponse.name); - console.log('Training started...'); + console.log(`Training operation name: `, initialApiResponse.name); + console.log(`Training started...`); return operation.promise(); }) .then(responses => { @@ -63,21 +63,21 @@ function createModel(projectId, computeRegion, datasetId, modelName) { const model = responses[0]; console.log(model); // Retrieve deployment state. - var deploymentState = ''; + var deploymentState = ``; if (model.deploymentState === 1) { - deploymentState = 'deployed'; + deploymentState = `deployed`; } else if (model.deploymentState === 2) { - deploymentState = 'undeployed'; + deploymentState = `undeployed`; } // Display the model information. - console.log('Model name: ', model.name); - console.log('Model id: ', model.name.split('/').pop(-1)); - console.log('Model display name: ', model.displayName); - console.log('Model create time:'); - console.log('\tseconds: ', model.createTime.seconds); - console.log('\tnanos: ', model.createTime.nanos); - console.log('Model deployment state: ', deploymentState); + console.log(`Model name: ${model.name}`); + console.log(`Model id: ${model.name.split(`/`).pop(-1)}`); + console.log(`Model display name: ${model.displayName}`); + console.log(`Model create time:`); + console.log(`\tseconds: ${model.createTime.seconds}`); + console.log(`\tnanos: ${model.createTime.nanos}`); + console.log(`Model deployment state: ${deploymentState}`); }) .catch(err => { console.error(err); @@ -87,7 +87,7 @@ function createModel(projectId, computeRegion, datasetId, modelName) { function listModels(projectId, computeRegion, filter_) { // [START automl_translation_listModels] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -108,62 +108,20 @@ function listModels(projectId, computeRegion, filter_) { const model = responses[0]; // Display the model information. - console.log('List of models:'); - for (let i = 0; i < model.length; i += 1) { - console.log('Model name: ', model[i].name); - console.log('Model id: ', model[i].name.split('/').pop(-1)); - console.log('Model display name: ', model[i].displayName); - console.log('Model dataset id: ', model[i].datasetId); - if (model[i].modelMetadata === 'translationModelMetadata') { - console.log('Translation model metadata:'); - console.log( - '\tBase model: ', - model[i].translationModelMetadata.baseModel - ); - console.log( - '\tSource language code: ', - model[i].translationModelMetadata.sourceLanguageCode - ); - console.log( - '\tTarget language code: ', - model[i].translationModelMetadata.targetLanguageCode - ); - } else if ( - model[i].modelMetadata === 'textClassificationModelMetadata' - ) { - console.log( - 'Text classification model metadata: ', - model[i].textClassificationModelMetadata - ); - } else if ( - model[i].modelMetadata === 'imageClassificationModelMetadata' - ) { - console.log('Image classification model metadata:'); - console.log( - '\tBase model id: ', - model[i].imageClassificationModelMetadata.baseModelId - ); - console.log( - '\tTrain budget: ', - model[i].imageClassificationModelMetadata.trainBudget - ); - console.log( - '\tTrain cost: ', - model[i].imageClassificationModelMetadata.trainCost - ); - console.log( - '\tStop reason: ', - model[i].imageClassificationModelMetadata.stopReason - ); - } - console.log('Model create time:'); - console.log('\tseconds: ', model[i].createTime.seconds); - console.log('\tnanos: ', model[i].createTime.nanos); - console.log('Model update time:'); - console.log('\tseconds: ', model[i].updateTime.seconds); - console.log('\tnanos: ', model[i].updateTime.nanos); - console.log('Model deployment state: ', model[i].deploymentState); - console.log('\n'); + console.log(`List of models:`); + for (let i of model) { + console.log(`Model name: ${i.name}`); + console.log(`Model id: ${i.name.split(`/`).pop(-1)}`); + console.log(`Model display name: ${i.displayName}`); + console.log(`Model dataset id: ${i.datasetId}`); + console.log(`Model create time:`); + console.log(`\tseconds: ${i.createTime.seconds}`); + console.log(`\tnanos: ${i.createTime.nanos}`); + console.log(`Model update time:`); + console.log(`\tseconds: ${i.updateTime.seconds}`); + console.log(`\tnanos: ${i.updateTime.nanos}`); + console.log(`Model deployment state: ${i.deploymentState}`); + console.log(`\n`); } }) .catch(err => { @@ -174,7 +132,7 @@ function listModels(projectId, computeRegion, filter_) { function getModel(projectId, computeRegion, modelId) { // [START automl_translation_getModel] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -195,52 +153,57 @@ function getModel(projectId, computeRegion, modelId) { const model = responses[0]; // Display the model information. - console.log('Model name: ', model.name); - console.log('Model id: ', model.name.split('/').pop(-1)); - console.log('Model display name: ', model.displayName); - console.log('Model dataset id: ', model.datasetId); - if (model.modelMetadata === 'translationModelMetadata') { - console.log('Translation model metadata:'); - console.log('\tBase model: ', model.translationModelMetadata.baseModel); + console.log(`Model name: ${model.name}`); + console.log(`Model id: ${model.name.split(`/`).pop(-1)}`); + console.log(`Model display name: ${model.displayName}`); + console.log(`Model dataset id: ${model.datasetId}`); + if (model.modelMetadata === `translationModelMetadata`) { + console.log(`Translation model metadata:`); console.log( - '\tSource language code: ', - model.translationModelMetadata.sourceLanguageCode + `\tBase model: ${model.translationModelMetadata.baseModel}` ); console.log( - '\tTarget language code: ', - model.translationModelMetadata.targetLanguageCode + `\tSource language code: ${ + model.translationModelMetadata.sourceLanguageCode + }` ); - } else if (model.modelMetadata === 'textClassificationModelMetadata') { console.log( - 'Text classification model metadata: ', - model.textClassificationModelMetadata + `\tTarget language code: ${ + model.translationModelMetadata.targetLanguageCode + }` ); - } else if (model.modelMetadata === 'imageClassificationModelMetadata') { - console.log('Image classification model metadata:'); + } else if (model.modelMetadata === `textClassificationModelMetadata`) { console.log( - '\tBase model id: ', - model.imageClassificationModelMetadata.baseModelId + `Text classification model metadata: ${ + model.textClassificationModelMetadata + }` ); + } else if (model.modelMetadata === `imageClassificationModelMetadata`) { + console.log(`Image classification model metadata:`); console.log( - '\tTrain budget: ', - model.imageClassificationModelMetadata.trainBudget + `\tBase model id: ${ + model.imageClassificationModelMetadata.baseModelId + }` ); console.log( - '\tTrain cost: ', - model.imageClassificationModelMetadata.trainCost + `\tTrain budget: ${ + model.imageClassificationModelMetadata.trainBudget + }` ); console.log( - '\tStop reason: ', - model.imageClassificationModelMetadata.stopReason + `\tTrain cost: ${model.imageClassificationModelMetadata.trainCost}` + ); + console.log( + `\tStop reason: ${model.imageClassificationModelMetadata.stopReason}` ); } - console.log('Model create time:'); - console.log('\tseconds: ', model.createTime.seconds); - console.log('\tnanos: ', model.createTime.nanos); - console.log('Model update time:'); - console.log('\tseconds: ', model.updateTime.seconds); - console.log('\tnanos: ', model.updateTime.nanos); - console.log('Model deployment state: ', model.deploymentState); + console.log(`Model create time:`); + console.log(`\tseconds: ${model.createTime.seconds}`); + console.log(`\tnanos: ${model.createTime.nanos}`); + console.log(`Model update time:`); + console.log(`\tseconds: ${model.updateTime.seconds}`); + console.log(`\tnanos: ${model.updateTime.nanos}`); + console.log(`Model deployment state: ${model.deploymentState}`); }) .catch(err => { console.error(err); @@ -250,7 +213,7 @@ function getModel(projectId, computeRegion, modelId) { function listModelEvaluations(projectId, computeRegion, modelId, filter_) { // [START automl_translation_listModelEvaluations] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -270,9 +233,9 @@ function listModelEvaluations(projectId, computeRegion, modelId, filter_) { .listModelEvaluations({parent: modelFullId, filter: filter_}) .then(responses => { const element = responses[0]; - console.log('List of model evaluations:'); - for (let i = 0; i < element.length; i += 1) { - console.log(element[i]); + console.log(`List of model evaluations:`); + for (let i of element) { + console.log(i); } }) .catch(err => { @@ -288,7 +251,7 @@ function getModelEvaluation( modelEvaluationId ) { // [START automl_translation_getModelEvaluation] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -323,7 +286,7 @@ function getModelEvaluation( function deleteModel(projectId, computeRegion, modelId) { // [START automl_translation_deleteModel] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -356,7 +319,7 @@ function deleteModel(projectId, computeRegion, modelId) { function getOperationStatus(operationFullId) { // [START automl_translation_getOperationStatus] - const automl = require('@google-cloud/automl'); + const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -368,7 +331,7 @@ function getOperationStatus(operationFullId) { // Get the latest state of a long-running operation. client.operationsClient.getOperation(operationFullId).then(responses => { const response = responses[0]; - console.log('Operation status: ', response); + console.log(`Operation status: ${response}`); }); // [END automl_translation_getOperationStatus] } diff --git a/samples/automl/automlTranslationPredict.js b/samples/automl/automlTranslationPredict.js index 2896a3cf..93925caa 100755 --- a/samples/automl/automlTranslationPredict.js +++ b/samples/automl/automlTranslationPredict.js @@ -69,7 +69,11 @@ function predict( } client - .predict({name: modelFullId, payload: payload, params: params}) + .predict({ + name: modelFullId, + payload: payload, + params: params, + }) .then(responses => { const response = responses[0]; console.log( diff --git a/samples/system-test/automlTranslation.test.js b/samples/system-test/automlTranslation.test.js index 4681039c..c38c9290 100644 --- a/samples/system-test/automlTranslation.test.js +++ b/samples/system-test/automlTranslation.test.js @@ -59,7 +59,7 @@ test.skip(`It should create a create, list, and delete a dataset`, async t => { t.true(output.includes(`Dataset deleted.`)); }); -// we make too models running this test, see hard-coded workaround below +// we make two models running this test, see hard-coded workaround below test.skip(`It should create a dataset, import data, and start making a model`, async t => { // Check to see that this dataset does not yet exist let output = await tools.runAsync(`${cmdDataset} listDatasets`); From efb5658c4348d47ac07160efb079f8ed17ffc469 Mon Sep 17 00:00:00 2001 From: Chris Frater Date: Wed, 22 Aug 2018 15:42:43 -0700 Subject: [PATCH 04/10] style fix 2 --- samples/automl/automlTranslationPredict.js | 12 ++++++------ samples/system-test/automlTranslation.test.js | 5 +---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/samples/automl/automlTranslationPredict.js b/samples/automl/automlTranslationPredict.js index 93925caa..25f03b27 100755 --- a/samples/automl/automlTranslationPredict.js +++ b/samples/automl/automlTranslationPredict.js @@ -21,7 +21,7 @@ * https://cloud.google.com/translate/automl/docs */ -'use strict'; +`use strict`; function predict( projectId, @@ -31,8 +31,8 @@ function predict( translationAllowFallback ) { // [START automl_translation_predict] - const automl = require('@google-cloud/automl'); - const fs = require('fs'); + const automl = require(`@google-cloud/automl`); + const fs = require(`fs`); // Create client for prediction service. const client = new automl.v1beta1.PredictionServiceClient(); @@ -44,13 +44,13 @@ function predict( // const computeRegion = `region-name, e.g. "us-central1"`; // const modelId = `id of the model, e.g. “ICN12345”`; // const filePath = `local text file path of content to be classified, e.g. "./resources/test.txt"`; - // const translationAllowFallback = `use Google translation model as fallback, e.g. "False" or "True"'; + // const translationAllowFallback = `use Google translation model as fallback, e.g. "False" or "True"`; // Get the full path of the model. const modelFullId = client.modelPath(projectId, computeRegion, modelId); // Read the file content for translation. - const content = fs.readFileSync(filePath, 'utf8'); + const content = fs.readFileSync(filePath, `utf8`); // Set the payload by giving the content of the file. const payload = { @@ -77,7 +77,7 @@ function predict( .then(responses => { const response = responses[0]; console.log( - 'Translated Content: ', + `Translated Content: `, response.payload[0].translation.translatedContent.content ); }) diff --git a/samples/system-test/automlTranslation.test.js b/samples/system-test/automlTranslation.test.js index c38c9290..f3f86a9d 100644 --- a/samples/system-test/automlTranslation.test.js +++ b/samples/system-test/automlTranslation.test.js @@ -25,9 +25,6 @@ const cmdDataset = `node ./automl/automlTranslationDataset.js`; const cmdModel = `node ./automl/automlTranslationModel.js`; const cmdPredict = `node ./automl/automlTranslationPredict.js`; -// const flowerTrainData = `gs://`; -// const cwd = path.join(__dirname, `..`); - const testDataSetName = `testDataSet`; const dummyDataSet = `dummyDataSet`; const testModelName = 'dummyModel'; @@ -117,7 +114,7 @@ test(`It should run get model (from a prexisting model)`, async t => { output = await tools.runAsync( `${cmdModel} getModel -a "${donotdeleteModelId}"` ); - t.true(output.includes(`Model deployment state: DEPLOYED`)); + t.true(output.includes(`Model deployment state: DEPLOYED`)); }); test(`It should run Prediction from prexisting model`, async t => { From 2a309c5e47057672d38829d19bc58aa25952e3ea Mon Sep 17 00:00:00 2001 From: Chris Frater Date: Fri, 24 Aug 2018 08:58:22 -0700 Subject: [PATCH 05/10] Thanks Ace! --- samples/automl/automlTranslationDataset.js | 25 +++++++++-------- samples/automl/automlTranslationModel.js | 28 +++++++++---------- samples/automl/automlTranslationPredict.js | 4 +-- samples/system-test/automlTranslation.test.js | 24 ++++++++-------- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/samples/automl/automlTranslationDataset.js b/samples/automl/automlTranslationDataset.js index 89aacee9..c0f1a3ff 100755 --- a/samples/automl/automlTranslationDataset.js +++ b/samples/automl/automlTranslationDataset.js @@ -24,7 +24,7 @@ `use strict`; function createDataset(projectId, computeRegion, datasetName, source, target) { - // [START automl_translation_createDataset] + // [START automl_translation_create_dataset] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -82,11 +82,11 @@ function createDataset(projectId, computeRegion, datasetName, source, target) { .catch(err => { console.error(err); }); - // [END automl_translation_createDataset] + // [END automl_translation_create_dataset] } function listDatasets(projectId, computeRegion, filter_) { - // [START automl_translation_listDatasets] + // [START automl_translation_list_datasets] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -133,11 +133,11 @@ function listDatasets(projectId, computeRegion, filter_) { .catch(err => { console.error(err); }); - // [END automl_translation_listDatasets] + // [START automl_translation_list_datasets] } function getDataset(projectId, computeRegion, datasetId) { - // [START automl_translation_getDataset] + // [START automl_translation_get_dataset] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -181,11 +181,11 @@ function getDataset(projectId, computeRegion, datasetId) { .catch(err => { console.error(err); }); - // [END automl_translation_getDataset] + // [END automl_translation_get_dataset] } function importData(projectId, computeRegion, datasetId, path) { - // [START automl_translation_importData] + // [START automl_translation_import_data] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -219,17 +219,18 @@ function importData(projectId, computeRegion, datasetId, path) { }) .then(responses => { // The final result of the operation. - if (responses[2].done === true) console.log(`Data imported.`); - console.log(`Dataset imported.`); + if (responses[2].done === true) { + console.log(`Data imported.`); + } }) .catch(err => { console.error(err); }); - // [END automl_translation_importData] + // [END automl_translation_import_data] } function deleteDataset(projectId, computeRegion, datasetId) { - // [START automl_translation_deleteDataset] + // [START automl_translation_delete_dataset] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -258,7 +259,7 @@ function deleteDataset(projectId, computeRegion, datasetId) { .catch(err => { console.error(err); }); - // [END automl_translation_deleteDataset] + // [END automl_translation_delete_dataset] } require(`yargs`) diff --git a/samples/automl/automlTranslationModel.js b/samples/automl/automlTranslationModel.js index c91cc81b..6496c919 100755 --- a/samples/automl/automlTranslationModel.js +++ b/samples/automl/automlTranslationModel.js @@ -24,7 +24,7 @@ `use strict`; function createModel(projectId, computeRegion, datasetId, modelName) { - // [START automl_translation_createModel] + // [START automl_translation_create_model] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -82,11 +82,11 @@ function createModel(projectId, computeRegion, datasetId, modelName) { .catch(err => { console.error(err); }); - // [END automl_translation_createModel] + // [END automl_translation_create_model] } function listModels(projectId, computeRegion, filter_) { - // [START automl_translation_listModels] + // [START automl_translation_list_models] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -127,11 +127,11 @@ function listModels(projectId, computeRegion, filter_) { .catch(err => { console.error(err); }); - // [END automl_translation_listModels] + // [END automl_translation_list_models] } function getModel(projectId, computeRegion, modelId) { - // [START automl_translation_getModel] + // [START automl_translation_get_model] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -208,11 +208,11 @@ function getModel(projectId, computeRegion, modelId) { .catch(err => { console.error(err); }); - // [END automl_translation_getModel] + // [END automl_translation_get_model] } function listModelEvaluations(projectId, computeRegion, modelId, filter_) { - // [START automl_translation_listModelEvaluations] + // [START automl_translation_list_model_evaluations] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -241,7 +241,7 @@ function listModelEvaluations(projectId, computeRegion, modelId, filter_) { .catch(err => { console.error(err); }); - // [END automl_translation_listModelEvaluations] + // [END automl_translation_list_model_evaluations] } function getModelEvaluation( @@ -250,7 +250,7 @@ function getModelEvaluation( modelId, modelEvaluationId ) { - // [START automl_translation_getModelEvaluation] + // [START automl_translation_get_model_evaluation] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -281,11 +281,11 @@ function getModelEvaluation( .catch(err => { console.error(err); }); - // [END automl_translation_getModelEvaluation] + // [END automl_translation_get_model_evaluation] } function deleteModel(projectId, computeRegion, modelId) { - // [START automl_translation_deleteModel] + // [START automl_translation_delete_model] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -314,11 +314,11 @@ function deleteModel(projectId, computeRegion, modelId) { .catch(err => { console.error(err); }); - // [END automl_translation_deleteModel] + // [END automl_translation_delete_model] } function getOperationStatus(operationFullId) { - // [START automl_translation_getOperationStatus] + // [START automl_translation_get_operation_status] const automl = require(`@google-cloud/automl`); const client = new automl.v1beta1.AutoMlClient(); @@ -333,7 +333,7 @@ function getOperationStatus(operationFullId) { const response = responses[0]; console.log(`Operation status: ${response}`); }); - // [END automl_translation_getOperationStatus] + // [END automl_translation_get_operation_status] } require(`yargs`) diff --git a/samples/automl/automlTranslationPredict.js b/samples/automl/automlTranslationPredict.js index 25f03b27..d7768e3b 100755 --- a/samples/automl/automlTranslationPredict.js +++ b/samples/automl/automlTranslationPredict.js @@ -59,8 +59,8 @@ function predict( }, }; - // params is additional domain-specific parameters. - // translationAllowFallback allows to use Google translation model. + // Params is additional domain-specific parameters. + // TranslationAllowFallback allows to use Google translation model. var params = {}; if (translationAllowFallback) { params = { diff --git a/samples/system-test/automlTranslation.test.js b/samples/system-test/automlTranslation.test.js index f3f86a9d..880ce29c 100644 --- a/samples/system-test/automlTranslation.test.js +++ b/samples/system-test/automlTranslation.test.js @@ -33,7 +33,7 @@ const sampleText = `./automl/resources/testInput.txt`; const donotdeleteModelId = `TRL188026453969732486`; //const donotdeleteDatasetId = `TRL2551826603472450019`; -// skipped because it's been taking too long to delete datasets +// Skipped because it's been taking too long to delete datasets test.skip(`It should create a create, list, and delete a dataset`, async t => { // Check to see that this dataset does not yet exist let output = await tools.runAsync(`${cmdDataset} listDatasets`); @@ -49,14 +49,14 @@ test.skip(`It should create a create, list, and delete a dataset`, async t => { .trim(); t.true(output.includes(`Dataset display name: ${testDataSetName}`)); - // delete dataset + // Delete dataset output = await tools.runAsync( `${cmdDataset} deleteDataset -i "${dataSetId}"` ); t.true(output.includes(`Dataset deleted.`)); }); -// we make two models running this test, see hard-coded workaround below +// We make two models running this test, see hard-coded workaround below test.skip(`It should create a dataset, import data, and start making a model`, async t => { // Check to see that this dataset does not yet exist let output = await tools.runAsync(`${cmdDataset} listDatasets`); @@ -82,7 +82,7 @@ test.skip(`It should create a dataset, import data, and start making a model`, a output = await tools.runAsync(`${cmdModel} listModels`); t.false(output.includes(`${testModelName}`)); - // begin training dataset, getting operation ID for next operation + // Begin training dataset, getting operation ID for next operation output = await tools.runAsync( `${cmdModel} createModel -i "${dataSetId}" -m "${testModelName}" -t "2"` ); @@ -92,7 +92,7 @@ test.skip(`It should create a dataset, import data, and start making a model`, a .trim(); t.true(output.includes(`Training started...`)); - // poll operation status, here confirming that operation is not complete yet + // Poll operation status, here confirming that operation is not complete yet output = await tools.runAsync( `${cmdModel} getOperationStatus -i "${dataSetId}" -o "${operationName}"` ); @@ -100,17 +100,17 @@ test.skip(`It should create a dataset, import data, and start making a model`, a }); test(`It should run get model (from a prexisting model)`, async t => { - //confirm dataset exists + // Confirm dataset exists let output = await tools.runAsync(`${cmdDataset} listDatasets`); t.true(output.includes(`me_do_not_delete`)); - //list model evaluations, confirm model exists + // List model evaluations, confirm model exists output = await tools.runAsync( `${cmdModel} listModelEvaluations -a "${donotdeleteModelId}"` ); t.true(output.includes(`translationEvaluationMetrics:`)); - //get model evaluation + // Get model evaluation output = await tools.runAsync( `${cmdModel} getModel -a "${donotdeleteModelId}"` ); @@ -118,17 +118,17 @@ test(`It should run get model (from a prexisting model)`, async t => { }); test(`It should run Prediction from prexisting model`, async t => { - //confirm dataset exists + // Confirm dataset exists let output = await tools.runAsync(`${cmdDataset} listDatasets`); t.true(output.includes(`me_do_not_delete`)); - //list model evaluations, confirm model exists + // List model evaluations, confirm model exists output = await tools.runAsync( `${cmdModel} listModelEvaluations -a "${donotdeleteModelId}"` ); t.true(output.includes(`translationEvaluationMetrics:`)); - // run prediction on 'testImage.jpg' in resources folder + // Run prediction on 'testImage.jpg' in resources folder output = await tools.runAsync( `${cmdPredict} predict -i "${donotdeleteModelId}" -f "${sampleText}" -t "False"` ); @@ -137,7 +137,7 @@ test(`It should run Prediction from prexisting model`, async t => { ); }); -//list datasets +// List datasets test(`should list datasets`, async t => { const output = await tools.runAsync(`${cmdDataset} listDatasets`); t.true(output.includes(`List of datasets:`)); From ad8ae322bb80023bc3589c6947ebae589b711558 Mon Sep 17 00:00:00 2001 From: Chris Frater Date: Fri, 24 Aug 2018 11:51:25 -0700 Subject: [PATCH 06/10] template path fix --- samples/system-test/automlTranslation.test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/samples/system-test/automlTranslation.test.js b/samples/system-test/automlTranslation.test.js index 880ce29c..d40400c9 100644 --- a/samples/system-test/automlTranslation.test.js +++ b/samples/system-test/automlTranslation.test.js @@ -21,9 +21,10 @@ const test = require(`ava`); const tools = require(`@google-cloud/nodejs-repo-tools`); -const cmdDataset = `node ./automl/automlTranslationDataset.js`; -const cmdModel = `node ./automl/automlTranslationModel.js`; -const cmdPredict = `node ./automl/automlTranslationPredict.js`; +const automl = `node ./automl`; +const cmdDataset = `${automl}/automlTranslationDataset.js`; +const cmdModel = `${automl}/automlTranslationModel.js`; +const cmdPredict = `${automl}/automlTranslationPredict.js`; const testDataSetName = `testDataSet`; const dummyDataSet = `dummyDataSet`; From 53f76a2eee6f32c7dac2f57a28324eae3245e462 Mon Sep 17 00:00:00 2001 From: Rebecca Taylor Date: Mon, 10 Sep 2018 12:42:17 -0700 Subject: [PATCH 07/10] =?UTF-8?q?Fix=20ENV=20variable=20for=20project=20Id?= =?UTF-8?q?=C2=A0(GCLOUD=5FPROJECT)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/automl/automlTranslationPredict.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/automl/automlTranslationPredict.js b/samples/automl/automlTranslationPredict.js index d7768e3b..f934f982 100755 --- a/samples/automl/automlTranslationPredict.js +++ b/samples/automl/automlTranslationPredict.js @@ -113,7 +113,7 @@ require(`yargs`) projectId: { alias: `z`, type: `number`, - default: process.env.PROJECT_ID, + default: process.env.GCLOUD_PROJECT, requiresArg: true, description: `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`, }, From fa8772343e2714744a02f27cdbecc151c94e447b Mon Sep 17 00:00:00 2001 From: nirupa-kumar Date: Wed, 26 Sep 2018 10:39:34 -0700 Subject: [PATCH 08/10] Translate AutoML samples --- samples/README.md | 52 ++++----- .../automl/AutoML Translation Tutorial.docx | Bin 22371 -> 0 bytes samples/automl/automlTranslationDataset.js | 66 +++++------ samples/automl/automlTranslationModel.js | 107 +++++++++--------- samples/automl/automlTranslationPredict.js | 4 +- samples/automl/package.json | 26 +++++ samples/automl/system-test/.eslintrc.yml | 5 + .../system-test/automlTranslation.test.js | 43 ++++--- 8 files changed, 166 insertions(+), 137 deletions(-) delete mode 100755 samples/automl/AutoML Translation Tutorial.docx create mode 100644 samples/automl/package.json create mode 100644 samples/automl/system-test/.eslintrc.yml rename samples/{ => automl}/system-test/automlTranslation.test.js (71%) diff --git a/samples/README.md b/samples/README.md index cc0b7e36..08dbdd6a 100644 --- a/samples/README.md +++ b/samples/README.md @@ -77,18 +77,18 @@ __Usage:__ `node automlTranslationDataset.js --help` automlTranslationDataset.js Commands: - automlTranslationDataset.js createDataset creates a new Dataset - automlTranslationDataset.js listDatasets list all Datasets - automlTranslationDataset.js getDataset Get a Dataset - automlTranslationDataset.js deleteDataset Delete a dataset - automlTranslationDataset.js importData Import labeled items into dataset + automlTranslationDataset.js create-dataset creates a new Dataset + automlTranslationDataset.js list-datasets list all Datasets + automlTranslationDataset.js get-dataset Get a Dataset + automlTranslationDataset.js delete-dataset Delete a dataset + automlTranslationDataset.js import-data Import labeled items into dataset Options: --version Show version number [boolean] --computeRegion, -c region name e.g. "us-central1" [string] [default: "us-central1"] --datasetName, -n Name of the Dataset [string] [default: "testDataSet"] --datasetId, -i Id of the dataset [string] - --filter_, -f Name of the Dataset to search for [string] [default: "translationDatasetMetadata:*"] + --filter, -f Name of the Dataset to search for [string] [default: "translationDatasetMetadata:*"] --multilabel, -m Type of the classification problem, False - MULTICLASS, True - MULTILABEL. [string] [default: false] --outputUri, -o URI (or local path) to export dataset [string] @@ -100,11 +100,11 @@ Options: --help Show help [boolean] Examples: - node automlTranslationDataset.js createDataset -n "newDataSet" -s "en" -t "ja" - node automlTranslationDataset.js listDatasets -f "translationDatasetMetadata:*" - node automlTranslationDataset.js getDataset -i "DATASETID" - node automlTranslationDataset.js deleteDataset -i "DATASETID" - node automlTranslationDataset.js importData -i "dataSetId" -p "gs://myproject/mytraindata.csv" + node automlTranslationDataset.js create-dataset -n "newDataSet" -s "en" -t "ja" + node automlTranslationDataset.js list-datasets -f "translationDatasetMetadata:*" + node automlTranslationDataset.js get-dataset -i "DATASETID" + node automlTranslationDataset.js delete-dataset -i "DATASETID" + node automlTranslationDataset.js import-data -i "dataSetId" -p "gs://myproject/mytraindata.csv" For more information, see https://cloud.google.com/translate/docs ``` @@ -127,19 +127,19 @@ __Usage:__ `node translate.js --help` automlTranslationModel.js Commands: - automlTranslationModel.js createModel creates a new Model - automlTranslationModel.js getOperationStatus Gets status of current operation - automlTranslationModel.js listModels list all Models - automlTranslationModel.js getModel Get a Model - automlTranslationModel.js listModelEvaluations List model evaluations - automlTranslationModel.js getModelEvaluation Get model evaluation - automlTranslationModel.js deleteModel Delete a Model + automlTranslationModel.js create-model creates a new Model + automlTranslationModel.js get-operation-status Gets status of current operation + automlTranslationModel.js list-models list all Models + automlTranslationModel.js get-model Get a Model + automlTranslationModel.js list-model-evaluations List model evaluations + automlTranslationModel.js get-model-evaluation Get model evaluation + automlTranslationModel.js delete-model Delete a Model Options: --version Show version number [boolean] --computeRegion, -c region name e.g. "us-central1" [string] [default: "us-central1"] --datasetId, -i Id of the dataset [string] - --filter_, -f Name of the Dataset to search for [string] [default: ""] + --filter, -f Name of the Dataset to search for [string] [default: ""] --modelName, -m Name of the model [string] [default: false] --modelId, -a Id of the model [string] [default: ""] --modelEvaluationId, -e Id of the model evaluation [string] [default: ""] @@ -148,13 +148,13 @@ Options: --help Show help [boolean] Examples: - node automlTranslationModel.js createModel -i "DatasetID" -m "myModelName" - node automlTranslationModel.js getOperationStatus -i "datasetId" -o "OperationFullID" - node automlTranslationModel.js listModels -f "translationModelMetadata:*" - node automlTranslationModel.js getModel -a "ModelID" - node automlTranslationModel.js listModelEvaluations -a "ModelID" - node automlTranslationModel.js getModelEvaluation -a "ModelId" -e "ModelEvaluationID" - node automlTranslationModel.js deleteModel -a "ModelID" + node automlTranslationModel.js create-model -i "DatasetID" -m "myModelName" + node automlTranslationModel.js get-operation-status -i "datasetId" -o "OperationFullID" + node automlTranslationModel.js list-models -f "translationModelMetadata:*" + node automlTranslationModel.js get-model -a "ModelID" + node automlTranslationModel.js list-model-evaluations -a "ModelID" + node automlTranslationModel.js get-model-evaluation -a "ModelId" -e "ModelEvaluationID" + node automlTranslationModel.js delete-model -a "ModelID" For more information, see https://cloud.google.com/translate/docs ``` diff --git a/samples/automl/AutoML Translation Tutorial.docx b/samples/automl/AutoML Translation Tutorial.docx deleted file mode 100755 index 6a0ea603d857b3e9b23bc9ed82dd0c8ed6ce7981..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 22371 zcma&M1yo$ywyll3y99T4cXux=xCeI#?(XjHg}b}E6C4s;6Wqxod+&4Jx%dA6ZLfN@ zViv4LE17eSzP>(`<-j2@Kww~CK<=H+Qc!fQ7ED+I3ehl5bKUuQD!7wU+GtRN~8gT&G^51i|M|D%2;x?}42@U(qFcrGw^aXp|`sjfr_A zZ0|)%nkE8TqndAMOhD!FvUy9%yjSAMpuIe$F11*cig>y2lJ?7Z+GbZci3n@Uu1_xFv<6O zwtmK|H1igDnI&&&GKKUu4D7T8rvXl7meWhBTqpJj zK~t>sxVSNS-<150`aOAkb*D$q))r0b?iZXmb2Z0nB$xD&cixxTo}rcHpkaPicZ`67 zfq-;Cfq*Fg|4tvYe@!1dS6gEb}aFBN&1mB3)&*)m&LCEyx{vkx*d_#i_ZrfVliPA>Up? zbwpqTO9TQIMFC3;7)>?;8-Gegv;py}j9d^NCn7*xEI1*1&93r52Oejo6;06#KAbHO zYz6{Ql^;gxUx-bjG~ z>piI@?$WhHYCDP+Rebvi5+cuT;{~;FjCalRsC3jYKFow1Wf!q2K{zp(?jcAU5}0{E zIzlaIj(_0Pcde)yd}$Ie6Qr@k;=%=?vnI~tYm@*S#`zH@v6nGzG^UfwWf7hB0L3yq z|159>03w7K2@lM^k0_pXuV4r;-CXAv1Rc6+T+i}^27u>4wORp0k!vl;gQc5d_y==8 z&P2NekKn-3!0pS?gYlble62C}XPda*U$+5Y%56@Zc6i;@Rr2mhg-5m3?O&>0YV~Xm zqedBuREvL-fCWFV2qaZqfs}vYpBjrdN+^UV90Cc5*8~edb9Rv!R-E!6*M@Ps*T|A_ z*3V_v;4q6lTAp0v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information. console.log(`List of datasets:`); - for (let i of dataset) { - console.log(`Dataset name: ${i.name}`); - console.log(`Dataset id: ${i.name.split(`/`).pop(-1)}`); - console.log(`Dataset display name: ${i.displayName}`); - console.log(`Dataset example count: ${i.exampleCount}`); + datasets.forEach(dataset => { + console.log(`Dataset name: ${dataset.name}`); + console.log(`Dataset id: ${dataset.name.split(`/`).pop(-1)}`); + console.log(`Dataset display name: ${dataset.displayName}`); + console.log(`Dataset example count: ${dataset.exampleCount}`); console.log(`Translation dataset specification:`); console.log( `\tSource language code: ${ - i.translationDatasetMetadata.sourceLanguageCode + dataset.translationDatasetMetadata.sourceLanguageCode }` ); console.log( `\tTarget language code: ${ - i.translationDatasetMetadata.targetLanguageCode + dataset.translationDatasetMetadata.targetLanguageCode }` ); console.log(`Dataset create time:`); - console.log(`\tseconds: ${i.createTime.seconds}`); - console.log(`\tnanos: ${i.createTime.nanos}`); - } + console.log(`\tseconds: ${dataset.createTime.seconds}`); + console.log(`\tnanos: ${dataset.createTime.nanos}`); + }); }) .catch(err => { console.error(err); @@ -138,9 +138,9 @@ function listDatasets(projectId, computeRegion, filter_) { function getDataset(projectId, computeRegion, datasetId) { // [START automl_translation_get_dataset] - const automl = require(`@google-cloud/automl`); + const automl = require(`@google-cloud/automl`).v1beta1; - const client = new automl.v1beta1.AutoMlClient(); + const client = new automl.AutoMlClient(); /** * TODO(developer): Uncomment the following line before running the sample. @@ -186,9 +186,9 @@ function getDataset(projectId, computeRegion, datasetId) { function importData(projectId, computeRegion, datasetId, path) { // [START automl_translation_import_data] - const automl = require(`@google-cloud/automl`); + const automl = require(`@google-cloud/automl`).v1beta1; - const client = new automl.v1beta1.AutoMlClient(); + const client = new automl.AutoMlClient(); /** * TODO(developer): Uncomment the following line before running the sample. @@ -231,9 +231,9 @@ function importData(projectId, computeRegion, datasetId, path) { function deleteDataset(projectId, computeRegion, datasetId) { // [START automl_translation_delete_dataset] - const automl = require(`@google-cloud/automl`); + const automl = require(`@google-cloud/automl`).v1beta1; - const client = new automl.v1beta1.AutoMlClient(); + const client = new automl.AutoMlClient(); /** * TODO(developer): Uncomment the following line before running the sample. @@ -285,7 +285,7 @@ require(`yargs`) requiresArg: true, description: `Id of the dataset`, }, - filter_: { + filter: { alias: `f`, default: `translationDatasetMetadata:*`, type: `string`, @@ -344,24 +344,24 @@ require(`yargs`) opts.target ) ) - .command(`listDatasets`, `list all Datasets`, {}, opts => - listDatasets(opts.projectId, opts.computeRegion, opts.filter_) + .command(`list-datasets`, `list all Datasets`, {}, opts => + listDatasets(opts.projectId, opts.computeRegion, opts.filter) ) - .command(`getDataset`, `Get a Dataset`, {}, opts => + .command(`get-dataset`, `Get a Dataset`, {}, opts => getDataset(opts.projectId, opts.computeRegion, opts.datasetId) ) - .command(`deleteDataset`, `Delete a dataset`, {}, opts => + .command(`delete-dataset`, `Delete a dataset`, {}, opts => deleteDataset(opts.projectId, opts.computeRegion, opts.datasetId) ) - .command(`importData`, `Import labeled items into dataset`, {}, opts => + .command(`import-data`, `Import labeled items into dataset`, {}, opts => importData(opts.projectId, opts.computeRegion, opts.datasetId, opts.path) ) - .example(`node $0 createDataset -n "newDataSet" -s "en" -t "ja"`) - .example(`node $0 listDatasets -f "translationDatasetMetadata:*"`) - .example(`node $0 getDataset -i "DATASETID"`) - .example(`node $0 deleteDataset -i "DATASETID"`) + .example(`node $0 create-dataset -n "newDataSet" -s "en" -t "ja"`) + .example(`node $0 list-datasets -f "translationDatasetMetadata:*"`) + .example(`node $0 get-dataset -i "DATASETID"`) + .example(`node $0 delete-dataset -i "DATASETID"`) .example( - `node $0 importData -i "dataSetId" -p "gs://myproject/mytraindata.csv"` + `node $0 import-data -i "dataSetId" -p "gs://myproject/mytraindata.csv"` ) .wrap(120) .recommendCommands() diff --git a/samples/automl/automlTranslationModel.js b/samples/automl/automlTranslationModel.js index 6496c919..26fb83f7 100755 --- a/samples/automl/automlTranslationModel.js +++ b/samples/automl/automlTranslationModel.js @@ -25,9 +25,9 @@ function createModel(projectId, computeRegion, datasetId, modelName) { // [START automl_translation_create_model] - const automl = require(`@google-cloud/automl`); + const automl = require(`@google-cloud/automl`).v1beta1; - const client = new automl.v1beta1.AutoMlClient(); + const client = new automl.AutoMlClient(); /** * TODO(developer): Uncomment the following line before running the sample. @@ -85,44 +85,44 @@ function createModel(projectId, computeRegion, datasetId, modelName) { // [END automl_translation_create_model] } -function listModels(projectId, computeRegion, filter_) { +function listModels(projectId, computeRegion, filter) { // [START automl_translation_list_models] - const automl = require(`@google-cloud/automl`); + const automl = require(`@google-cloud/automl`).v1beta1; - const client = new automl.v1beta1.AutoMlClient(); + const client = new automl.AutoMlClient(); /** * TODO(developer): Uncomment the following line before running the sample. */ // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; // const computeRegion = `region-name, e.g. "us-central1"`; - // const filter_ = `filter expressions, must specify field, e.g. "translationDatasetMetadata:*”`; + // const filter = `filter expressions, must specify field, e.g. "translationDatasetMetadata:*”`; // A resource that represents Google Cloud Platform location. const projectLocation = client.locationPath(projectId, computeRegion); // List all the models available in the region by applying filter. client - .listModels({parent: projectLocation, filter: filter_}) + .listModels({parent: projectLocation, filter: filter}) .then(responses => { - const model = responses[0]; + const models = responses[0]; // Display the model information. console.log(`List of models:`); - for (let i of model) { - console.log(`Model name: ${i.name}`); - console.log(`Model id: ${i.name.split(`/`).pop(-1)}`); - console.log(`Model display name: ${i.displayName}`); - console.log(`Model dataset id: ${i.datasetId}`); + models.forEach(model => { + console.log(`Model name: ${model.name}`); + console.log(`Model id: ${model.name.split(`/`).pop(-1)}`); + console.log(`Model display name: ${model.displayName}`); + console.log(`Model dataset id: ${model.datasetId}`); console.log(`Model create time:`); - console.log(`\tseconds: ${i.createTime.seconds}`); - console.log(`\tnanos: ${i.createTime.nanos}`); + console.log(`\tseconds: ${model.createTime.seconds}`); + console.log(`\tnanos: ${model.createTime.nanos}`); console.log(`Model update time:`); - console.log(`\tseconds: ${i.updateTime.seconds}`); - console.log(`\tnanos: ${i.updateTime.nanos}`); - console.log(`Model deployment state: ${i.deploymentState}`); + console.log(`\tseconds: ${model.updateTime.seconds}`); + console.log(`\tnanos: ${model.updateTime.nanos}`); + console.log(`Model deployment state: ${model.deploymentState}`); console.log(`\n`); - } + }); }) .catch(err => { console.error(err); @@ -132,9 +132,9 @@ function listModels(projectId, computeRegion, filter_) { function getModel(projectId, computeRegion, modelId) { // [START automl_translation_get_model] - const automl = require(`@google-cloud/automl`); + const automl = require(`@google-cloud/automl`).v1beta1; - const client = new automl.v1beta1.AutoMlClient(); + const client = new automl.AutoMlClient(); /** * TODO(developer): Uncomment the following line before running the sample. @@ -211,11 +211,11 @@ function getModel(projectId, computeRegion, modelId) { // [END automl_translation_get_model] } -function listModelEvaluations(projectId, computeRegion, modelId, filter_) { +function listModelEvaluations(projectId, computeRegion, modelId, filter) { // [START automl_translation_list_model_evaluations] - const automl = require(`@google-cloud/automl`); + const automl = require(`@google-cloud/automl`).v1beta1; - const client = new automl.v1beta1.AutoMlClient(); + const client = new automl.AutoMlClient(); /** * TODO(developer): Uncomment the following line before running the sample. @@ -223,20 +223,20 @@ function listModelEvaluations(projectId, computeRegion, modelId, filter_) { // const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`; // const computeRegion = `region-name, e.g. "us-central1"`; // const modelId = `id of the model, e.g. “ICN12345”`; - // const filter_ = `filter expressions, must specify field, e.g. “imageClassificationModelMetadata:*”`; + // const filter = `filter expressions, must specify field, e.g. “imageClassificationModelMetadata:*”`; // Get the full path of the model. const modelFullId = client.modelPath(projectId, computeRegion, modelId); // List all the model evaluations in the model by applying filter. client - .listModelEvaluations({parent: modelFullId, filter: filter_}) + .listModelEvaluations({parent: modelFullId, filter: filter}) .then(responses => { - const element = responses[0]; + const elements = responses[0]; console.log(`List of model evaluations:`); - for (let i of element) { - console.log(i); - } + elements.forEach(element => { + console.log(element); + }); }) .catch(err => { console.error(err); @@ -286,9 +286,9 @@ function getModelEvaluation( function deleteModel(projectId, computeRegion, modelId) { // [START automl_translation_delete_model] - const automl = require(`@google-cloud/automl`); + const automl = require(`@google-cloud/automl`).v1beta1; - const client = new automl.v1beta1.AutoMlClient(); + const client = new automl.AutoMlClient(); /** * TODO(developer): Uncomment the following line before running the sample. @@ -319,9 +319,9 @@ function deleteModel(projectId, computeRegion, modelId) { function getOperationStatus(operationFullId) { // [START automl_translation_get_operation_status] - const automl = require(`@google-cloud/automl`); + const automl = require(`@google-cloud/automl`).v1beta1; - const client = new automl.v1beta1.AutoMlClient(); + const client = new automl.AutoMlClient(); /** * TODO(developer): Uncomment the following line before running the sample. @@ -352,7 +352,7 @@ require(`yargs`) requiresArg: true, description: `Id of the dataset`, }, - filter_: { + filter: { alias: `f`, default: ``, type: `string`, @@ -395,7 +395,7 @@ require(`yargs`) description: `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`, }, }) - .command(`createModel`, `creates a new Model`, {}, opts => + .command(`create-model`, `creates a new Model`, {}, opts => createModel( opts.projectId, opts.computeRegion, @@ -403,24 +403,27 @@ require(`yargs`) opts.modelName ) ) - .command(`getOperationStatus`, `Gets status of current operation`, {}, opts => - getOperationStatus(opts.operationFullId) + .command( + `get-operation-status`, + `Gets status of current operation`, + {}, + opts => getOperationStatus(opts.operationFullId) ) - .command(`listModels`, `list all Models`, {}, opts => - listModels(opts.projectId, opts.computeRegion, opts.filter_) + .command(`list-models`, `list all Models`, {}, opts => + listModels(opts.projectId, opts.computeRegion, opts.filter) ) - .command(`getModel`, `Get a Model`, {}, opts => + .command(`get-model`, `Get a Model`, {}, opts => getModel(opts.projectId, opts.computeRegion, opts.modelId) ) - .command(`listModelEvaluations`, `List model evaluations`, {}, opts => + .command(`list-model-evaluations`, `List model evaluations`, {}, opts => listModelEvaluations( opts.projectId, opts.computeRegion, opts.modelId, - opts.filter_ + opts.filter ) ) - .command(`getModelEvaluation`, `Get model evaluation`, {}, opts => + .command(`get-model-evaluation`, `Get model evaluation`, {}, opts => getModelEvaluation( opts.projectId, opts.computeRegion, @@ -428,16 +431,16 @@ require(`yargs`) opts.modelEvaluationId ) ) - .command(`deleteModel`, `Delete a Model`, {}, opts => + .command(`delete-model`, `Delete a Model`, {}, opts => deleteModel(opts.projectId, opts.computeRegion, opts.modelId) ) - .example(`node $0 createModel -i "DatasetID" -m "myModelName"`) - .example(`node $0 getOperationStatus -i "datasetId" -o "OperationFullID"`) - .example(`node $0 listModels -f "translationModelMetadata:*"`) - .example(`node $0 getModel -a "ModelID"`) - .example(`node $0 listModelEvaluations -a "ModelID"`) - .example(`node $0 getModelEvaluation -a "ModelId" -e "ModelEvaluationID"`) - .example(`node $0 deleteModel -a "ModelID"`) + .example(`node $0 create-model -i "DatasetID" -m "myModelName"`) + .example(`node $0 get-operation-status -i "datasetId" -o "OperationFullID"`) + .example(`node $0 list-models -f "translationModelMetadata:*"`) + .example(`node $0 get-model -a "ModelID"`) + .example(`node $0 list-model-evaluations -a "ModelID"`) + .example(`node $0 get-model-evaluation -a "ModelId" -e "ModelEvaluationID"`) + .example(`node $0 delete-model -a "ModelID"`) .wrap(120) .recommendCommands() .help() diff --git a/samples/automl/automlTranslationPredict.js b/samples/automl/automlTranslationPredict.js index f934f982..5a756967 100755 --- a/samples/automl/automlTranslationPredict.js +++ b/samples/automl/automlTranslationPredict.js @@ -31,11 +31,11 @@ function predict( translationAllowFallback ) { // [START automl_translation_predict] - const automl = require(`@google-cloud/automl`); + const automl = require(`@google-cloud/automl`).v1beta1; const fs = require(`fs`); // Create client for prediction service. - const client = new automl.v1beta1.PredictionServiceClient(); + const client = new automl.PredictionServiceClient(); /** * TODO(developer): Uncomment the following line before running the sample. diff --git a/samples/automl/package.json b/samples/automl/package.json new file mode 100644 index 00000000..b24d421a --- /dev/null +++ b/samples/automl/package.json @@ -0,0 +1,26 @@ +{ + "name": "automl", + "version": "1.0.0", + "description": "", + "main": "automlTranslationDataset.js", + "scripts": { + "test": "ava -T 1m --verbose system-test/*.test.js" + }, + "engines": { + "node": ">=8" + }, + "author": "", + "license": "ISC", + "dependencies": { + "@google-cloud/automl": "^0.1.1", + "@google-cloud/translate": "^1.1.0", + "yargs": "^12.0.1", + "mathjs": "^5.0.4" + }, + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "^2.3.0", + "ava": "^0.25.0", + "proxyquire": "^2.0.1", + "sinon": "^6.0.1" + } +} diff --git a/samples/automl/system-test/.eslintrc.yml b/samples/automl/system-test/.eslintrc.yml new file mode 100644 index 00000000..8b2fa88f --- /dev/null +++ b/samples/automl/system-test/.eslintrc.yml @@ -0,0 +1,5 @@ +--- +rules: + node/no-unpublished-require: off + node/no-unsupported-features: off + no-empty: off \ No newline at end of file diff --git a/samples/system-test/automlTranslation.test.js b/samples/automl/system-test/automlTranslation.test.js similarity index 71% rename from samples/system-test/automlTranslation.test.js rename to samples/automl/system-test/automlTranslation.test.js index d40400c9..08589dfa 100644 --- a/samples/system-test/automlTranslation.test.js +++ b/samples/automl/system-test/automlTranslation.test.js @@ -13,36 +13,31 @@ * limitations under the License. */ -/* eslint node/no-extraneous-require: off */ -/* eslint node/no-unsupported-features/es-syntax: off */ - 'use strict'; const test = require(`ava`); const tools = require(`@google-cloud/nodejs-repo-tools`); -const automl = `node ./automl`; -const cmdDataset = `${automl}/automlTranslationDataset.js`; -const cmdModel = `${automl}/automlTranslationModel.js`; -const cmdPredict = `${automl}/automlTranslationPredict.js`; +const cmdDataset = `node automlTranslationDataset.js`; +const cmdModel = `node automlTranslationModel.js`; +const cmdPredict = `node automlTranslationPredict.js`; const testDataSetName = `testDataSet`; const dummyDataSet = `dummyDataSet`; const testModelName = 'dummyModel'; -const sampleText = `./automl/resources/testInput.txt`; +const sampleText = `./resources/testInput.txt`; const donotdeleteModelId = `TRL188026453969732486`; -//const donotdeleteDatasetId = `TRL2551826603472450019`; // Skipped because it's been taking too long to delete datasets test.skip(`It should create a create, list, and delete a dataset`, async t => { // Check to see that this dataset does not yet exist - let output = await tools.runAsync(`${cmdDataset} listDatasets`); + let output = await tools.runAsync(`${cmdDataset} list-datasets`); t.false(output.includes(testDataSetName)); // Create dataset output = await tools.runAsync( - `${cmdDataset} createDataset -n "${testDataSetName}"` + `${cmdDataset} create-dataset -n "${testDataSetName}"` ); const dataSetId = output .split(`\n`)[1] @@ -52,7 +47,7 @@ test.skip(`It should create a create, list, and delete a dataset`, async t => { // Delete dataset output = await tools.runAsync( - `${cmdDataset} deleteDataset -i "${dataSetId}"` + `${cmdDataset} delete-dataset -i "${dataSetId}"` ); t.true(output.includes(`Dataset deleted.`)); }); @@ -60,12 +55,12 @@ test.skip(`It should create a create, list, and delete a dataset`, async t => { // We make two models running this test, see hard-coded workaround below test.skip(`It should create a dataset, import data, and start making a model`, async t => { // Check to see that this dataset does not yet exist - let output = await tools.runAsync(`${cmdDataset} listDatasets`); + let output = await tools.runAsync(`${cmdDataset} list-datasets`); t.false(output.includes(dummyDataSet)); // Create dataset output = await tools.runAsync( - `${cmdDataset} createDataset -n "${dummyDataSet}"` + `${cmdDataset} create-dataset -n "${dummyDataSet}"` ); const dataSetId = output .split(`\n`)[1] @@ -75,17 +70,17 @@ test.skip(`It should create a dataset, import data, and start making a model`, a // Import Data output = await tools.runAsync( - `${cmdDataset} importData -i "${dataSetId}" -p "gs://nodejs-docs-samples-vcm/flowerTraindata20lines.csv"` + `${cmdDataset} import-data -i "${dataSetId}" -p "gs://nodejs-docs-samples-vcm/flowerTraindata20lines.csv"` ); t.true(output.includes(`Data imported.`)); // Check to make sure model doesn't already exist - output = await tools.runAsync(`${cmdModel} listModels`); + output = await tools.runAsync(`${cmdModel} list-models`); t.false(output.includes(`${testModelName}`)); // Begin training dataset, getting operation ID for next operation output = await tools.runAsync( - `${cmdModel} createModel -i "${dataSetId}" -m "${testModelName}" -t "2"` + `${cmdModel} create-model -i "${dataSetId}" -m "${testModelName}" -t "2"` ); const operationName = output .split(`\n`)[0] @@ -95,37 +90,37 @@ test.skip(`It should create a dataset, import data, and start making a model`, a // Poll operation status, here confirming that operation is not complete yet output = await tools.runAsync( - `${cmdModel} getOperationStatus -i "${dataSetId}" -o "${operationName}"` + `${cmdModel} get-operation-status -i "${dataSetId}" -o "${operationName}"` ); t.true(output.includes(`done: false`)); }); test(`It should run get model (from a prexisting model)`, async t => { // Confirm dataset exists - let output = await tools.runAsync(`${cmdDataset} listDatasets`); + let output = await tools.runAsync(`${cmdDataset} list-datasets`); t.true(output.includes(`me_do_not_delete`)); // List model evaluations, confirm model exists output = await tools.runAsync( - `${cmdModel} listModelEvaluations -a "${donotdeleteModelId}"` + `${cmdModel} list-model-evaluations -a "${donotdeleteModelId}"` ); t.true(output.includes(`translationEvaluationMetrics:`)); // Get model evaluation output = await tools.runAsync( - `${cmdModel} getModel -a "${donotdeleteModelId}"` + `${cmdModel} get-model -a "${donotdeleteModelId}"` ); t.true(output.includes(`Model deployment state: DEPLOYED`)); }); test(`It should run Prediction from prexisting model`, async t => { // Confirm dataset exists - let output = await tools.runAsync(`${cmdDataset} listDatasets`); + let output = await tools.runAsync(`${cmdDataset} list-datasets`); t.true(output.includes(`me_do_not_delete`)); // List model evaluations, confirm model exists output = await tools.runAsync( - `${cmdModel} listModelEvaluations -a "${donotdeleteModelId}"` + `${cmdModel} list-model-evaluations -a "${donotdeleteModelId}"` ); t.true(output.includes(`translationEvaluationMetrics:`)); @@ -140,6 +135,6 @@ test(`It should run Prediction from prexisting model`, async t => { // List datasets test(`should list datasets`, async t => { - const output = await tools.runAsync(`${cmdDataset} listDatasets`); + const output = await tools.runAsync(`${cmdDataset} list-datasets`); t.true(output.includes(`List of datasets:`)); }); From a9e7fbd2be33899a0ee9e81213cea470d50ed6a2 Mon Sep 17 00:00:00 2001 From: nirupa-kumar Date: Wed, 26 Sep 2018 11:48:41 -0700 Subject: [PATCH 09/10] fixing lint issues --- samples/automl/automlTranslationModel.js | 2 +- samples/automl/automlTranslationPredict.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/automl/automlTranslationModel.js b/samples/automl/automlTranslationModel.js index 26fb83f7..09caec34 100755 --- a/samples/automl/automlTranslationModel.js +++ b/samples/automl/automlTranslationModel.js @@ -63,7 +63,7 @@ function createModel(projectId, computeRegion, datasetId, modelName) { const model = responses[0]; console.log(model); // Retrieve deployment state. - var deploymentState = ``; + let deploymentState = ``; if (model.deploymentState === 1) { deploymentState = `deployed`; } else if (model.deploymentState === 2) { diff --git a/samples/automl/automlTranslationPredict.js b/samples/automl/automlTranslationPredict.js index 5a756967..366660be 100755 --- a/samples/automl/automlTranslationPredict.js +++ b/samples/automl/automlTranslationPredict.js @@ -61,7 +61,7 @@ function predict( // Params is additional domain-specific parameters. // TranslationAllowFallback allows to use Google translation model. - var params = {}; + let params = {}; if (translationAllowFallback) { params = { translationAllowFallback: true, From 4e89c73f0b4ff436d2395a756fa7e4b29c6000bf Mon Sep 17 00:00:00 2001 From: nirupa-kumar Date: Wed, 26 Sep 2018 13:07:06 -0700 Subject: [PATCH 10/10] re-trigger tests --- samples/automl/system-test/automlTranslation.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/automl/system-test/automlTranslation.test.js b/samples/automl/system-test/automlTranslation.test.js index 08589dfa..931f6a5a 100644 --- a/samples/automl/system-test/automlTranslation.test.js +++ b/samples/automl/system-test/automlTranslation.test.js @@ -30,7 +30,7 @@ const sampleText = `./resources/testInput.txt`; const donotdeleteModelId = `TRL188026453969732486`; // Skipped because it's been taking too long to delete datasets -test.skip(`It should create a create, list, and delete a dataset`, async t => { +test.skip(`should create a create, list, and delete a dataset`, async t => { // Check to see that this dataset does not yet exist let output = await tools.runAsync(`${cmdDataset} list-datasets`); t.false(output.includes(testDataSetName)); @@ -53,7 +53,7 @@ test.skip(`It should create a create, list, and delete a dataset`, async t => { }); // We make two models running this test, see hard-coded workaround below -test.skip(`It should create a dataset, import data, and start making a model`, async t => { +test.skip(`should create a dataset, import data, and start making a model`, async t => { // Check to see that this dataset does not yet exist let output = await tools.runAsync(`${cmdDataset} list-datasets`); t.false(output.includes(dummyDataSet)); @@ -95,7 +95,7 @@ test.skip(`It should create a dataset, import data, and start making a model`, a t.true(output.includes(`done: false`)); }); -test(`It should run get model (from a prexisting model)`, async t => { +test(`should run get model (from a prexisting model)`, async t => { // Confirm dataset exists let output = await tools.runAsync(`${cmdDataset} list-datasets`); t.true(output.includes(`me_do_not_delete`)); @@ -113,7 +113,7 @@ test(`It should run get model (from a prexisting model)`, async t => { t.true(output.includes(`Model deployment state: DEPLOYED`)); }); -test(`It should run Prediction from prexisting model`, async t => { +test(`should run Prediction from prexisting model`, async t => { // Confirm dataset exists let output = await tools.runAsync(`${cmdDataset} list-datasets`); t.true(output.includes(`me_do_not_delete`));