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

Commit 8b42e76

Browse files
Benjamin E. CoeJustinBeckwith
authored andcommitted
feat: add .repo-metadata.json; allows us to generate new docs site (#183)
1 parent 1ef0ac5 commit 8b42e76

6 files changed

Lines changed: 221 additions & 40 deletions

File tree

.repo-metadata.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "automl",
3+
"name_pretty": "Cloud AutoML",
4+
"product_documentation": "https://cloud.google.com/automl/docs/",
5+
"client_documentation": "https://cloud.google.com/nodejs/docs/reference/automl/latest/",
6+
"issue_tracker": "https://issuetracker.google.com/savedsearches/559744",
7+
"release_level": "beta",
8+
"language": "nodejs",
9+
"repo": "googleapis/nodejs-automl",
10+
"distribution_name": "@google-cloud/automl",
11+
"api_id": "automl.googleapis.com",
12+
"requires_billing": true
13+
}

README.md

Lines changed: 100 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,135 @@
11
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
2-
[//]: # "To regenerate it, use `npm run generate-scaffolding`."
2+
[//]: # "To regenerate it, use `python -m synthtool`."
33
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
44

55
# [Cloud AutoML: Node.js Client](https://github.com/googleapis/nodejs-automl)
66

7-
[![release level](https://img.shields.io/badge/release%20level-alpha-orange.svg?style&#x3D;flat)](https://cloud.google.com/terms/launch-stages)
7+
[![release level](https://img.shields.io/badge/release%20level-beta-yellow.svg?style=flat)](https://cloud.google.com/terms/launch-stages)
88
[![npm version](https://img.shields.io/npm/v/@google-cloud/automl.svg)](https://www.npmjs.org/package/@google-cloud/automl)
99
[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-automl/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-automl)
1010

11-
Train high quality custom machine learning models with minimum effort and machine learning expertise
1211

1312

14-
* [Using the client library](#using-the-client-library)
13+
14+
Cloud AutoML API client for Node.js
15+
16+
17+
* [Cloud AutoML Node.js Client API Reference][client-docs]
18+
* [Cloud AutoML Documentation][product-docs]
19+
* [github.com/googleapis/nodejs-automl](https://github.com/googleapis/nodejs-automl)
20+
21+
Read more about the client libraries for Cloud APIs, including the older
22+
Google APIs Client Libraries, in [Client Libraries Explained][explained].
23+
24+
[explained]: https://cloud.google.com/apis/docs/client-libraries-explained
25+
26+
**Table of contents:**
27+
28+
29+
* [Quickstart](#quickstart)
30+
* [Before you begin](#before-you-begin)
31+
* [Installing the client library](#installing-the-client-library)
32+
* [Using the client library](#using-the-client-library)
33+
* [Samples](#samples)
1534
* [Versioning](#versioning)
1635
* [Contributing](#contributing)
1736
* [License](#license)
1837

19-
## Using the client library
38+
## Quickstart
2039

21-
1. [Select or create a Cloud Platform project][projects].
40+
### Before you begin
2241

42+
1. [Select or create a Cloud Platform project][projects].
2343
1. [Enable billing for your project][billing].
24-
2544
1. [Enable the Cloud AutoML API][enable_api].
26-
2745
1. [Set up authentication with a service account][auth] so you can access the
2846
API from your local workstation.
2947

30-
1. Install the client library:
48+
### Installing the client library
49+
50+
```bash
51+
npm install @google-cloud/automl
52+
```
3153

32-
npm install --save @google-cloud/automl
3354

34-
1. Try an example:
55+
### Using the client library
3556

3657
```javascript
37-
// TBD
58+
const automl = require('@google-cloud/automl');
59+
const fs = require('fs');
60+
61+
// Create client for prediction service.
62+
const client = new automl.PredictionServiceClient();
63+
64+
/**
65+
* TODO(developer): Uncomment the following line before running the sample.
66+
*/
67+
// const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`;
68+
// const computeRegion = `region-name, e.g. "us-central1"`;
69+
// const modelId = `id of the model, e.g. “ICN723541179344731436”`;
70+
// const filePath = `local text file path of content to be classified, e.g. "./resources/flower.png"`;
71+
// const scoreThreshold = `value between 0.0 and 1.0, e.g. "0.5"`;
72+
73+
// Get the full path of the model.
74+
const modelFullId = client.modelPath(projectId, computeRegion, modelId);
75+
76+
// Read the file content for prediction.
77+
const content = fs.readFileSync(filePath, 'base64');
78+
79+
const params = {};
80+
81+
if (scoreThreshold) {
82+
params.score_threshold = scoreThreshold;
83+
}
84+
85+
// Set the payload by giving the content and type of the file.
86+
const payload = {};
87+
payload.image = {imageBytes: content};
88+
89+
// params is additional domain-specific parameters.
90+
// currently there is no additional parameters supported.
91+
const [response] = await client.predict({
92+
name: modelFullId,
93+
payload: payload,
94+
params: params,
95+
});
96+
console.log(`Prediction results:`);
97+
response.payload.forEach(result => {
98+
console.log(`Predicted class name: ${result.displayName}`);
99+
console.log(`Predicted class score: ${result.classification.score}`);
100+
});
101+
38102
```
39103

40104

41-
The [AutoML Node.js Client API Reference][client-docs] documentation
105+
106+
## Samples
107+
108+
Samples are in the [`samples/`](https://github.com/googleapis/nodejs-automl/tree/master/samples) directory. The samples' `README.md`
109+
has instructions for running the samples.
110+
111+
| Sample | Source Code | Try it |
112+
| --------------------------- | --------------------------------- | ------ |
113+
| Quickstart | [source code](https://github.com/googleapis/nodejs-automl/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-automl&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
114+
115+
116+
117+
The [Cloud AutoML Node.js Client API Reference][client-docs] documentation
42118
also contains samples.
43119

44120
## Versioning
45121

46122
This library follows [Semantic Versioning](http://semver.org/).
47123

48-
This library is considered to be in **alpha**. This means it is still a
49-
work-in-progress and under active development. Any release is subject to
50-
backwards-incompatible changes at any time.
124+
125+
126+
This library is considered to be in **beta**. This means it is expected to be
127+
mostly stable while we work toward a general availability release; however,
128+
complete stability is not guaranteed. We will address issues and requests
129+
against beta libraries with a high priority.
130+
131+
132+
51133

52134
More Information: [Google Cloud Platform Launch Stages][launch_stages]
53135

@@ -63,21 +145,10 @@ Apache Version 2.0
63145

64146
See [LICENSE](https://github.com/googleapis/nodejs-automl/blob/master/LICENSE)
65147

66-
## What's Next
67-
68-
* [AutoML Documentation][product-docs]
69-
* [AutoML Node.js Client API Reference][client-docs]
70-
* [github.com/googleapis/nodejs-automl](https://github.com/googleapis/nodejs-automl)
71-
72-
Read more about the client libraries for Cloud APIs, including the older
73-
Google APIs Client Libraries, in [Client Libraries Explained][explained].
74-
75-
[explained]: https://cloud.google.com/apis/docs/client-libraries-explained
76-
77148
[client-docs]: https://cloud.google.com/nodejs/docs/reference/automl/latest/
78149
[product-docs]: https://cloud.google.com/automl/docs/
79150
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
80151
[projects]: https://console.cloud.google.com/project
81152
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
82-
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=automl
83-
[auth]: https://cloud.google.com/docs/authentication/getting-started
153+
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=automl.googleapis.com
154+
[auth]: https://cloud.google.com/docs/authentication/getting-started

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@
4646
"eslint-config-prettier": "^4.0.0",
4747
"eslint-plugin-node": "^9.0.0",
4848
"eslint-plugin-prettier": "^3.0.0",
49-
"jsdoc-baseline": "git+https://github.com/hegemonic/jsdoc-baseline.git",
5049
"intelli-espower-loader": "^1.0.1",
5150
"jsdoc": "^3.5.5",
51+
"jsdoc-baseline": "^0.1.0",
52+
"linkinator": "^1.1.2",
5253
"mocha": "^6.0.0",
5354
"nyc": "^14.0.0",
5455
"power-assert": "^1.5.0",
55-
"prettier": "^1.13.5",
56-
"linkinator": "^1.1.2"
56+
"prettier": "^1.13.5"
5757
}
5858
}

samples/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
2+
[//]: # "To regenerate it, use `python -m synthtool`."
3+
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
4+
5+
# [Cloud AutoML: Node.js Samples](https://github.com/googleapis/nodejs-automl)
6+
7+
[![Open in Cloud Shell][shell_img]][shell_link]
8+
9+
10+
11+
## Table of Contents
12+
13+
* [Before you begin](#before-you-begin)
14+
* [Samples](#samples)
15+
* [Quickstart](#quickstart)
16+
17+
## Before you begin
18+
19+
Before running the samples, make sure you've followed the steps outlined in
20+
[Using the client library](https://github.com/googleapis/nodejs-automl#using-the-client-library).
21+
22+
## Samples
23+
24+
25+
26+
### Quickstart
27+
28+
View the [source code](https://github.com/googleapis/nodejs-automl/blob/master/samples/quickstart.js).
29+
30+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-automl&page=editor&open_in_editor=samples/quickstart.js,samples/README.md)
31+
32+
__Usage:__
33+
34+
35+
`node quickstart.js`
36+
37+
38+
39+
40+
41+
42+
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
43+
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-automl&page=editor&open_in_editor=samples/README.md
44+
[product-docs]: https://cloud.google.com/automl/docs/

samples/quickstart.js

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018, Google, Inc.
2+
* Copyright 2019, Google, Inc.
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
55
* You may obtain a copy of the License at
@@ -15,7 +15,60 @@
1515

1616
'use strict';
1717

18-
// [START automl_quickstart]
19-
// TBD
20-
// [END automl_quickstart]
18+
async function main(
19+
projectId,
20+
computeRegion,
21+
modelId,
22+
filePath,
23+
scoreThreshold
24+
) {
25+
// [START automl_quickstart]
26+
const automl = require('@google-cloud/automl');
27+
const fs = require('fs');
2128

29+
// Create client for prediction service.
30+
const client = new automl.PredictionServiceClient();
31+
32+
/**
33+
* TODO(developer): Uncomment the following line before running the sample.
34+
*/
35+
// const projectId = `The GCLOUD_PROJECT string, e.g. "my-gcloud-project"`;
36+
// const computeRegion = `region-name, e.g. "us-central1"`;
37+
// const modelId = `id of the model, e.g. “ICN723541179344731436”`;
38+
// const filePath = `local text file path of content to be classified, e.g. "./resources/flower.png"`;
39+
// const scoreThreshold = `value between 0.0 and 1.0, e.g. "0.5"`;
40+
41+
// Get the full path of the model.
42+
const modelFullId = client.modelPath(projectId, computeRegion, modelId);
43+
44+
// Read the file content for prediction.
45+
const content = fs.readFileSync(filePath, 'base64');
46+
47+
const params = {};
48+
49+
if (scoreThreshold) {
50+
params.score_threshold = scoreThreshold;
51+
}
52+
53+
// Set the payload by giving the content and type of the file.
54+
const payload = {};
55+
payload.image = {imageBytes: content};
56+
57+
// params is additional domain-specific parameters.
58+
// currently there is no additional parameters supported.
59+
const [response] = await client.predict({
60+
name: modelFullId,
61+
payload: payload,
62+
params: params,
63+
});
64+
console.log(`Prediction results:`);
65+
response.payload.forEach(result => {
66+
console.log(`Predicted class name: ${result.displayName}`);
67+
console.log(`Predicted class score: ${result.classification.score}`);
68+
});
69+
// [END automl_quickstart]
70+
}
71+
main(...process.argv.slice(2)).catch(err => {
72+
console.error(err);
73+
process.exitCode = 1;
74+
});

synth.metadata

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"updateTime": "2019-05-21T11:08:09.690003Z",
2+
"updateTime": "2019-05-22T22:20:23.138969Z",
33
"sources": [
44
{
55
"generator": {
@@ -12,15 +12,15 @@
1212
"git": {
1313
"name": "googleapis",
1414
"remote": "https://github.com/googleapis/googleapis.git",
15-
"sha": "32a10f69e2c9ce15bba13ab1ff928bacebb25160",
16-
"internalRef": "249058354"
15+
"sha": "f792303254ea54442d03ca470ffb38930bda7806",
16+
"internalRef": "249516437"
1717
}
1818
},
1919
{
2020
"template": {
2121
"name": "node_library",
2222
"origin": "synthtool.gcp",
23-
"version": "2019.5.2"
23+
"version": "2019.4.10"
2424
}
2525
}
2626
],

0 commit comments

Comments
 (0)