From efa9398142ca20f046692df1a7415c53c4c4b64b Mon Sep 17 00:00:00 2001 From: dpebot Date: Fri, 31 Aug 2018 04:12:46 -0700 Subject: [PATCH 1/3] Re-generate library using /synth.py --- .circleci/config.yml | 7 ++- .eslintignore | 1 - .jsdoc.js | 4 +- .kokoro/continuous/node8/lint.cfg | 2 +- .kokoro/docs.sh | 2 +- .kokoro/lint.sh | 2 +- .kokoro/samples-test.sh | 2 +- .kokoro/system-test.sh | 2 +- .kokoro/test.bat | 3 +- .kokoro/test.sh | 3 +- .../cloud/vision/v1/image_annotator.proto | 27 ++++++++++++ .../cloud/vision/v1/doc_image_annotator.js | 43 ++++++++++++++++++- src/v1/doc/google/protobuf/doc_any.js | 21 +++++---- src/v1p1beta1/doc/google/protobuf/doc_any.js | 21 +++++---- src/v1p2beta1/doc/google/protobuf/doc_any.js | 21 +++++---- src/v1p3beta1/doc/google/protobuf/doc_any.js | 21 +++++---- .../doc/google/protobuf/doc_field_mask.js | 6 +++ .../doc/google/protobuf/doc_timestamp.js | 8 ++-- 18 files changed, 146 insertions(+), 50 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 41c82336..eab76c4a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -107,9 +107,7 @@ jobs: steps: - checkout - run: *npm_install_and_link - - run: - name: Build documentation. - command: npm run docs + - run: npm run docs sample_tests: docker: - image: 'node:8' @@ -164,5 +162,6 @@ jobs: user: node steps: - checkout - - run: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc' + - npm install + - run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc - run: npm publish --access=public diff --git a/.eslintignore b/.eslintignore index 7b5856ea..f6fac98b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,3 @@ node_modules/* samples/node_modules/* src/**/doc/* -samples/system-test/* diff --git a/.jsdoc.js b/.jsdoc.js index dce8e9ff..83b5a99c 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -1,5 +1,5 @@ /*! - * Copyright 2017 Google Inc. All Rights Reserved. + * Copyright 2018 Google LLC. 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. @@ -36,7 +36,7 @@ module.exports = { includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2017 Google, Inc.', + copyright: 'Copyright 2018 Google, LLC.', includeDate: false, sourceFiles: false, systemName: '@google-cloud/vision', diff --git a/.kokoro/continuous/node8/lint.cfg b/.kokoro/continuous/node8/lint.cfg index db497ccd..bebc4ae2 100644 --- a/.kokoro/continuous/node8/lint.cfg +++ b/.kokoro/continuous/node8/lint.cfg @@ -1,4 +1,4 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/nodejs-vision/.kokoro/lint.sh" -} \ No newline at end of file +} diff --git a/.kokoro/docs.sh b/.kokoro/docs.sh index 09fd52bc..1d288f3d 100755 --- a/.kokoro/docs.sh +++ b/.kokoro/docs.sh @@ -16,7 +16,7 @@ set -xeo pipefail -cd github/nodejs-vision +cd $(dirname $0)/.. npm install diff --git a/.kokoro/lint.sh b/.kokoro/lint.sh index c0323cc7..9d29203e 100755 --- a/.kokoro/lint.sh +++ b/.kokoro/lint.sh @@ -16,7 +16,7 @@ set -xeo pipefail -cd github/nodejs-vision +cd $(dirname $0)/.. npm install diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh index 4e38938d..93af79aa 100755 --- a/.kokoro/samples-test.sh +++ b/.kokoro/samples-test.sh @@ -20,7 +20,7 @@ set -xeo pipefail export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json export GCLOUD_PROJECT=long-door-651 -cd github/nodejs-vision +cd $(dirname $0)/.. npm install diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh index 3fd99fa2..299032dc 100755 --- a/.kokoro/system-test.sh +++ b/.kokoro/system-test.sh @@ -19,7 +19,7 @@ set -xeo pipefail # Setup service account credentials. export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json -cd github/nodejs-vision +cd $(dirname $0)/.. npm install diff --git a/.kokoro/test.bat b/.kokoro/test.bat index 3db32685..a8534ba8 100644 --- a/.kokoro/test.bat +++ b/.kokoro/test.bat @@ -14,7 +14,8 @@ @echo "Starting Windows build" -cd github/nodejs-vision +cd /d %~dp0 +cd .. call npm install || goto :error call npm run test || goto :error diff --git a/.kokoro/test.sh b/.kokoro/test.sh index f20da101..7f49f6d3 100755 --- a/.kokoro/test.sh +++ b/.kokoro/test.sh @@ -16,7 +16,8 @@ set -xeo pipefail -cd github/nodejs-vision +cd $(dirname $0)/.. + npm install npm test node_modules/.bin/codecov diff --git a/protos/google/cloud/vision/v1/image_annotator.proto b/protos/google/cloud/vision/v1/image_annotator.proto index acd7b268..f8d82084 100644 --- a/protos/google/cloud/vision/v1/image_annotator.proto +++ b/protos/google/cloud/vision/v1/image_annotator.proto @@ -103,6 +103,9 @@ message Feature { // Run web detection. WEB_DETECTION = 10; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; } // The feature type. @@ -410,6 +413,26 @@ message EntityAnnotation { repeated Property properties = 9; } +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // The BCP-47 language code, such as "en-US" or "sr-Latn". For more + // information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + // Set of features pertaining to the image, computed by computer vision // methods over safe-search verticals (for example, adult, spoof, medical, // violence). @@ -569,6 +592,10 @@ message AnnotateImageResponse { // If present, label detection has completed successfully. repeated EntityAnnotation label_annotations = 4; + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + // If present, text (OCR) detection has completed successfully. repeated EntityAnnotation text_annotations = 5; diff --git a/src/v1/doc/google/cloud/vision/v1/doc_image_annotator.js b/src/v1/doc/google/cloud/vision/v1/doc_image_annotator.js index f1e6c00b..9ab159a3 100644 --- a/src/v1/doc/google/cloud/vision/v1/doc_image_annotator.js +++ b/src/v1/doc/google/cloud/vision/v1/doc_image_annotator.js @@ -107,7 +107,12 @@ var Feature = { /** * Run web detection. */ - WEB_DETECTION: 10 + WEB_DETECTION: 10, + + /** + * Run localizer for object detection. + */ + OBJECT_LOCALIZATION: 19 } }; @@ -569,6 +574,36 @@ var EntityAnnotation = { // This is for documentation. Actual contents will be loaded by gRPC. }; +/** + * Set of detected objects with bounding boxes. + * + * @property {string} mid + * Object ID that should align with EntityAnnotation mid. + * + * @property {string} languageCode + * The BCP-47 language code, such as "en-US" or "sr-Latn". For more + * information, see + * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + * + * @property {string} name + * Object name, expressed in its `language_code` language. + * + * @property {number} score + * Score of the result. Range [0, 1]. + * + * @property {Object} boundingPoly + * Image region to which this object belongs. This must be populated. + * + * This object should have the same structure as [BoundingPoly]{@link google.cloud.vision.v1.BoundingPoly} + * + * @typedef LocalizedObjectAnnotation + * @memberof google.cloud.vision.v1 + * @see [google.cloud.vision.v1.LocalizedObjectAnnotation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/image_annotator.proto} + */ +var LocalizedObjectAnnotation = { + // This is for documentation. Actual contents will be loaded by gRPC. +}; + /** * Set of features pertaining to the image, computed by computer vision * methods over safe-search verticals (for example, adult, spoof, medical, @@ -869,6 +904,12 @@ var ImageAnnotationContext = { * * This object should have the same structure as [EntityAnnotation]{@link google.cloud.vision.v1.EntityAnnotation} * + * @property {Object[]} localizedObjectAnnotations + * If present, localized object detection has completed successfully. + * This will be sorted descending by confidence score. + * + * This object should have the same structure as [LocalizedObjectAnnotation]{@link google.cloud.vision.v1.LocalizedObjectAnnotation} + * * @property {Object[]} textAnnotations * If present, text (OCR) detection has completed successfully. * diff --git a/src/v1/doc/google/protobuf/doc_any.js b/src/v1/doc/google/protobuf/doc_any.js index f55fa17f..c5c5bbaf 100644 --- a/src/v1/doc/google/protobuf/doc_any.js +++ b/src/v1/doc/google/protobuf/doc_any.js @@ -97,17 +97,18 @@ * } * * @property {string} typeUrl - * A URL/resource name whose content describes the type of the - * serialized protocol buffer message. + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). * - * For URLs which use the scheme `http`, `https`, or no scheme, the - * following restrictions and interpretations apply: + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: * * * If no scheme is provided, `https` is assumed. - * * The last segment of the URL's path must represent the fully - * qualified name of the type (as in `path/google.protobuf.Duration`). - * The name should be in a canonical form (e.g., leading "." is - * not accepted). * * An HTTP GET on the URL must yield a google.protobuf.Type * value in binary format, or produce an error. * * Applications are allowed to cache lookup results based on the @@ -116,6 +117,10 @@ * on changes to types. (Use versioned type names to manage * breaking changes.) * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * * Schemes other than `http`, `https` (or the empty scheme) might be * used with implementation specific semantics. * diff --git a/src/v1p1beta1/doc/google/protobuf/doc_any.js b/src/v1p1beta1/doc/google/protobuf/doc_any.js index f55fa17f..c5c5bbaf 100644 --- a/src/v1p1beta1/doc/google/protobuf/doc_any.js +++ b/src/v1p1beta1/doc/google/protobuf/doc_any.js @@ -97,17 +97,18 @@ * } * * @property {string} typeUrl - * A URL/resource name whose content describes the type of the - * serialized protocol buffer message. + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). * - * For URLs which use the scheme `http`, `https`, or no scheme, the - * following restrictions and interpretations apply: + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: * * * If no scheme is provided, `https` is assumed. - * * The last segment of the URL's path must represent the fully - * qualified name of the type (as in `path/google.protobuf.Duration`). - * The name should be in a canonical form (e.g., leading "." is - * not accepted). * * An HTTP GET on the URL must yield a google.protobuf.Type * value in binary format, or produce an error. * * Applications are allowed to cache lookup results based on the @@ -116,6 +117,10 @@ * on changes to types. (Use versioned type names to manage * breaking changes.) * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * * Schemes other than `http`, `https` (or the empty scheme) might be * used with implementation specific semantics. * diff --git a/src/v1p2beta1/doc/google/protobuf/doc_any.js b/src/v1p2beta1/doc/google/protobuf/doc_any.js index f55fa17f..c5c5bbaf 100644 --- a/src/v1p2beta1/doc/google/protobuf/doc_any.js +++ b/src/v1p2beta1/doc/google/protobuf/doc_any.js @@ -97,17 +97,18 @@ * } * * @property {string} typeUrl - * A URL/resource name whose content describes the type of the - * serialized protocol buffer message. + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). * - * For URLs which use the scheme `http`, `https`, or no scheme, the - * following restrictions and interpretations apply: + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: * * * If no scheme is provided, `https` is assumed. - * * The last segment of the URL's path must represent the fully - * qualified name of the type (as in `path/google.protobuf.Duration`). - * The name should be in a canonical form (e.g., leading "." is - * not accepted). * * An HTTP GET on the URL must yield a google.protobuf.Type * value in binary format, or produce an error. * * Applications are allowed to cache lookup results based on the @@ -116,6 +117,10 @@ * on changes to types. (Use versioned type names to manage * breaking changes.) * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * * Schemes other than `http`, `https` (or the empty scheme) might be * used with implementation specific semantics. * diff --git a/src/v1p3beta1/doc/google/protobuf/doc_any.js b/src/v1p3beta1/doc/google/protobuf/doc_any.js index f55fa17f..c5c5bbaf 100644 --- a/src/v1p3beta1/doc/google/protobuf/doc_any.js +++ b/src/v1p3beta1/doc/google/protobuf/doc_any.js @@ -97,17 +97,18 @@ * } * * @property {string} typeUrl - * A URL/resource name whose content describes the type of the - * serialized protocol buffer message. + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). * - * For URLs which use the scheme `http`, `https`, or no scheme, the - * following restrictions and interpretations apply: + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: * * * If no scheme is provided, `https` is assumed. - * * The last segment of the URL's path must represent the fully - * qualified name of the type (as in `path/google.protobuf.Duration`). - * The name should be in a canonical form (e.g., leading "." is - * not accepted). * * An HTTP GET on the URL must yield a google.protobuf.Type * value in binary format, or produce an error. * * Applications are allowed to cache lookup results based on the @@ -116,6 +117,10 @@ * on changes to types. (Use versioned type names to manage * breaking changes.) * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * * Schemes other than `http`, `https` (or the empty scheme) might be * used with implementation specific semantics. * diff --git a/src/v1p3beta1/doc/google/protobuf/doc_field_mask.js b/src/v1p3beta1/doc/google/protobuf/doc_field_mask.js index c82c2b33..d700752b 100644 --- a/src/v1p3beta1/doc/google/protobuf/doc_field_mask.js +++ b/src/v1p3beta1/doc/google/protobuf/doc_field_mask.js @@ -218,6 +218,12 @@ * Note that oneof type names ("test_oneof" in this case) cannot be used in * paths. * + * ## Field Mask Verification + * + * The implementation of any API method which has a FieldMask type field in the + * request should verify the included field paths, and return an + * `INVALID_ARGUMENT` error if any path is duplicated or unmappable. + * * @property {string[]} paths * The set of field mask paths. * diff --git a/src/v1p3beta1/doc/google/protobuf/doc_timestamp.js b/src/v1p3beta1/doc/google/protobuf/doc_timestamp.js index a02db52b..51d8f40f 100644 --- a/src/v1p3beta1/doc/google/protobuf/doc_timestamp.js +++ b/src/v1p3beta1/doc/google/protobuf/doc_timestamp.js @@ -79,7 +79,9 @@ * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone - * is required, though only UTC (as indicated by "Z") is presently supported. + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). * * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past * 01:30 UTC on January 15, 2017. @@ -90,8 +92,8 @@ * to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) * with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one * can use the Joda Time's [`ISODateTimeFormat.dateTime()`](https://cloud.google.com - * http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()) - * to obtain a formatter capable of generating timestamps in this format. + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime-- + * ) to obtain a formatter capable of generating timestamps in this format. * * @property {number} seconds * Represents seconds of UTC time since Unix epoch From 47052c680d74d97ec98213d955ea49a871c8ed82 Mon Sep 17 00:00:00 2001 From: Jonathan Lui Date: Fri, 31 Aug 2018 12:17:41 -0700 Subject: [PATCH 2/3] fix(test): v1 now supports object localization, use v1p1beta1 for tests that assert the method doesnt exist --- test/helpers.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/helpers.test.js b/test/helpers.test.js index 449e9426..8c83fe6d 100644 --- a/test/helpers.test.js +++ b/test/helpers.test.js @@ -513,8 +513,8 @@ describe('Vision helper methods', () => { }); it('throws an error if trying to invoke a method not available in current version', () => { - // Use v1 version of client. - const client = new vision.v1.ImageAnnotatorClient(CREDENTIALS); + // Use v1p1beta1 version of client. + const client = new vision.v1p1beta1.ImageAnnotatorClient(CREDENTIALS); assert.throws(() => { // Object localization is only available for v1p3beta1. From c4b82176e458ac0ffb13b290c45929f72a02b14d Mon Sep 17 00:00:00 2001 From: Jonathan Lui Date: Fri, 31 Aug 2018 12:25:43 -0700 Subject: [PATCH 3/3] npm run prettier --- samples/system-test/detect.test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/samples/system-test/detect.test.js b/samples/system-test/detect.test.js index 2f7bc2c0..412bbca9 100644 --- a/samples/system-test/detect.test.js +++ b/samples/system-test/detect.test.js @@ -215,7 +215,7 @@ test(`should detect similar web images in a local file`, async t => { t.true(output.includes('Description: Google Cloud Platform')); } - if (webDetection.bestGuessLabels.length) { + if (webDetection.bestGuessLabels.length) { t.true(output.includes('Best guess labels found')); t.true(output.includes('Label:')); } @@ -227,7 +227,9 @@ test(`should detect similar web images in a remote file`, async t => { cwd ); - const [results] = await client.webDetection(`gs://${bucketName}/${files[5].name}`); + const [results] = await client.webDetection( + `gs://${bucketName}/${files[5].name}` + ); const webDetection = results[0].webDetection; if (webDetection.fullMatchingImages.length) { @@ -243,7 +245,7 @@ test(`should detect similar web images in a remote file`, async t => { t.true(output.includes('Description: Google Cloud Platform')); } - if (webDetection.bestGuessLabels.length) { + if (webDetection.bestGuessLabels.length) { t.true(output.includes('Best guess labels found')); t.true(output.includes('Label:')); }