Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arbitrary request options to single-feature helpers. #2555

Merged
merged 6 commits into from
Nov 3, 2017

Conversation

lukesneeringer
Copy link
Contributor

@lukesneeringer lukesneeringer commented Aug 23, 2017

⚠️ Includes Breaking Change

Requests to all Vision methods must be in the full format of an AnnotateImageRequest.


@jmdobry @stephenplusplus This is my pass at addressing #2553. It is definitely intended to be up for discussion.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 23, 2017
@@ -74,11 +74,12 @@ var coerceImage = (image, callback) => {
* asking for the single feature annotation.
*/
var _createSingleFeatureMethod = featureValue => {
return function(image, options) {
return this.annotateImage({
return function(image, options = {}, callOptions = undefined) {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


// Ensure the feature value indicated by the user's method choice exists on the
// features array; if it does not, add it.
var found = false;

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -196,6 +210,9 @@ module.exports = apiVersion => {
*
* If the key is `content`, the value should be a Buffer.
* @param {Object=} options
* Any additional options which should be mapped onto the

This comment was marked as spam.

This comment was marked as spam.

Copy link
Contributor

@jmdobry jmdobry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for possible Node v4 compat issue, LGTM.

// the precise method called, throw an exception.
for (let feature of annotateImageRequest.features) {
if (feature.type !== featureValue) {
throw new Error(

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@stephenplusplus stephenplusplus added the api: vision Issues related to the Cloud Vision API. label Aug 28, 2017
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling cec6f85 on lukesneeringer:issue-2553 into 5c7035b on GoogleCloudPlatform:master.

@googleapis googleapis deleted a comment from coveralls Sep 12, 2017
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Sep 12, 2017
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 616b1c0 on lukesneeringer:issue-2553 into 5c7035b on GoogleCloudPlatform:master.

@stephenplusplus
Copy link
Contributor

This is stuck on linting errors:

> google-cloud-node@ lint C:\projects\google-cloud-node
> jshint scripts/ packages/ system-test/ test/ && jscs packages/ system-test/ test/
Expected indentation of 0 characters at packages/vision/src/helpers.js :
    74 | *   asking for the single feature annotation.
    75 | */
    76 | var _createSingleFeatureMethod = featureValue => {
--------^
    77 |   return function(annotateImageRequest, callOptions) {
    78 |     annotateImageRequest.features = annotateImageRequest.features || [{
Expected indentation of 2 characters at packages/vision/src/helpers.js :
    75 | */
    76 | var _createSingleFeatureMethod = featureValue => {
    77 |   return function(annotateImageRequest, callOptions) {
----------^
    78 |     annotateImageRequest.features = annotateImageRequest.features || [{
    79 |       type: featureValue,
Expected indentation of 0 characters at packages/vision/src/helpers.js :
    94 |     return this.annotateImage(annotateImageRequest, callOptions);
    95 |   };
    96 | };
--------^
    97 |
    98 |
3 code style er> google-cloud-node@ lint C:\projects\google-cloud-node
> jshint scripts/ packages/ system-test/ test/ && jscs packages/ system-test/ test/
Expected indentation of 0 characters at packages/vision/src/helpers.js :
    74 | *   asking for the single feature annotation.
    75 | */
    76 | var _createSingleFeatureMethod = featureValue => {
--------^
    77 |   return function(annotateImageRequest, callOptions) {
    78 |     annotateImageRequest.features = annotateImageRequest.features || [{
Expected indentation of 2 characters at packages/vision/src/helpers.js :
    75 | */
    76 | var _createSingleFeatureMethod = featureValue => {
    77 |   return function(annotateImageRequest, callOptions) {
----------^
    78 |     annotateImageRequest.features = annotateImageRequest.features || [{
    79 |       type: featureValue,
Expected indentation of 0 characters at packages/vision/src/helpers.js :
    94 |     return this.annotateImage(annotateImageRequest, callOptions);
    95 |   };
    96 | };
--------^
    97 |
    98 |
3 code style er=> google-cloud-node@ lint C:\projects\google-cloud-node
> jshint scripts/ packages/ system-test/ test/ && jscs packages/ system-test/ test/
Expected indentation of 0 characters at packages/vision/src/helpers.js :
    74 | *   asking for the single feature annotation.
    75 | */
    76 | var _createSingleFeatureMethod = featureValue => {
--------^
    77 |   return function(annotateImageRequest, callOptions) {
    78 |     annotateImageRequest.features = annotateImageRequest.features || [{
Expected indentation of 2 characters at packages/vision/src/helpers.js :
    75 | */
    76 | var _createSingleFeatureMethod = featureValue => {
    77 |   return function(annotateImageRequest, callOptions) {
----------^
    78 |     annotateImageRequest.features = annotateImageRequest.features || [{
    79 |       type: featureValue,
Expected indentation of 0 characters at packages/vision/src/helpers.js :
    94 |     return this.annotateImage(annotateImageRequest, callOptions);
    95 |   };
    96 | };
--------^
    97 |
    98 |

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 11c885c on lukesneeringer:issue-2553 into 84d4969 on GoogleCloudPlatform:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vision Issues related to the Cloud Vision API. cla: no This human has *not* signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants