diff --git a/ai-platform/snippets/create-training-pipeline-video-action-recognition.js b/ai-platform/snippets/create-training-pipeline-video-action-recognition.js deleted file mode 100644 index accb3de20b3..00000000000 --- a/ai-platform/snippets/create-training-pipeline-video-action-recognition.js +++ /dev/null @@ -1,96 +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'; - -async function main( - datasetId, - modelDisplayName, - trainingPipelineDisplayName, - project, - location = 'us-central1' -) { - // [START aiplatform_create_training_pipeline_video_action_recognition_sample] - /** - * TODO(developer): Uncomment these variables before running the sample.\ - * (Not necessary if passing values as arguments) - */ - - // const datasetId = 'YOUR_DATASET_ID'; - // const modelDisplayName = 'YOUR_MODEL_DISPLAY_NAME'; - // const trainingPipelineDisplayName = 'YOUR_TRAINING_PIPELINE_DISPLAY_NAME'; - // const project = 'YOUR_PROJECT_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - const aiplatform = require('@google-cloud/aiplatform'); - const {definition} = - aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob; - - // Imports the Google Cloud Pipeline Service Client library - const {PipelineServiceClient} = aiplatform.v1; - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', - }; - - // Instantiates a client - const pipelineServiceClient = new PipelineServiceClient(clientOptions); - - async function createTrainingPipelineVideoActionRecognition() { - // Configure the parent resource - const parent = `projects/${project}/locations/${location}`; - // Values should match the input expected by your model. - const trainingTaskInputObj = - new definition.AutoMlVideoActionRecognitionInputs({ - // modelType can be either 'CLOUD' or 'MOBILE_VERSATILE_1' - modelType: 'CLOUD', - }); - const trainingTaskInputs = trainingTaskInputObj.toValue(); - - const modelToUpload = {displayName: modelDisplayName}; - const inputDataConfig = {datasetId: datasetId}; - const trainingPipeline = { - displayName: trainingPipelineDisplayName, - trainingTaskDefinition: - 'gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_video_action_recognition_1.0.0.yaml', - trainingTaskInputs, - inputDataConfig, - modelToUpload, - }; - const request = { - parent, - trainingPipeline, - }; - - // Create training pipeline request - const [response] = - await pipelineServiceClient.createTrainingPipeline(request); - - console.log('Create training pipeline video action recognition response'); - console.log(`Name : ${response.name}`); - console.log('Raw response:'); - console.log(JSON.stringify(response, null, 2)); - } - createTrainingPipelineVideoActionRecognition(); - // [END aiplatform_create_training_pipeline_video_action_recognition_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/create-training-pipeline-video-classification.js b/ai-platform/snippets/create-training-pipeline-video-classification.js deleted file mode 100644 index 3989c4c2a69..00000000000 --- a/ai-platform/snippets/create-training-pipeline-video-classification.js +++ /dev/null @@ -1,94 +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'; - -async function main( - datasetId, - modelDisplayName, - trainingPipelineDisplayName, - project, - location = 'us-central1' -) { - // [START aiplatform_create_training_pipeline_video_classification_sample] - /** - * TODO(developer): Uncomment these variables before running the sample.\ - * (Not necessary if passing values as arguments) - */ - - // const datasetId = 'YOUR_DATASET_ID'; - // const modelDisplayName = 'YOUR_MODEL_DISPLAY_NAME'; - // const trainingPipelineDisplayName = 'YOUR_TRAINING_PIPELINE_DISPLAY_NAME'; - // const project = 'YOUR_PROJECT_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - const aiplatform = require('@google-cloud/aiplatform'); - const {definition} = - aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob; - - // Imports the Google Cloud Pipeline Service Client library - const {PipelineServiceClient} = aiplatform.v1; - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', - }; - - // Instantiates a client - const pipelineServiceClient = new PipelineServiceClient(clientOptions); - - async function createTrainingPipelineVideoClassification() { - // Configure the parent resource - const parent = `projects/${project}/locations/${location}`; - // Values should match the input expected by your model. - const trainingTaskInputObj = new definition.AutoMlVideoClassificationInputs( - {} - ); - const trainingTaskInputs = trainingTaskInputObj.toValue(); - - const modelToUpload = {displayName: modelDisplayName}; - const inputDataConfig = {datasetId: datasetId}; - const trainingPipeline = { - displayName: trainingPipelineDisplayName, - trainingTaskDefinition: - 'gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_video_classification_1.0.0.yaml', - trainingTaskInputs, - inputDataConfig, - modelToUpload, - }; - const request = { - parent, - trainingPipeline, - }; - - // Create training pipeline request - const [response] = - await pipelineServiceClient.createTrainingPipeline(request); - - console.log('Create training pipeline video classification response'); - console.log(`Name : ${response.name}`); - console.log('Raw response:'); - console.log(JSON.stringify(response, null, 2)); - } - createTrainingPipelineVideoClassification(); - // [END aiplatform_create_training_pipeline_video_classification_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/create-training-pipeline-video-object-tracking.js b/ai-platform/snippets/create-training-pipeline-video-object-tracking.js deleted file mode 100644 index 42fc795e388..00000000000 --- a/ai-platform/snippets/create-training-pipeline-video-object-tracking.js +++ /dev/null @@ -1,96 +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'; - -async function main( - datasetId, - modelDisplayName, - trainingPipelineDisplayName, - project, - location = 'us-central1' -) { - // [START aiplatform_create_training_pipeline_video_object_tracking_sample] - /** - * TODO(developer): Uncomment these variables before running the sample.\ - * (Not necessary if passing values as arguments) - */ - - // const datasetId = 'YOUR_DATASET_ID'; - // const modelDisplayName = 'YOUR_MODEL_DISPLAY_NAME'; - // const trainingPipelineDisplayName = 'YOUR_TRAINING_PIPELINE_DISPLAY_NAME'; - // const project = 'YOUR_PROJECT_ID'; - // const location = 'YOUR_PROJECT_LOCATION'; - const aiplatform = require('@google-cloud/aiplatform'); - const {definition} = - aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob; - const ModelType = definition.AutoMlVideoObjectTrackingInputs.ModelType; - - // Imports the Google Cloud Pipeline Service Client library - const {PipelineServiceClient} = aiplatform.v1; - - // Specifies the location of the api endpoint - const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', - }; - - // Instantiates a client - const pipelineServiceClient = new PipelineServiceClient(clientOptions); - - async function createTrainingPipelineVideoObjectTracking() { - // Configure the parent resource - const parent = `projects/${project}/locations/${location}`; - - const trainingTaskInputsObj = - new definition.AutoMlVideoObjectTrackingInputs({ - modelType: ModelType.CLOUD, - }); - const trainingTaskInputs = trainingTaskInputsObj.toValue(); - - const modelToUpload = {displayName: modelDisplayName}; - const inputDataConfig = {datasetId: datasetId}; - const trainingPipeline = { - displayName: trainingPipelineDisplayName, - trainingTaskDefinition: - 'gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_video_object_tracking_1.0.0.yaml', - trainingTaskInputs, - inputDataConfig, - modelToUpload, - }; - const request = { - parent, - trainingPipeline, - }; - - // Create training pipeline request - const [response] = - await pipelineServiceClient.createTrainingPipeline(request); - - console.log('Create training pipeline video object tracking response'); - console.log(`Name : ${response.name}`); - console.log('Raw response:'); - console.log(JSON.stringify(response, null, 2)); - } - createTrainingPipelineVideoObjectTracking(); - // [END aiplatform_create_training_pipeline_video_object_tracking_sample] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); - -main(...process.argv.slice(2)); diff --git a/ai-platform/snippets/test/create-training-pipeline-video-action-recognition.test.js b/ai-platform/snippets/test/create-training-pipeline-video-action-recognition.test.js deleted file mode 100644 index 33d5f472ac5..00000000000 --- a/ai-platform/snippets/test/create-training-pipeline-video-action-recognition.test.js +++ /dev/null @@ -1,77 +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 uuid = require('uuid').v4; -const cp = require('child_process'); -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const aiplatform = require('@google-cloud/aiplatform'); -const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', -}; - -const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient( - clientOptions -); - -const datasetId = '6881957627459272704'; -const modelDisplayName = `temp_create_training_pipeline_node_var_model_test_${uuid()}`; -const trainingPipelineDisplayName = `temp_create_training_pipeline_node_var_test_${uuid()}`; -const location = 'us-central1'; -const project = process.env.CAIP_PROJECT_ID; - -let trainingPipelineId; - -describe('AI platform create training pipeline video action recognition', async function () { - this.retries(2); - it('should create a new video action-recognition training pipeline', async () => { - const stdout = execSync( - `node ./create-training-pipeline-video-action-recognition.js ${datasetId} ${modelDisplayName} ${trainingPipelineDisplayName} ${project} ${location}` - ); - assert.match( - stdout, - /Create training pipeline video action recognition response/ - ); - trainingPipelineId = stdout - .split('/locations/us-central1/trainingPipelines/')[1] - .split('\n')[0]; - }); - - after('should cancel the training pipeline and delete it', async () => { - const name = pipelineServiceClient.trainingPipelinePath( - project, - location, - trainingPipelineId - ); - - const cancelRequest = { - name, - }; - - pipelineServiceClient.cancelTrainingPipeline(cancelRequest).then(() => { - const deleteRequest = { - name, - }; - - return pipelineServiceClient.deleteTrainingPipeline(deleteRequest); - }); - }); -}); diff --git a/ai-platform/snippets/test/create-training-pipeline-video-classification.test.js b/ai-platform/snippets/test/create-training-pipeline-video-classification.test.js deleted file mode 100644 index 5a818b6f17f..00000000000 --- a/ai-platform/snippets/test/create-training-pipeline-video-classification.test.js +++ /dev/null @@ -1,85 +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 path = require('path'); -const {assert} = require('chai'); -const {after, describe, it} = require('mocha'); - -const uuid = require('uuid').v4; -const cp = require('child_process'); -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cwd = path.join(__dirname, '..'); - -const aiplatform = require('@google-cloud/aiplatform'); -const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', -}; - -const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient( - clientOptions -); - -const datasetId = '3757409464110546944'; -const modelDisplayName = `temp_create_training_pipeline_video_classification_model_test${uuid()}`; -const trainingPipelineDisplayName = `temp_create_training_pipeline_video_classification_test_${uuid()}`; -const location = 'us-central1'; -const project = process.env.CAIP_PROJECT_ID; - -let trainingPipelineId; - -describe('AI platform create training pipeline video classification', async function () { - this.retries(2); - it('should create a new video classification training pipeline', async () => { - const stdout = execSync( - `node ./create-training-pipeline-video-classification.js ${datasetId} \ - ${modelDisplayName} \ - ${trainingPipelineDisplayName} \ - ${project} ${location}`, - { - cwd, - } - ); - assert.match( - stdout, - /Create training pipeline video classification response/ - ); - trainingPipelineId = stdout - .split('/locations/us-central1/trainingPipelines/')[1] - .split('\n')[0]; - }); - - after('should cancel the training pipeline and delete it', async () => { - const name = pipelineServiceClient.trainingPipelinePath( - project, - location, - trainingPipelineId - ); - - const cancelRequest = { - name, - }; - - pipelineServiceClient.cancelTrainingPipeline(cancelRequest).then(() => { - const deleteRequest = { - name, - }; - - return pipelineServiceClient.deleteTrainingPipeline(deleteRequest); - }); - }); -}); diff --git a/ai-platform/snippets/test/create-training-pipeline-video-object-tracking.test.js b/ai-platform/snippets/test/create-training-pipeline-video-object-tracking.test.js deleted file mode 100644 index b6a893360fe..00000000000 --- a/ai-platform/snippets/test/create-training-pipeline-video-object-tracking.test.js +++ /dev/null @@ -1,85 +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 path = require('path'); -const {assert} = require('chai'); -const {after, describe, it} = require('mocha'); - -const uuid = require('uuid').v4; -const cp = require('child_process'); -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cwd = path.join(__dirname, '..'); - -const aiplatform = require('@google-cloud/aiplatform'); -const clientOptions = { - apiEndpoint: 'us-central1-aiplatform.googleapis.com', -}; - -const pipelineServiceClient = new aiplatform.v1.PipelineServiceClient( - clientOptions -); - -const datasetId = '1138566280794603520'; -const modelDisplayName = `temp_create_training_pipeline_video_object_tracking_model_test${uuid()}`; -const trainingPipelineDisplayName = `temp_create_training_pipeline_video_object_tracking_test_${uuid()}`; -const location = 'us-central1'; -const project = process.env.CAIP_PROJECT_ID; - -let trainingPipelineId; - -describe('AI platform create training pipeline object tracking', async function () { - this.retries(2); - it('should create a new object tracking training pipeline', async () => { - const stdout = execSync( - `node ./create-training-pipeline-video-object-tracking.js \ - ${datasetId} ${modelDisplayName} \ - ${trainingPipelineDisplayName} \ - ${project} ${location}`, - { - cwd, - } - ); - assert.match( - stdout, - /Create training pipeline video object tracking response/ - ); - trainingPipelineId = stdout - .split('/locations/us-central1/trainingPipelines/')[1] - .split('\n')[0]; - }); - - after('should cancel the training pipeline and delete it', async () => { - const name = pipelineServiceClient.trainingPipelinePath( - project, - location, - trainingPipelineId - ); - - const cancelRequest = { - name, - }; - - pipelineServiceClient.cancelTrainingPipeline(cancelRequest).then(() => { - const deleteRequest = { - name, - }; - - return pipelineServiceClient.deleteTrainingPipeline(deleteRequest); - }); - }); -});