Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

feat: added endpoint samples for vision api#467

Merged
bcoe merged 12 commits into
masterfrom
api-endpoints
Oct 29, 2019
Merged

feat: added endpoint samples for vision api#467
bcoe merged 12 commits into
masterfrom
api-endpoints

Conversation

@bradmiro

@bradmiro bradmiro commented Oct 24, 2019

Copy link
Copy Markdown
Contributor

These samples are being added for showing how to change the endpoint of vision api calls

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 24, 2019
@codecov

codecov Bot commented Oct 24, 2019

Copy link
Copy Markdown

Codecov Report

Merging #467 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #467   +/-   ##
=======================================
  Coverage   97.61%   97.61%           
=======================================
  Files           3        3           
  Lines          84       84           
=======================================
  Hits           82       82           
  Misses          2        2

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dcc4d62...348ae3e. Read the comment docs.

@JustinBeckwith JustinBeckwith requested review from bcoe and removed request for JustinBeckwith October 24, 2019 20:14
@bradmiro bradmiro changed the title Added endpoint samples for vision api feat: added endpoint samples for vision api Oct 24, 2019
@bradmiro

Copy link
Copy Markdown
Contributor Author

I believe the docs test is failing because there's a link pointing to a file that doesn't exist in the main repo yet, but is included in this PR

@bcoe bcoe left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this looks most of the way there, but the sample format is just slightly off. I shared an example of format as documented in internal docs.

Comment thread samples/setEndpoint.js
'use strict';

async function setEndpoint() {
// [START vision_set_endpoint]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a tiny bit of, the START should be above the sendEndpoint method, so that the example code includes both the start of the function and the closing }.

The sample guidelines also suggest that we have an outer function that handles command line arguments, and then an inner async function, see:

function main(arg1 = 'default_value_one', arg2 = 1234) {
  // [START your_region_tag]
  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  // const arg1 = 'default_value_one';
  // const arg2 = 1234;

  // Imports the Google Cloud Some API library
  const {SomeApiClient} = require('@google-cloud/some-api');

  // Instantiates a client
  const someApiClient = new SomeApiClient();

  async function doSomething() {
    ...
  }

  doSomething();
  // [END your_region_tag]
}

main(...process.argv.slice(2));

@bradmiro bradmiro Oct 25, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The intention of the sample is to only highlight that small section of the function, the rest of the function is being left so that the tests still pass as this is a modified version of the quickstart. Sorry, should have mentioned this with the PR.

Here's the Python canonical (within the tags): https://github.com/GoogleCloudPlatform/python-docs-samples/blob/750d2f6d36b1a030f7226067922c8ac3dab3a39b/vision/cloud-client/detect/set_endpoint.py

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

gotcha, what's weird to me, is I think this includes the closing brace, so you end up with:

  // Imports the Google Cloud client library
  const vision = require('@google-cloud/vision');

  // Specifies the location of the api endpoint
  const clientOptions = {apiEndpoint: 'eu-vision.googleapis.com'};

  // Creates a client
  const client = new vision.ImageAnnotatorClient(clientOptions);

  // Performs label detection on the image file
  const [result] = await client.labelDetection('./resources/wakeupcat.jpg');
  const labels = result.labelAnnotations;
  console.log('Labels:');
  labels.forEach(label => console.log(label.description));
}

where the last } is the closing brace for async function setEndpoint() { which is out of context for the algorithm; does the END just need to be brought up a couple lines?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ahh yes! Good catch, it should certainly be a few lines higher. Fixed :)

@bcoe bcoe merged commit 4c569b4 into master Oct 29, 2019
@bcoe bcoe deleted the api-endpoints branch October 29, 2019 01:35
@bradmiro bradmiro restored the api-endpoints branch October 29, 2019 17:14
bradmiro added a commit that referenced this pull request Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants