From 099dc35f04a6ee9d97351e5b8ffe3dcb93887c2a Mon Sep 17 00:00:00 2001 From: Angel Caamal Date: Fri, 23 Oct 2026 17:49:56 +0000 Subject: [PATCH] chore: decommission and remove automl samples folder --- automl/.eslintrc.yml | 3 - automl/package.json | 29 ----- automl/test/.eslintrc.yml | 3 - automl/test/batch_predict.test.js | 50 -------- automl/test/delete_dataset.test.js | 61 ---------- automl/test/delete_model.test.js | 45 ------- automl/test/deploy_model.test.js | 41 ------- automl/test/export_dataset.test.js | 64 ---------- automl/test/get_dataset.test.js | 40 ------ automl/test/get_model.test.js | 40 ------ automl/test/get_model_evaluation.test.js | 40 ------ automl/test/get_operation_status.test.js | 40 ------ automl/test/import_dataset.test.js | 115 ------------------ ...e_entity_extraction_create_dataset.test.js | 54 -------- ...age_entity_extraction_create_model.test.js | 43 ------- ...language_entity_extraction_predict.test.js | 61 ---------- ..._sentiment_analysis_create_dataset.test.js | 54 -------- ...ge_sentiment_analysis_create_model.test.js | 41 ------- ...anguage_sentiment_analysis_predict.test.js | 60 --------- ...text_classification_create_dataset.test.js | 54 -------- ...e_text_classification_create_model.test.js | 38 ------ ...nguage_text_classification_predict.test.js | 60 --------- automl/test/list_datasets.test.js | 39 ------ automl/test/list_model_evaluations.test.js | 40 ------ automl/test/list_models.test.js | 40 ------ automl/test/list_operation_status.test.js | 39 ------ automl/test/setEndpoint.test.js | 30 ----- automl/test/translate_create_dataset.test.js | 54 -------- automl/test/translate_create_model.test.js | 45 ------- automl/test/translate_predict.test.js | 40 ------ automl/test/undeploy_model.test.js | 41 ------- automl/test/util.js | 28 ----- ...sion_classification_create_dataset.test.js | 54 -------- ...vision_classification_create_model.test.js | 41 ------- ...sification_deploy_model_node_count.test.js | 42 ------- .../vision_classification_predict.test.js | 60 --------- ...on_object_detection_create_dataset.test.js | 54 -------- ...sion_object_detection_create_model.test.js | 41 ------- ..._detection_deploy_model_node_count.test.js | 42 ------- .../vision_object_detection_predict.test.js | 64 ---------- 40 files changed, 1830 deletions(-) delete mode 100644 automl/.eslintrc.yml delete mode 100644 automl/package.json delete mode 100644 automl/test/.eslintrc.yml delete mode 100644 automl/test/batch_predict.test.js delete mode 100644 automl/test/delete_dataset.test.js delete mode 100644 automl/test/delete_model.test.js delete mode 100644 automl/test/deploy_model.test.js delete mode 100644 automl/test/export_dataset.test.js delete mode 100644 automl/test/get_dataset.test.js delete mode 100644 automl/test/get_model.test.js delete mode 100644 automl/test/get_model_evaluation.test.js delete mode 100644 automl/test/get_operation_status.test.js delete mode 100644 automl/test/import_dataset.test.js delete mode 100644 automl/test/language_entity_extraction_create_dataset.test.js delete mode 100644 automl/test/language_entity_extraction_create_model.test.js delete mode 100644 automl/test/language_entity_extraction_predict.test.js delete mode 100644 automl/test/language_sentiment_analysis_create_dataset.test.js delete mode 100644 automl/test/language_sentiment_analysis_create_model.test.js delete mode 100644 automl/test/language_sentiment_analysis_predict.test.js delete mode 100644 automl/test/language_text_classification_create_dataset.test.js delete mode 100644 automl/test/language_text_classification_create_model.test.js delete mode 100644 automl/test/language_text_classification_predict.test.js delete mode 100644 automl/test/list_datasets.test.js delete mode 100644 automl/test/list_model_evaluations.test.js delete mode 100644 automl/test/list_models.test.js delete mode 100644 automl/test/list_operation_status.test.js delete mode 100644 automl/test/setEndpoint.test.js delete mode 100644 automl/test/translate_create_dataset.test.js delete mode 100644 automl/test/translate_create_model.test.js delete mode 100644 automl/test/translate_predict.test.js delete mode 100644 automl/test/undeploy_model.test.js delete mode 100644 automl/test/util.js delete mode 100644 automl/test/vision_classification_create_dataset.test.js delete mode 100644 automl/test/vision_classification_create_model.test.js delete mode 100644 automl/test/vision_classification_deploy_model_node_count.test.js delete mode 100644 automl/test/vision_classification_predict.test.js delete mode 100644 automl/test/vision_object_detection_create_dataset.test.js delete mode 100644 automl/test/vision_object_detection_create_model.test.js delete mode 100644 automl/test/vision_object_detection_deploy_model_node_count.test.js delete mode 100644 automl/test/vision_object_detection_predict.test.js diff --git a/automl/.eslintrc.yml b/automl/.eslintrc.yml deleted file mode 100644 index 282535f55f6..00000000000 --- a/automl/.eslintrc.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -rules: - no-console: off diff --git a/automl/package.json b/automl/package.json deleted file mode 100644 index f865c3a8feb..00000000000 --- a/automl/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@google-cloud/automl-samples", - "description": "Samples for the Cloud AutoML Client Library for Node.js.", - "license": "Apache-2.0", - "author": "Google LLC", - "engines": { - "node": ">=16.0.0" - }, - "repository": "googleapis/nodejs-automl", - "private": true, - "scripts": { - "test": "c8 mocha -p -j 2 --timeout 9000000" - }, - "files": [ - "**/*.js", - "!test/" - ], - "dependencies": { - "@google-cloud/automl": "^4.0.0", - "mathjs": "^13.0.0" - }, - "devDependencies": { - "@google-cloud/storage": "^7.0.0", - "c8": "^10.0.0", - "chai": "^4.5.0", - "mocha": "^10.0.0", - "uuid": "^11.1.1" - } -} diff --git a/automl/test/.eslintrc.yml b/automl/test/.eslintrc.yml deleted file mode 100644 index fccd877b3e3..00000000000 --- a/automl/test/.eslintrc.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -rules: - no-warning-comments: off diff --git a/automl/test/batch_predict.test.js b/automl/test/batch_predict.test.js deleted file mode 100644 index 6b666054990..00000000000 --- a/automl/test/batch_predict.test.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const BATCH_PREDICT_REGION_TAG = 'batch_predict'; -const LOCATION = 'us-central1'; -const MODEL_ID = 'TEN0000000000000000000'; - -describe('Automl Batch Predict Test', () => { - const client = new AutoMlClient(); - - it('should batch predict', async () => { - // As batch prediction can take a long time, instead try to batch predict - // on a nonexistent model and confirm that the model was not found, but - // other elements of the request were valid. - const projectId = await client.getProjectId(); - const inputUri = `gs://${projectId}-lcm/entity_extraction/input.jsonl`; - const outputUri = `gs://${projectId}-lcm/TEST_BATCH_PREDICT/`; - - const args = [ - BATCH_PREDICT_REGION_TAG, - projectId, - LOCATION, - MODEL_ID, - inputUri, - outputUri, - ]; - const output = cp.spawnSync('node', args, {encoding: 'utf8'}); - - assert.match(output.stderr, /does not exist/); - }); -}); diff --git a/automl/test/delete_dataset.test.js b/automl/test/delete_dataset.test.js deleted file mode 100644 index 5a035c36f0f..00000000000 --- a/automl/test/delete_dataset.test.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2019 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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it, before} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const DELETE_DATASET_REGION_TAG = 'delete_dataset'; -const LOCATION = 'us-central1'; - -describe('Automl Translate Delete Dataset Tests', () => { - const client = new AutoMlClient(); - let datasetId; - - before('should create a dataset', async () => { - const projectId = await client.getProjectId(); - const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`; - const request = { - parent: client.locationPath(projectId, LOCATION), - dataset: { - displayName: displayName, - translationDatasetMetadata: { - sourceLanguageCode: 'en', - targetLanguageCode: 'ja', - }, - }, - }; - const [operation] = await client.createDataset(request); - const [response] = await operation.promise(); - datasetId = response.name - .split('/') - [response.name.split('/').length - 1].split('\n')[0]; - }); - - it('should delete a dataset', async () => { - const projectId = await client.getProjectId(); - // delete - const delete_output = execSync( - `node ${DELETE_DATASET_REGION_TAG}.js ${projectId} ${LOCATION} ${datasetId}` - ); - assert.match(delete_output, /Dataset deleted/); - }); -}); diff --git a/automl/test/delete_model.test.js b/automl/test/delete_model.test.js deleted file mode 100644 index 72fac7f66e5..00000000000 --- a/automl/test/delete_model.test.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const DELETE_MODEL_REGION_TAG = 'delete_model.js'; -const LOCATION = 'us-central1'; - -describe('Automl Delete Model Tests', () => { - const client = new AutoMlClient(); - - it('should delete a model', async () => { - // As model creation can take many hours, instead try to delete a - // nonexistent model and confirm that the model was not found, but other - // elements of the request were valid. - const projectId = await client.getProjectId(); - const args = [ - DELETE_MODEL_REGION_TAG, - projectId, - LOCATION, - 'TRL0000000000000000000', - ]; - const output = cp.spawnSync('node', args, {encoding: 'utf8'}); - - assert.match(output.stderr, /NOT_FOUND/); - assert.match(output.stderr, /The model does not exist./); - }); -}); diff --git a/automl/test/deploy_model.test.js b/automl/test/deploy_model.test.js deleted file mode 100644 index 561a13a2fe8..00000000000 --- a/automl/test/deploy_model.test.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const DEPLOY_MODEL_REGION_TAG = 'deploy_model.js'; -const LOCATION = 'us-central1'; -const MODEL_ID = 'TEN0000000000000000000'; - -describe('Automl Deploy Model Test', () => { - const client = new AutoMlClient(); - - it('should deploy a model', async () => { - // As model deployment can take a long time, instead try to deploy a - // nonexistent model and confirm that the model was not found, but other - // elements of the request were valid. - const projectId = await client.getProjectId(); - const args = [DEPLOY_MODEL_REGION_TAG, projectId, LOCATION, MODEL_ID]; - const output = cp.spawnSync('node', args, {encoding: 'utf8'}); - - assert.match(output.stderr, /NOT_FOUND/); - assert.match(output.stderr, /The model does not exist./); - }); -}); diff --git a/automl/test/export_dataset.test.js b/automl/test/export_dataset.test.js deleted file mode 100644 index 64963844ab8..00000000000 --- a/automl/test/export_dataset.test.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2019 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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it, after} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; -const {Storage} = require('@google-cloud/storage'); - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const DATASET_ID = 'TRL8522556519449886720'; -const EXPORT_DATASET_REGION_TAG = 'export_dataset'; -const LOCATION = 'us-central1'; - -const {delay} = require('./util'); - -describe('Automl Translate Dataset Tests', () => { - const client = new AutoMlClient(); - const prefix = 'TEST_EXPORT_OUTPUT'; - - it('should export a datset', async function () { - this.retries(4); - await delay(this.test); - const projectId = await client.getProjectId(); - const bucketName = `${projectId}-automl-translate`; - const export_output = execSync( - `node ${EXPORT_DATASET_REGION_TAG}.js ${projectId} ${LOCATION} ${DATASET_ID} gs://${bucketName}/${prefix}/` - ); - - assert.match(export_output, /Dataset exported/); - }); - - after('delete created files', async () => { - const projectId = await client.getProjectId(); - const bucketName = `${projectId}-automl-translate`; - - const storageClient = new Storage(); - const options = { - prefix: prefix, - }; - const [files] = await storageClient - .bucket(`gs://${bucketName}`) - .getFiles(options); - - for (const file of files) { - await storageClient.bucket(`gs://${bucketName}`).file(file.name).delete(); - } - }); -}); diff --git a/automl/test/get_dataset.test.js b/automl/test/get_dataset.test.js deleted file mode 100644 index 974ca10cee0..00000000000 --- a/automl/test/get_dataset.test.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2019 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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const GET_DATASET_REGION_TAG = 'get_dataset'; -const DATASET_ID = 'TRL8522556519449886720'; -const LOCATION = 'us-central1'; - -describe('Automl Get Dataset Tests', () => { - const client = new AutoMlClient(); - - it('should get a dataset', async () => { - const projectId = await client.getProjectId(); - const get_output = execSync( - `node ${GET_DATASET_REGION_TAG}.js ${projectId} ${LOCATION} ${DATASET_ID}` - ); - - assert.match(get_output, /Dataset id/); - }); -}); diff --git a/automl/test/get_model.test.js b/automl/test/get_model.test.js deleted file mode 100644 index f014f3fd973..00000000000 --- a/automl/test/get_model.test.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const GET_MODEL_REGION_TAG = 'get_model'; -const LOCATION = 'us-central1'; -const MODEL_ID = 'TRL1218052175389786112'; - -describe('Automl Get Model Tests', () => { - const client = new AutoMlClient(); - - it('should get a model', async () => { - const projectId = await client.getProjectId(); - - const get_model_output = execSync( - `node ${GET_MODEL_REGION_TAG}.js ${projectId} ${LOCATION} ${MODEL_ID}` - ); - assert.match(get_model_output, /Model id/); - }); -}); diff --git a/automl/test/get_model_evaluation.test.js b/automl/test/get_model_evaluation.test.js deleted file mode 100644 index 9ea43af9456..00000000000 --- a/automl/test/get_model_evaluation.test.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const GET_MODEL_EVALUATION_REGION_TAG = 'get_model_evaluation'; -const LOCATION = 'us-central1'; -const MODEL_ID = 'TRL1218052175389786112'; -const MODEL_EVALUATION_ID = '6800627877826816909'; - -describe('Automl Translate Model Tests', () => { - const client = new AutoMlClient(); - - it('should get model evaluations', async () => { - const projectId = await client.getProjectId(); - const get_model_eval_output = execSync( - `node ${GET_MODEL_EVALUATION_REGION_TAG}.js ${projectId} ${LOCATION} ${MODEL_ID} ${MODEL_EVALUATION_ID}` - ); - assert.match(get_model_eval_output, /Model evaluation name/); - }); -}); diff --git a/automl/test/get_operation_status.test.js b/automl/test/get_operation_status.test.js deleted file mode 100644 index c58e1881412..00000000000 --- a/automl/test/get_operation_status.test.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const GET_OPERATION_STATUS_REGION_TAG = 'get_operation_status'; -const LOCATION = 'us-central1'; -const OPERATION_ID = 'TRL5980949629938696192'; - -describe('Automl Get Operation Status Tests', () => { - const client = new AutoMlClient(); - - it('should get operation status', async () => { - const projectId = await client.getProjectId(); - - const get_output = execSync( - `node ${GET_OPERATION_STATUS_REGION_TAG}.js ${projectId} ${LOCATION} ${OPERATION_ID}` - ); - assert.match(get_output, /Operation details/); - }); -}); diff --git a/automl/test/import_dataset.test.js b/automl/test/import_dataset.test.js deleted file mode 100644 index afbb0fbe68d..00000000000 --- a/automl/test/import_dataset.test.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2019 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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it, before} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const IMPORT_DATASET_REGION_TAG = 'import_dataset'; -const LOCATION = 'us-central1'; -const TWENTY_MINUTES_IN_SECONDS = 60 * 20; -const {delay} = require('./util'); - -describe('Automl Import Dataset Test', () => { - const client = new AutoMlClient(); - let datasetId; - - before(async () => { - await cleanupOldDatasets(); - }); - - async function cleanupOldDatasets() { - const projectId = await client.getProjectId(); - let request = { - parent: client.locationPath(projectId, LOCATION), - filter: 'translation_dataset_metadata:*', - }; - const [response] = await client.listDatasets(request); - for (const dataset of response) { - try { - const id = dataset.name - .split('/') - [dataset.name.split('/').length - 1].split('\n')[0]; - console.info(`checking dataset ${id}`); - if (id.match(/test_[0-9a-f]{8}/)) { - console.info(`deleting dataset ${id}`); - if ( - dataset.createTime.seconds - Date.now() / 1000 > - TWENTY_MINUTES_IN_SECONDS - ) { - console.info(`dataset ${id} is greater than 20 minutes old`); - request = { - name: client.datasetPath(projectId, LOCATION, id), - }; - const [operation] = await client.deleteDataset(request); - await operation.promise(); - } - } - } catch (err) { - console.warn(err); - } - } - } - - it('should create a dataset', async function () { - this.retries(5); - await delay(this.test); - const projectId = await client.getProjectId(); - const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`; - const request = { - parent: client.locationPath(projectId, LOCATION), - dataset: { - displayName: displayName, - translationDatasetMetadata: { - sourceLanguageCode: 'en', - targetLanguageCode: 'ja', - }, - }, - }; - const [operation] = await client.createDataset(request); - const [response] = await operation.promise(); - datasetId = response.name - .split('/') - [response.name.split('/').length - 1].split('\n')[0]; - }); - - it('should import dataset', async function () { - this.retries(5); - await delay(this.test); - const projectId = await client.getProjectId(); - const data = `gs://${projectId}-automl-translate/en-ja-short.csv`; - const import_output = execSync( - `node ${IMPORT_DATASET_REGION_TAG}.js ${projectId} ${LOCATION} ${datasetId} ${data}` - ); - assert.match(import_output, /Dataset imported/); - }); - - it('should delete created dataset', async function () { - this.retries(5); - await delay(this.test); - const projectId = await client.getProjectId(); - const request = { - name: client.datasetPath(projectId, LOCATION, datasetId), - }; - const [operation] = await client.deleteDataset(request); - await operation.promise(); - }); -}); diff --git a/automl/test/language_entity_extraction_create_dataset.test.js b/automl/test/language_entity_extraction_create_dataset.test.js deleted file mode 100644 index ed5dcd8e9c7..00000000000 --- a/automl/test/language_entity_extraction_create_dataset.test.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2019 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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it, after} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const CREATE_DATASET_REGION_TAG = 'language_entity_extraction_create_dataset'; -const LOCATION = 'us-central1'; - -describe('Automl Natural Language Entity Extraction Create Dataset Test', () => { - const client = new AutoMlClient(); - let datasetId; - - it('should create a dataset', async () => { - const projectId = await client.getProjectId(); - const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`; - - // create - const create_output = execSync( - `node ${CREATE_DATASET_REGION_TAG}.js ${projectId} ${LOCATION} ${displayName}` - ); - assert.match(create_output, /Dataset id:/); - - datasetId = create_output.split('Dataset id: ')[1].split('\n')[0]; - }); - - after('delete created dataset', async () => { - const projectId = await client.getProjectId(); - const request = { - name: client.datasetPath(projectId, LOCATION, datasetId), - }; - const [operation] = await client.deleteDataset(request); - await operation.promise(); - }); -}); diff --git a/automl/test/language_entity_extraction_create_model.test.js b/automl/test/language_entity_extraction_create_model.test.js deleted file mode 100644 index 5584816fd20..00000000000 --- a/automl/test/language_entity_extraction_create_model.test.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2019 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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const CREATE_MODEL_REGION_TAG = 'language_entity_extraction_create_model.js'; -const LOCATION = 'us-central1'; -const DATASET_ID = 'TEN0000000000000000000'; - -describe('Automl Natural Language Entity Extraction Create Model Test', () => { - const client = new AutoMlClient(); - // let operationId; - - // Natural language entity extraction models are non cancellable operations - it('should create a model', async () => { - // As entity extraction does not let you cancel model creation, instead try - // to create a model from a nonexistent dataset, but other elements of the - // request were valid. - const projectId = await client.getProjectId(); - const args = [CREATE_MODEL_REGION_TAG, projectId, LOCATION, DATASET_ID]; - const output = cp.spawnSync('node', args, {encoding: 'utf8'}); - - assert.match(output.stderr, /NOT_FOUND/); - assert.match(output.stderr, /Dataset does not exist./); - }); -}); diff --git a/automl/test/language_entity_extraction_predict.test.js b/automl/test/language_entity_extraction_predict.test.js deleted file mode 100644 index 500bf8ef83d..00000000000 --- a/automl/test/language_entity_extraction_predict.test.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2019 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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it, before} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const PREDICT_REGION_TAG = 'language_entity_extraction_predict'; -const LOCATION = 'us-central1'; -const MODEL_ID = 'TEN2238627664384491520'; - -describe('Automl Natural Language Entity Extraction Predict Test', () => { - const client = new AutoMlClient(); - - before('should verify the model is deployed', async () => { - const projectId = await client.getProjectId(); - const request = { - name: client.modelPath(projectId, LOCATION, MODEL_ID), - }; - - const [response] = await client.getModel(request); - if (response.deploymentState === 'UNDEPLOYED') { - const request = { - name: client.modelPath(projectId, LOCATION, MODEL_ID), - }; - - const [operation] = await client.deployModel(request); - - // Wait for operation to complete. - await operation.promise(); - } - }); - - it('should predict', async () => { - const projectId = await client.getProjectId(); - const content = - "'Constitutional mutations in the WT1 gene in patients with Denys-Drash syndrome.'"; - - const predictOutput = execSync( - `node ${PREDICT_REGION_TAG}.js ${projectId} ${LOCATION} ${MODEL_ID} ${content}` - ); - assert.match(predictOutput, /Text Extract Entity Types/); - }); -}); diff --git a/automl/test/language_sentiment_analysis_create_dataset.test.js b/automl/test/language_sentiment_analysis_create_dataset.test.js deleted file mode 100644 index d0e8ccd2629..00000000000 --- a/automl/test/language_sentiment_analysis_create_dataset.test.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it, after} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const CREATE_DATASET_REGION_TAG = 'language_sentiment_analysis_create_dataset'; -const LOCATION = 'us-central1'; - -describe('Automl Natural Language Sentiment Analysis Create Dataset Test', () => { - const client = new AutoMlClient(); - let datasetId; - - it('should create a dataset', async () => { - const projectId = await client.getProjectId(); - const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`; - - // create - const create_output = execSync( - `node ${CREATE_DATASET_REGION_TAG}.js ${projectId} ${LOCATION} ${displayName}` - ); - assert.match(create_output, /Dataset id:/); - - datasetId = create_output.split('Dataset id: ')[1].split('\n')[0]; - }); - - after('delete created dataset', async () => { - const projectId = await client.getProjectId(); - const request = { - name: client.datasetPath(projectId, LOCATION, datasetId), - }; - const [operation] = await client.deleteDataset(request); - await operation.promise(); - }); -}); diff --git a/automl/test/language_sentiment_analysis_create_model.test.js b/automl/test/language_sentiment_analysis_create_model.test.js deleted file mode 100644 index 39994297c5e..00000000000 --- a/automl/test/language_sentiment_analysis_create_model.test.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const CREATE_MODEL_REGION_TAG = 'language_sentiment_analysis_create_model'; -const LOCATION = 'us-central1'; -const DATASET_ID = 'TST00000000000000000'; - -describe('Automl Natural Language Sentiment Analysis Create Model Test', () => { - const client = new AutoMlClient(); - - it('should create a model', async () => { - // As sentimental analysis does not let you cancel model creation, instead try - // to create a model from a nonexistent dataset, but other elements of the - // request were valid. - const projectId = await client.getProjectId(); - const args = [CREATE_MODEL_REGION_TAG, projectId, LOCATION, DATASET_ID]; - const output = cp.spawnSync('node', args, {encoding: 'utf8'}); - - assert.match(output.stderr, /NOT_FOUND/); - assert.match(output.stderr, /does not exist/); - }); -}); diff --git a/automl/test/language_sentiment_analysis_predict.test.js b/automl/test/language_sentiment_analysis_predict.test.js deleted file mode 100644 index e6748ee28cf..00000000000 --- a/automl/test/language_sentiment_analysis_predict.test.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it, before} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const PREDICT_REGION_TAG = 'language_sentiment_analysis_predict'; -const LOCATION = 'us-central1'; -const MODEL_ID = 'TST3171435737203605504'; - -describe('Automl Natural Language Sentiment Analysis Predict Test', () => { - const client = new AutoMlClient(); - - before('should verify the model is deployed', async () => { - const projectId = await client.getProjectId(); - const request = { - name: client.modelPath(projectId, LOCATION, MODEL_ID), - }; - - const [response] = await client.getModel(request); - if (response.deploymentState === 'UNDEPLOYED') { - const request = { - name: client.modelPath(projectId, LOCATION, MODEL_ID), - }; - - const [operation] = await client.deployModel(request); - - // Wait for operation to complete. - await operation.promise(); - } - }); - - it('should predict', async () => { - const projectId = await client.getProjectId(); - const content = "'Hopefully this Claritin kicks in soon'"; - - const predictOutput = execSync( - `node ${PREDICT_REGION_TAG}.js ${projectId} ${LOCATION} ${MODEL_ID} ${content}` - ); - assert.match(predictOutput, /Predicted sentiment score/); - }); -}); diff --git a/automl/test/language_text_classification_create_dataset.test.js b/automl/test/language_text_classification_create_dataset.test.js deleted file mode 100644 index f913d91bba3..00000000000 --- a/automl/test/language_text_classification_create_dataset.test.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {after, describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const CREATE_DATASET_REGION_TAG = 'language_text_classification_create_dataset'; -const LOCATION = 'us-central1'; - -describe('Automl Natural Language Text Classification Create Dataset Test', () => { - const client = new AutoMlClient(); - let datasetId; - - it('should create a dataset', async () => { - const projectId = await client.getProjectId(); - const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`; - - // create - const create_output = execSync( - `node ${CREATE_DATASET_REGION_TAG}.js ${projectId} ${LOCATION} ${displayName}` - ); - assert.match(create_output, /Dataset id:/); - - datasetId = create_output.split('Dataset id: ')[1].split('\n')[0]; - }); - - after('delete created dataset', async () => { - const projectId = await client.getProjectId(); - const request = { - name: client.datasetPath(projectId, LOCATION, datasetId), - }; - const [operation] = await client.deleteDataset(request); - await operation.promise(); - }); -}); diff --git a/automl/test/language_text_classification_create_model.test.js b/automl/test/language_text_classification_create_model.test.js deleted file mode 100644 index d90352e680c..00000000000 --- a/automl/test/language_text_classification_create_model.test.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const CREATE_MODEL_REGION_TAG = 'language_text_classification_create_model'; -const LOCATION = 'us-central1'; -const DATASET_ID = 'TCN00000000000000000'; - -describe('Automl Natural Language Text Classification Create Model Test', () => { - const client = new AutoMlClient(); - - it('should create a model', async () => { - const projectId = await client.getProjectId(); - const args = [CREATE_MODEL_REGION_TAG, projectId, LOCATION, DATASET_ID]; - const output = cp.spawnSync('node', args, {encoding: 'utf8'}); - - assert.match(output.stderr, /NOT_FOUND/); - assert.match(output.stderr, /Dataset does not exist./); - }); -}); diff --git a/automl/test/language_text_classification_predict.test.js b/automl/test/language_text_classification_predict.test.js deleted file mode 100644 index 7a86284e891..00000000000 --- a/automl/test/language_text_classification_predict.test.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {before, describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const MODEL_ID = 'TCN7483069430457434112'; -const PREDICT_REGION_TAG = 'language_text_classification_predict'; -const LOCATION = 'us-central1'; - -describe('Automl Natural Language Text Classification Predict Test', () => { - const client = new AutoMlClient(); - - before('should verify the model is deployed', async () => { - const projectId = await client.getProjectId(); - const request = { - name: client.modelPath(projectId, LOCATION, MODEL_ID), - }; - - const [response] = await client.getModel(request); - if (response.deploymentState === 'UNDEPLOYED') { - const request = { - name: client.modelPath(projectId, LOCATION, MODEL_ID), - }; - - const [operation] = await client.deployModel(request); - - // Wait for operation to complete. - await operation.promise(); - } - }); - - it('should predict', async () => { - const projectId = await client.getProjectId(); - const content = "'Fruit and nut flavour'"; - - const predictOutput = execSync( - `node ${PREDICT_REGION_TAG}.js ${projectId} ${LOCATION} ${MODEL_ID} ${content}` - ); - assert.match(predictOutput, /Predicted class name/); - }); -}); diff --git a/automl/test/list_datasets.test.js b/automl/test/list_datasets.test.js deleted file mode 100644 index 9bc3dce219d..00000000000 --- a/automl/test/list_datasets.test.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2019 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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LIST_DATASET_REGION_TAG = 'list_datasets'; -const LOCATION = 'us-central1'; - -describe('Automl List Dataset Tests', () => { - const client = new AutoMlClient(); - - it('should list datasets', async () => { - const projectId = await client.getProjectId(); - const list_output = execSync( - `node ${LIST_DATASET_REGION_TAG}.js ${projectId} ${LOCATION}` - ); - - assert.match(list_output, /Dataset id/); - }); -}); diff --git a/automl/test/list_model_evaluations.test.js b/automl/test/list_model_evaluations.test.js deleted file mode 100644 index 33aab77574a..00000000000 --- a/automl/test/list_model_evaluations.test.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LIST_MODEL_EVALUATION_REGION_TAG = 'list_model_evaluations'; -const LOCATION = 'us-central1'; -const MODEL_ID = 'TRL1218052175389786112'; - -describe('Automl List Model Evaluation Tests', () => { - const client = new AutoMlClient(); - - it('should list model evaluations', async () => { - const projectId = await client.getProjectId(); - // list model evaluations - const list_model_eval_output = execSync( - `node ${LIST_MODEL_EVALUATION_REGION_TAG}.js ${projectId} ${LOCATION} ${MODEL_ID}` - ); - assert.match(list_model_eval_output, /Model evaluation name/); - }); -}); diff --git a/automl/test/list_models.test.js b/automl/test/list_models.test.js deleted file mode 100644 index 2657a38b945..00000000000 --- a/automl/test/list_models.test.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LIST_MODEL_REGION_TAG = 'list_models'; -const LOCATION = 'us-central1'; - -describe('Automl List Model Tests', () => { - const client = new AutoMlClient(); - - it('should list models', async () => { - const projectId = await client.getProjectId(); - - // list models - const list_model_output = execSync( - `node ${LIST_MODEL_REGION_TAG}.js ${projectId} ${LOCATION}` - ); - assert.match(list_model_output, /Model id:/); - }); -}); diff --git a/automl/test/list_operation_status.test.js b/automl/test/list_operation_status.test.js deleted file mode 100644 index f8ec88528e8..00000000000 --- a/automl/test/list_operation_status.test.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LIST_OPERATION_STATUS_REGION_TAG = 'list_operation_status'; -const LOCATION = 'us-central1'; - -describe('Automl List Operation Status Tests', () => { - const client = new AutoMlClient(); - - it('should list operation status', async () => { - const projectId = await client.getProjectId(); - - const list_output = execSync( - `node ${LIST_OPERATION_STATUS_REGION_TAG}.js ${projectId} ${LOCATION} ` - ); - assert.match(list_output, /List of operation status:/); - }); -}); diff --git a/automl/test/setEndpoint.test.js b/automl/test/setEndpoint.test.js deleted file mode 100644 index 4996c742e49..00000000000 --- a/automl/test/setEndpoint.test.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const cp = require('child_process'); - -const projectId = process.env.GCLOUD_PROJECT; - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -describe('set endpoint for automl', () => { - it('should list all datasets in `eu`', async () => { - const stdout = execSync(`node beta/setEndpoint.js "${projectId}"`); - assert.match(stdout, /do_not_delete_eu/); - }); -}); diff --git a/automl/test/translate_create_dataset.test.js b/automl/test/translate_create_dataset.test.js deleted file mode 100644 index 0d6ae52abe1..00000000000 --- a/automl/test/translate_create_dataset.test.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it, after} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const CREATE_DATASET_REGION_TAG = 'translate_create_dataset'; -const LOCATION = 'us-central1'; - -describe('Automl Translate Create Dataset Test', () => { - const client = new AutoMlClient(); - let datasetId; - - it('should create a dataset', async () => { - const projectId = await client.getProjectId(); - const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`; - - // create - const create_output = execSync( - `node ${CREATE_DATASET_REGION_TAG}.js ${projectId} ${LOCATION} ${displayName}` - ); - assert.match(create_output, /Dataset id:/); - - datasetId = create_output.split('Dataset id: ')[1].split('\n')[0]; - }); - - after('delete created dataset', async () => { - const projectId = await client.getProjectId(); - const request = { - name: client.datasetPath(projectId, LOCATION, datasetId), - }; - const [operation] = await client.deleteDataset(request); - await operation.promise(); - }); -}); diff --git a/automl/test/translate_create_model.test.js b/automl/test/translate_create_model.test.js deleted file mode 100644 index 7925b386253..00000000000 --- a/automl/test/translate_create_model.test.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const CREATE_MODEL_REGION_TAG = 'translate_create_model'; -const LOCATION = 'us-central1'; -const DATASET_ID = 'TRL8522556519449886720'; - -const {delay} = require('./util'); - -describe('Automl Translate Create Model Tests', () => { - const client = new AutoMlClient(); - - it.skip('should create a model', async function () { - this.retries(5); - await delay(this.test); - - const projectId = await client.getProjectId(); - const create_output = execSync( - `node ${CREATE_MODEL_REGION_TAG}.js ${projectId} ${LOCATION} ${DATASET_ID} translation_test_create_model` - ); - - assert.match(create_output, /Training started/); - }); -}); diff --git a/automl/test/translate_predict.test.js b/automl/test/translate_predict.test.js deleted file mode 100644 index cb9c71e7423..00000000000 --- a/automl/test/translate_predict.test.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const MODEL_ID = 'TRL1218052175389786112'; -const PREDICT_REGION_TAG = 'translate_predict'; -const LOCATION = 'us-central1'; - -describe('Automl Translate Predict Test', () => { - const client = new AutoMlClient(); - - it('should predict', async () => { - const projectId = await client.getProjectId(); - - const list_output = execSync( - `node ${PREDICT_REGION_TAG}.js ${projectId} ${LOCATION} ${MODEL_ID} resources/input.txt` - ); - assert.match(list_output, /Translated content:/); - }); -}); diff --git a/automl/test/undeploy_model.test.js b/automl/test/undeploy_model.test.js deleted file mode 100644 index 583a213b670..00000000000 --- a/automl/test/undeploy_model.test.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const DEPLOY_MODEL_REGION_TAG = 'undeploy_model.js'; -const LOCATION = 'us-central1'; -const MODEL_ID = 'TEN0000000000000000000'; - -describe('Automl Undeploy Model Test', () => { - const client = new AutoMlClient(); - - it('should undeploy a model', async () => { - // As model undeployment can take a long time, instead try to undeploy a - // nonexistent model and confirm that the model was not found, but other - // elements of the request were valid. - const projectId = await client.getProjectId(); - const args = [DEPLOY_MODEL_REGION_TAG, projectId, LOCATION, MODEL_ID]; - const output = cp.spawnSync('node', args, {encoding: 'utf8'}); - - assert.match(output.stderr, /NOT_FOUND/); - assert.match(output.stderr, /The model does not exist./); - }); -}); diff --git a/automl/test/util.js b/automl/test/util.js deleted file mode 100644 index 97b804a43c0..00000000000 --- a/automl/test/util.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -// ML tests frequently run into concurrency and quota issues, for which -// retrying with a backoff is a good strategy: -module.exports = { - async delay(test) { - const retries = test.currentRetry(); - if (retries === 0) return; // no retry on the first failure. - // see: https://cloud.google.com/storage/docs/exponential-backoff: - const ms = Math.pow(2, retries) * 1000 + Math.random() * 2000; - return new Promise(done => { - console.info(`retrying "${test.title}" in ${ms}ms`); - setTimeout(done, ms); - }); - }, -}; diff --git a/automl/test/vision_classification_create_dataset.test.js b/automl/test/vision_classification_create_dataset.test.js deleted file mode 100644 index cda62f9805a..00000000000 --- a/automl/test/vision_classification_create_dataset.test.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {after, describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const CREATE_DATASET_REGION_TAG = 'vision_classification_create_dataset'; -const LOCATION = 'us-central1'; - -describe('Automl Vision Classification Create Dataset Test', () => { - const client = new AutoMlClient(); - let datasetId; - - it('should create a dataset', async () => { - const projectId = await client.getProjectId(); - const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`; - - // create - const create_output = execSync( - `node ${CREATE_DATASET_REGION_TAG}.js ${projectId} ${LOCATION} ${displayName}` - ); - assert.match(create_output, /Dataset id:/); - - datasetId = create_output.split('Dataset id: ')[1].split('\n')[0]; - }); - - after('delete created dataset', async () => { - const projectId = await client.getProjectId(); - const request = { - name: client.datasetPath(projectId, LOCATION, datasetId), - }; - const [operation] = await client.deleteDataset(request); - await operation.promise(); - }); -}); diff --git a/automl/test/vision_classification_create_model.test.js b/automl/test/vision_classification_create_model.test.js deleted file mode 100644 index 59b9a79e288..00000000000 --- a/automl/test/vision_classification_create_model.test.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const CREATE_MODEL_REGION_TAG = 'vision_classification_create_model'; -const LOCATION = 'us-central1'; -const DATASET_ID = 'ICN000000000000000000'; - -describe('Automl Vision Classification Create Model Tests', () => { - const client = new AutoMlClient(); - - it('should create a model', async () => { - // As vision classification does not let you cancel model creation, instead try - // to create a model from a nonexistent dataset, but other elements of the - // request were valid. - const projectId = await client.getProjectId(); - const args = [CREATE_MODEL_REGION_TAG, projectId, LOCATION, DATASET_ID]; - const output = cp.spawnSync('node', args, {encoding: 'utf8'}); - - assert.match(output.stderr, /NOT_FOUND/); - assert.match(output.stderr, /Dataset does not exist./); - }); -}); diff --git a/automl/test/vision_classification_deploy_model_node_count.test.js b/automl/test/vision_classification_deploy_model_node_count.test.js deleted file mode 100644 index bda2e483608..00000000000 --- a/automl/test/vision_classification_deploy_model_node_count.test.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const DEPLOY_MODEL_REGION_TAG = - 'vision_classification_deploy_model_node_count.js'; -const LOCATION = 'us-central1'; -const MODEL_ID = 'ICN0000000000000000000'; - -describe('Automl Vision Classification Deploy Model Test', () => { - const client = new AutoMlClient(); - - it('should deploy a model with a specified node count', async () => { - // As model deployment can take a long time, instead try to deploy a - // nonexistent model and confirm that the model was not found, but other - // elements of the request were valid. - const projectId = await client.getProjectId(); - const args = [DEPLOY_MODEL_REGION_TAG, projectId, LOCATION, MODEL_ID]; - const output = cp.spawnSync('node', args, {encoding: 'utf8'}); - - assert.match(output.stderr, /NOT_FOUND/); - assert.match(output.stderr, /The model does not exist./); - }); -}); diff --git a/automl/test/vision_classification_predict.test.js b/automl/test/vision_classification_predict.test.js deleted file mode 100644 index 71acdbf9b00..00000000000 --- a/automl/test/vision_classification_predict.test.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2020 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 -// -// https://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. - -'use strict'; - -const {assert} = require('chai'); -const {before, describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const MODEL_ID = 'ICN5317963909599068160'; -const PREDICT_REGION_TAG = 'vision_classification_predict'; -const LOCATION = 'us-central1'; - -describe('Automl Vision Classification Predict Test', () => { - const client = new AutoMlClient(); - - before('should verify the model is deployed', async () => { - const projectId = await client.getProjectId(); - const request = { - name: client.modelPath(projectId, LOCATION, MODEL_ID), - }; - - const [response] = await client.getModel(request); - if (response.deploymentState === 'UNDEPLOYED') { - const request = { - name: client.modelPath(projectId, LOCATION, MODEL_ID), - }; - - const [operation] = await client.deployModel(request); - - // Wait for operation to complete. - await operation.promise(); - } - }); - - it('should predict', async () => { - const projectId = await client.getProjectId(); - const filePath = 'resources/test.png'; - - const predictOutput = execSync( - `node ${PREDICT_REGION_TAG}.js ${projectId} ${LOCATION} ${MODEL_ID} ${filePath}` - ); - assert.match(predictOutput, /Predicted class name/); - }); -}); diff --git a/automl/test/vision_object_detection_create_dataset.test.js b/automl/test/vision_object_detection_create_dataset.test.js deleted file mode 100644 index 5516af3997b..00000000000 --- a/automl/test/vision_object_detection_create_dataset.test.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2020 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. - -'use strict'; - -const {assert} = require('chai'); -const {after, describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const CREATE_DATASET_REGION_TAG = 'vision_object_detection_create_dataset'; -const LOCATION = 'us-central1'; - -describe('Automl Vision Object Detection Create Dataset Test', () => { - const client = new AutoMlClient(); - let datasetId; - - it('should create a dataset', async () => { - const projectId = await client.getProjectId(); - const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`; - - // create - const create_output = await execSync( - `node ${CREATE_DATASET_REGION_TAG}.js ${projectId} ${LOCATION} ${displayName}` - ); - assert.match(create_output, /Dataset id:/); - - datasetId = create_output.split('Dataset id: ')[1].split('\n')[0]; - }); - - after('delete created dataset', async () => { - const projectId = await client.getProjectId(); - const request = { - name: client.datasetPath(projectId, LOCATION, datasetId), - }; - const [operation] = await client.deleteDataset(request); - await operation.promise(); - }); -}); diff --git a/automl/test/vision_object_detection_create_model.test.js b/automl/test/vision_object_detection_create_model.test.js deleted file mode 100644 index a867bc1e533..00000000000 --- a/automl/test/vision_object_detection_create_model.test.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2020 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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const CREATE_MODEL_REGION_TAG = 'vision_object_detection_create_model'; -const LOCATION = 'us-central1'; -const DATASET_ID = 'IOD0000000000000000000'; - -describe('Automl Vision Object Detection Create Model Test', () => { - const client = new AutoMlClient(); - - it('should create a model', async () => { - // As object detection does not let you cancel model creation, instead try - // to create a model from a nonexistent dataset, but other elements of the - // request were valid. - const projectId = await client.getProjectId(); - const args = [CREATE_MODEL_REGION_TAG, projectId, LOCATION, DATASET_ID]; - const output = cp.spawnSync('node', args, {encoding: 'utf8'}); - - assert.match(output.stderr, /NOT_FOUND/); - assert.match(output.stderr, /Dataset does not exist./); - }); -}); diff --git a/automl/test/vision_object_detection_deploy_model_node_count.test.js b/automl/test/vision_object_detection_deploy_model_node_count.test.js deleted file mode 100644 index a3203812ee7..00000000000 --- a/automl/test/vision_object_detection_deploy_model_node_count.test.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2020 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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const DEPLOY_MODEL_REGION_TAG = - 'vision_object_detection_deploy_model_node_count'; -const LOCATION = 'us-central1'; -const MODEL_ID = '0000000000000000000000'; - -describe('Automl Vision Object Detection Deploy Model Test', () => { - const client = new AutoMlClient(); - - it('should deploy a model with a specified node count', async () => { - // As model deployment can take a long time, instead try to deploy a - // nonexistent model and confirm that the model was not found, but other - // elements of the request were valid. - const projectId = await client.getProjectId(); - const args = [DEPLOY_MODEL_REGION_TAG, projectId, LOCATION, MODEL_ID]; - const output = cp.spawnSync('node', args, {encoding: 'utf8'}); - - assert.match(output.stderr, /NOT_FOUND/); - assert.match(output.stderr, /The model does not exist./); - }); -}); diff --git a/automl/test/vision_object_detection_predict.test.js b/automl/test/vision_object_detection_predict.test.js deleted file mode 100644 index 3842a2a403d..00000000000 --- a/automl/test/vision_object_detection_predict.test.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2020 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. - -'use strict'; - -const {assert} = require('chai'); -const {describe, it} = require('mocha'); -const {AutoMlClient} = require('@google-cloud/automl').v1; - -const cp = require('child_process'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const MODEL_ID = 'IOD1656537412546854912'; -const PREDICT_REGION_TAG = 'vision_object_detection_predict'; -const LOCATION = 'us-central1'; - -const {delay} = require('./util'); - -describe('Automl Vision Object Detection Predict Test', () => { - const client = new AutoMlClient(); - - it('should verify the model is deployed', async function () { - this.retries(5); - await delay(this.test); - const projectId = await client.getProjectId(); - const request = { - name: client.modelPath(projectId, LOCATION, MODEL_ID), - }; - - const [response] = await client.getModel(request); - if (response.deploymentState === 'DEPLOYED') { - const request = { - name: client.modelPath(projectId, LOCATION, MODEL_ID), - }; - - const [operation] = await client.deployModel(request); - - // Wait for operation to complete. - await operation.promise(); - } - }); - - it('should predict', async () => { - const projectId = await client.getProjectId(); - const filePath = 'resources/salad.jpg'; - - const predictOutput = execSync( - `node ${PREDICT_REGION_TAG}.js ${projectId} ${LOCATION} ${MODEL_ID} ${filePath}` - ); - assert.match(predictOutput, /Predicted class name/); - }); -});