-
Notifications
You must be signed in to change notification settings - Fork 14
feat(samples): adds samples for enhanced version of library #16
Conversation
Here is the summary of changes. You added 16 region tags.
This comment is generated by snippet-bot.
|
Codecov Report
@@ Coverage Diff @@
## master #16 +/- ##
==========================================
+ Coverage 98.80% 98.82% +0.01%
==========================================
Files 15 15
Lines 20493 20493
Branches 575 575
==========================================
+ Hits 20249 20253 +4
+ Misses 236 232 -4
Partials 8 8
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple initial comments for you.
@@ -8,5 +8,5 @@ env_vars: { | |||
|
|||
env_vars: { | |||
key: "SECRET_MANAGER_KEYS" | |||
value: "nodejs-ai-platform-env" | |||
value: "nodejs-ai-platform-env, ucaip_samples_secrets" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll need to add .kokoro/presubmit/node12/samples-test.cfg
to excludes, in synth.py
, so that it's not overwritten when the templates update nightly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
// Create batch prediction job request | ||
const [response] = await jobServiceClient.createBatchPredictionJob(request); | ||
|
||
console.log(`Create batch prediction job video classification response`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log(`Create batch prediction job video classification response`); | |
console.log('Create batch prediction job video classification response'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a problem across all of these samples. I've addressed them in spots, where I've found them, but we need to root them all out.
I've logged issue #38 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think we can mark #38 as fixed with this PR. I've removed all of the console.log
statements with the unneeded back ticks.
|
||
const modelParameters = modelParamsObj.toValue(); | ||
|
||
const inputConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's enough setup here, that I would be tempted to add a couple comments that include links to the corresponding documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
const dedicatedResource = response.dedicatedResource; | ||
console.log(`\tDedicated resources`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of logic here for the printing logic, I'd be tempted to see if I could abstract it a bit into a helper, that's also between the START
/END
blocks, something like:
function printDedicatedResource(dedicatedResource) {
}
function printCompletionStats () {
}
...
If you moved these down to the bottom of the sample, I think you would draw better attention to the more important part of samples which is the calls to the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. Earlier versions of the Python canonicals had more verbose responses printed out. Now they're much shorter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty much ready to go to me, I think we'll want to address the await
issue I brought up, as it will make the samples embed better on cloud site.
console.log(response); | ||
} | ||
// [END aiplatform_create_batch_prediction_job_video_classification] | ||
await createBatchPredictionJobVideoClassification(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't have the createBatchPredictionJobVideoClassification
inside the snippet, we'll show example code that doesn't actually invoke to the customer, instead do:
createBatchPredictionJobVideoClassification();
Dropping the await
.
And you can add this:
rocess.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
Just above your invocation of main
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
console.log(response); | ||
} | ||
// [END aiplatform_create_training_pipeline_text_sentiment_analysis] | ||
await createTrainingPipelineTextSentimentAnalysis(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we'll need to address the await
issue across the samles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
console.log('Create batch prediction job video classification response'); | ||
console.log(`Name : ${response.name}`); | ||
console.log('Raw response:'); | ||
console.log(response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an object with nested keys, you might want to do:
console.log(JSON.stringify(response, null, 2));
I like this approach a lot better than having a huge amount of logic for printing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
🤖 I have created a release \*beep\* \*boop\* --- ## [1.3.0](https://www.github.com/googleapis/nodejs-ai-platform/compare/v1.2.0...v1.3.0) (2021-01-14) ### Features * **samples:** adds samples for enhanced version of library ([#16](https://www.github.com/googleapis/nodejs-ai-platform/issues/16)) ([aef443c](https://www.github.com/googleapis/nodejs-ai-platform/commit/aef443c41b8a9a2199e0c5b100a5ab91444b0dfe)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This PR updates the following samples to use the enhanced client library:
This PR relies on the PR that contains the enhanced client library.