From 4d19b5b8bfe078b07f99a4f52221a92517efbdc2 Mon Sep 17 00:00:00 2001 From: Na Li Date: Thu, 6 Feb 2020 16:38:19 -0800 Subject: [PATCH 1/5] Remove use of browserstack --- tfjs-converter/package.json | 2 +- tfjs-converter/run_tests.ts | 38 +++++++++++++++++++ .../executors/dynamic_executor_test.ts | 10 ++--- 3 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 tfjs-converter/run_tests.ts diff --git a/tfjs-converter/package.json b/tfjs-converter/package.json index 15f24b24a76..431b61830e4 100644 --- a/tfjs-converter/package.json +++ b/tfjs-converter/package.json @@ -59,7 +59,7 @@ "link-local": "yalc link", "publish-local": "yarn build-npm && yalc push", "test": "yarn gen-json --test && karma start", - "test-ci": "yarn gen-json --test && yarn build && yarn lint && yarn run-browserstack", + "test-ci": "yarn gen-json --test && yarn build && yarn lint && ts-node run_tests.ts", "test-snippets": "ts-node ./scripts/test_snippets.ts", "run-browserstack": "karma start --singleRun --browsers='bs_firefox_mac,bs_chrome_mac' --reporters='dots,karma-typescript,BrowserStack'", "lint": "tslint -p . -t verbose", diff --git a/tfjs-converter/run_tests.ts b/tfjs-converter/run_tests.ts new file mode 100644 index 00000000000..2fdce3c4f78 --- /dev/null +++ b/tfjs-converter/run_tests.ts @@ -0,0 +1,38 @@ +/** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * 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. + * ============================================================================= + */ + +// tslint:disable-next-line:no-imports-from-dist +import * as jasmine_util from '@tensorflow/tfjs-core/dist/jasmine_util'; + +// tslint:disable-next-line:no-require-imports +const jasmineCtor = require('jasmine'); +// tslint:disable-next-line:no-require-imports + +Error.stackTraceLimit = Infinity; + +process.on('unhandledRejection', e => { + throw e; +}); + +jasmine_util.setTestEnvs( + [{name: 'test-converter', backendName: 'cpu', flags: {}}]); + +const unitTests = 'src/**/*_test.ts'; + +const runner = new jasmineCtor(); +runner.loadConfig({spec_files: [unitTests], random: false}); +runner.execute(); diff --git a/tfjs-converter/src/operations/executors/dynamic_executor_test.ts b/tfjs-converter/src/operations/executors/dynamic_executor_test.ts index 1f4ddd056f6..4663423178a 100644 --- a/tfjs-converter/src/operations/executors/dynamic_executor_test.ts +++ b/tfjs-converter/src/operations/executors/dynamic_executor_test.ts @@ -55,7 +55,7 @@ describe('dynamic', () => { const input3 = [tfc.tensor1d([1])]; const input4 = [tfc.tensor1d([1])]; const input5 = [tfc.tensor1d([1])]; - spyOn(tfc.image, 'nonMaxSuppressionAsync').and.callThrough(); + spyOn(tfc.image, 'nonMaxSuppressionAsync'); const result = executeOp(node, {input1, input2, input3, input4, input5}, context); expect(tfc.image.nonMaxSuppressionAsync) @@ -88,7 +88,7 @@ describe('dynamic', () => { const input3 = [tfc.tensor1d([1])]; const input4 = [tfc.tensor1d([1])]; const input5 = [tfc.tensor1d([1])]; - spyOn(tfc.image, 'nonMaxSuppressionAsync').and.callThrough(); + spyOn(tfc.image, 'nonMaxSuppressionAsync'); const result = executeOp(node, {input1, input2, input3, input4, input5}, context); expect(tfc.image.nonMaxSuppressionAsync) @@ -125,7 +125,7 @@ describe('dynamic', () => { const input4 = [tfc.tensor1d([1])]; const input5 = [tfc.tensor1d([1])]; const input6 = [tfc.tensor1d([1])]; - spyOn(tfc.image, 'nonMaxSuppressionWithScoreAsync').and.callThrough(); + spyOn(tfc.image, 'nonMaxSuppressionWithScoreAsync').and.returnValue({}); const result = executeOp( node, {input1, input2, input3, input4, input5, input6}, context); expect(tfc.image.nonMaxSuppressionWithScoreAsync) @@ -153,7 +153,7 @@ describe('dynamic', () => { node.op = 'Where'; node.inputParams = {'condition': createTensorAttr(0)}; const input1 = [tfc.scalar(1)]; - spyOn(tfc, 'whereAsync').and.callThrough(); + spyOn(tfc, 'whereAsync'); const result = executeOp(node, {input1}, context); expect((tfc.whereAsync as jasmine.Spy).calls.mostRecent().args[0].dtype) @@ -180,7 +180,7 @@ describe('dynamic', () => { node.inputParams = {'x': createTensorAttr(0), 'y': createTensorAttr(1)}; const input1 = [tfc.scalar(1)]; const input2 = [tfc.scalar(1)]; - spyOn(tfc, 'setdiff1dAsync').and.callThrough(); + spyOn(tfc, 'setdiff1dAsync'); const result = executeOp(node, {input1, input2}, context); expect(tfc.setdiff1dAsync).toHaveBeenCalledWith(input1[0], input2[0]); From 6020c7d004cfc53c44abab657e332823741c4e05 Mon Sep 17 00:00:00 2001 From: Na Li Date: Thu, 20 Feb 2020 11:13:37 -0800 Subject: [PATCH 2/5] Clean up cloudbuild.yml and package.json --- tfjs-converter/cloudbuild.yml | 11 +++-------- tfjs-converter/package.json | 5 ++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/tfjs-converter/cloudbuild.yml b/tfjs-converter/cloudbuild.yml index 8197674c864..797e1c16c57 100644 --- a/tfjs-converter/cloudbuild.yml +++ b/tfjs-converter/cloudbuild.yml @@ -14,15 +14,14 @@ steps: args: ['install'] waitFor: ['yarn-common'] -# Run browser tests. +# Run javascript tests. - name: 'node:10' dir: 'tfjs-converter' entrypoint: 'yarn' - id: 'test-browser' + id: 'test-js' args: ['test-ci'] waitFor: ['yarn'] - env: ['BROWSERSTACK_USERNAME=deeplearnjs1', 'NIGHTLY=$_NIGHTLY'] - secretEnv: ['BROWSERSTACK_KEY'] + env: ['NIGHTLY=$_NIGHTLY'] # Run python tests. - name: 'gcr.io/google-appengine/python' @@ -50,10 +49,6 @@ steps: args: ['test-snippets'] waitFor: ['yarn'] -secrets: -- kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc - secretEnv: - BROWSERSTACK_KEY: CiQAkwyoIW0LcnxymzotLwaH4udVTQFBEN4AEA5CA+a3+yflL2ASPQAD8BdZnGARf78MhH5T9rQqyz9HNODwVjVIj64CTkFlUCGrP1B2HX9LXHWHLmtKutEGTeFFX9XhuBzNExA= timeout: 1800s logsBucket: 'gs://tfjs-build-logs' substitutions: diff --git a/tfjs-converter/package.json b/tfjs-converter/package.json index 431b61830e4..d862af15eb2 100644 --- a/tfjs-converter/package.json +++ b/tfjs-converter/package.json @@ -58,10 +58,9 @@ "build-npm": "./scripts/build-npm.sh", "link-local": "yalc link", "publish-local": "yarn build-npm && yalc push", - "test": "yarn gen-json --test && karma start", - "test-ci": "yarn gen-json --test && yarn build && yarn lint && ts-node run_tests.ts", + "test": "yarn gen-json --test && yarn build && yarn lint && ts-node run_tests.ts", + "test-ci": "yarn test", "test-snippets": "ts-node ./scripts/test_snippets.ts", - "run-browserstack": "karma start --singleRun --browsers='bs_firefox_mac,bs_chrome_mac' --reporters='dots,karma-typescript,BrowserStack'", "lint": "tslint -p . -t verbose", "make-version": "sh -c ./scripts/make-version", "gen-doc": "ts-node ./scripts/gen_doc.ts", From f15b38e44e12faeb7e5444a43069906522eb4633 Mon Sep 17 00:00:00 2001 From: Na Li Date: Thu, 20 Feb 2020 11:34:39 -0800 Subject: [PATCH 3/5] Clean up package.json --- tfjs-converter/cloudbuild.yml | 18 +++++++++++++++++- tfjs-converter/package.json | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tfjs-converter/cloudbuild.yml b/tfjs-converter/cloudbuild.yml index 797e1c16c57..7aac2ab4efa 100644 --- a/tfjs-converter/cloudbuild.yml +++ b/tfjs-converter/cloudbuild.yml @@ -6,7 +6,7 @@ steps: id: 'yarn-common' args: ['install'] -# Install converter dependencies +# Install converter dependencies. - name: 'node:10' dir: 'tfjs-converter' entrypoint: 'yarn' @@ -14,6 +14,22 @@ steps: args: ['install'] waitFor: ['yarn-common'] +# Run lint. +- name: 'node:10' + dir: 'tfjs-converter' + entrypoint: 'yarn' + id: 'lint' + args: ['lint'] + waitFor: ['yarn'] + +# Build the project. +- name: 'node:10' + dir: 'tfjs-converter' + entrypoint: 'yarn' + id: 'build' + args: ['build'] + waitFor: ['yarn'] + # Run javascript tests. - name: 'node:10' dir: 'tfjs-converter' diff --git a/tfjs-converter/package.json b/tfjs-converter/package.json index d862af15eb2..fef633a5b8c 100644 --- a/tfjs-converter/package.json +++ b/tfjs-converter/package.json @@ -58,7 +58,7 @@ "build-npm": "./scripts/build-npm.sh", "link-local": "yalc link", "publish-local": "yarn build-npm && yalc push", - "test": "yarn gen-json --test && yarn build && yarn lint && ts-node run_tests.ts", + "test": "yarn gen-json --test && ts-node run_tests.ts", "test-ci": "yarn test", "test-snippets": "ts-node ./scripts/test_snippets.ts", "lint": "tslint -p . -t verbose", From e2f7b43015b837d46de68e35e70cf467a15b46b3 Mon Sep 17 00:00:00 2001 From: Na Li Date: Thu, 20 Feb 2020 11:51:00 -0800 Subject: [PATCH 4/5] Clean up cloudbuild.yml --- tfjs-converter/cloudbuild.yml | 19 ++++++++++++++----- tfjs-converter/package.json | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tfjs-converter/cloudbuild.yml b/tfjs-converter/cloudbuild.yml index 7aac2ab4efa..2dcad7cf933 100644 --- a/tfjs-converter/cloudbuild.yml +++ b/tfjs-converter/cloudbuild.yml @@ -22,13 +22,21 @@ steps: args: ['lint'] waitFor: ['yarn'] +# Generate json file. +- name: 'node:10' + dir: 'tfjs-converter' + entrypoint: 'yarn' + id: 'gen-json' + args: ['gen-json', '--test'] + waitFor: ['yarn'] + # Build the project. - name: 'node:10' dir: 'tfjs-converter' entrypoint: 'yarn' id: 'build' args: ['build'] - waitFor: ['yarn'] + waitFor: ['gen-json'] # Run javascript tests. - name: 'node:10' @@ -36,27 +44,28 @@ steps: entrypoint: 'yarn' id: 'test-js' args: ['test-ci'] - waitFor: ['yarn'] + waitFor: ['build'] env: ['NIGHTLY=$_NIGHTLY'] # Run python tests. - name: 'gcr.io/google-appengine/python' dir: 'tfjs-converter/python' entrypoint: 'bash' + id: 'python-build' args: ['./build-pip-package.sh', '--test', '/tmp/tfjs-pips'] - waitFor: ['yarn'] + waitFor: ['gen-json'] - name: 'python:2' dir: 'tfjs-converter/python' entrypoint: 'bash' args: ['./run-python-tests.sh'] - waitFor: ['yarn'] + waitFor: ['python-build'] - name: 'python:3.6' dir: 'tfjs-converter/python' entrypoint: 'bash' args: ['./run-python-tests.sh'] - waitFor: ['yarn'] + waitFor: ['python-build'] - name: 'node:10' dir: 'tfjs-converter' diff --git a/tfjs-converter/package.json b/tfjs-converter/package.json index fef633a5b8c..582185c261b 100644 --- a/tfjs-converter/package.json +++ b/tfjs-converter/package.json @@ -59,7 +59,7 @@ "link-local": "yalc link", "publish-local": "yarn build-npm && yalc push", "test": "yarn gen-json --test && ts-node run_tests.ts", - "test-ci": "yarn test", + "test-ci": "ts-node run_tests.ts", "test-snippets": "ts-node ./scripts/test_snippets.ts", "lint": "tslint -p . -t verbose", "make-version": "sh -c ./scripts/make-version", From cfbd43d074eb242fda490e675251aa8d7ca33acb Mon Sep 17 00:00:00 2001 From: Na Li Date: Thu, 20 Feb 2020 13:31:36 -0800 Subject: [PATCH 5/5] Clean up cloudbuild.yml --- tfjs-converter/cloudbuild.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tfjs-converter/cloudbuild.yml b/tfjs-converter/cloudbuild.yml index 2dcad7cf933..21291d8286f 100644 --- a/tfjs-converter/cloudbuild.yml +++ b/tfjs-converter/cloudbuild.yml @@ -51,21 +51,20 @@ steps: - name: 'gcr.io/google-appengine/python' dir: 'tfjs-converter/python' entrypoint: 'bash' - id: 'python-build' args: ['./build-pip-package.sh', '--test', '/tmp/tfjs-pips'] - waitFor: ['gen-json'] + waitFor: ['yarn'] - name: 'python:2' dir: 'tfjs-converter/python' entrypoint: 'bash' args: ['./run-python-tests.sh'] - waitFor: ['python-build'] + waitFor: ['yarn'] - name: 'python:3.6' dir: 'tfjs-converter/python' entrypoint: 'bash' args: ['./run-python-tests.sh'] - waitFor: ['python-build'] + waitFor: ['yarn'] - name: 'node:10' dir: 'tfjs-converter'