-
Notifications
You must be signed in to change notification settings - Fork 16
Conversation
Here is the summary of changes. You added 3 region tags.
This comment is generated by snippet-bot.
|
…ejs-ai-platform into enhanced-lib-try3
Codecov Report
@@ Coverage Diff @@
## master #22 +/- ##
==========================================
- Coverage 98.85% 98.81% -0.04%
==========================================
Files 12 15 +3
Lines 20173 20493 +320
Branches 544 575 +31
==========================================
+ Hits 19942 20251 +309
- Misses 223 234 +11
Partials 8 8
Continue to review full report at Codecov.
|
src/decorator.ts
Outdated
const namespace = | ||
namespaceName in rootNamespace | ||
? rootNamespace[namespaceName] | ||
: undefined; |
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.
You don't have to use a ternary here, rootNamespace[namespaceName]
will be undefined
if it's not there, so just const namespace = rootNamespace[namespaceName]
is equivalent to this code
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.
src/decorator.ts
Outdated
|
||
// Get the namespace object from JSON | ||
const namespaceJsonObject = | ||
namespaceName in jsonNode ? jsonNode[namespaceName] : undefined; |
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.
same as ↑↑
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.
src/decorator.ts
Outdated
} | ||
|
||
// Assign the toValue() and fromValue() helper methods to the enhanced message objects. | ||
// tslint:disable-next-line no-any |
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 disable-next-line should be moved one line down I think?
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.
src/helpers.ts
Outdated
const value = googleProtobufValueFromObject(obj, (val: any) => { | ||
return val; | ||
}); | ||
if (typeof value !== 'undefined') { |
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 if
, combined with the final return undefined
, can be replaced with just return value;
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.
src/helpers.ts
Outdated
return undefined; | ||
} | ||
|
||
export function fromValue(value: any): object | null | undefined { |
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.
tslint-disable-next-line?
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.
src/value-converter.ts
Outdated
|
||
// TODO(): Remove this file once https://github.com/protobufjs/protobuf.js/pull/1495 is submitted. | ||
export function googleProtobufValueFromObject( | ||
object: any, |
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.
tslint-disable-next-line?
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.
synth.py
Outdated
@@ -29,6 +29,19 @@ | |||
library = gapic.node_library(name, version) | |||
s.copy(library, excludes=["package.json", "README.md"]) | |||
|
|||
# Expose helper module | |||
index_file = 'src/index.ts' |
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.
So here I always wonder if we should do this or just exclude src/index.ts
from the generation (line 30) and just have src/index.ts
unchanged by the synthtool. Up to you here :)
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.
I think I'm going to err on the side of patching the library after generation, for now. We're doing some patching after the fact in the Python library too. @bcoe , your input gratefully accepted.
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 I'm following this regex, we're simply matching the end of the file? I think I like this approach for now 👍 as it allows us to add new clients via automation, without manual intervention -- let's try it.
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.
Awesome, thank you! I'm happy to work with you on potential better solutions in the future.
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.
Per conversation over chat, we decided to not do any post-processing in synth.py and instead exclude the hand-written files from being overwritten.
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.
LGTM with some nits, all of them minor
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 few very minor nits, you folks did incredible work pulling this together this week.
@@ -12,3 +12,4 @@ system-test/*key.json | |||
.DS_Store | |||
package-lock.json | |||
__pycache__ | |||
.vscode |
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 should consider moving .gitignore
into a template, @sofisl does your library generation tool populate the file now?
) { | ||
// [START aiplatform_create_training_pipeline_image_classification] | ||
/** | ||
* TODO(developer): Uncomment these variables before running the sample.\ |
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.
no need for the break \
on the end of the line, for multiline comments.
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.
stdout, | ||
/Create training pipeline image classification response/ | ||
); | ||
trainingPipelineId = stdout |
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.
I could imagine this assertion becoming a bit fragile, I'd just test for:
assert.match(stdout, /\/locations\/us-central1\/trainingPipelines\//)
Like above.
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.
src/decorator.ts
Outdated
// Walk the tree of nested namespaces contained within the enhanced-types.json file | ||
function walkNamespaces( | ||
// tslint:disable-next-line no-any | ||
jsonNode: Record<string, any>, |
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.
would it silence these warnings if we we gave a slightly more specific type hint like Record<string, object>
?
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.
Changed.
Unfortunately no, setting those to Record<string, object>
didn't work.
I tried to provide define / provide types as much as possible in the recent commits. However, in some cases I needed to cast to unknown
before casting to another type. In two specific cases, I wasn't able to work around using any--both uses are deep within the bowels of internal functions. (Even so, I'll continue to noodle on ways to address this issue.)
synth.py
Outdated
@@ -29,6 +29,19 @@ | |||
library = gapic.node_library(name, version) | |||
s.copy(library, excludes=["package.json", "README.md"]) | |||
|
|||
# Expose helper module | |||
index_file = 'src/index.ts' |
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 I'm following this regex, we're simply matching the end of the file? I think I like this approach for now 👍 as it allows us to add new clients via automation, without manual intervention -- let's try it.
} | ||
} | ||
// [END aiplatform_create_training_pipeline_image_classification] | ||
await createTrainingPipelineImageClassification(); |
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 method call needs to be inside of the region tag, or the code the customer pastes will never be run 🙃 Here and anywhere else in the samples please.
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.
@telpirion if you take this approach, then the await
should be dropped. @sofisl @fhinkel, it would be good to update the sample policies to include uncaughtRejections
, so that we properly exit with status code 1
, even when we're not awaiting.
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.
samples/package.json
Outdated
@@ -13,7 +13,9 @@ | |||
"test": "mocha --timeout 600000 test/*.js" | |||
}, | |||
"dependencies": { | |||
"@google-cloud/aiplatform": "^1.0.0" | |||
"@google-cloud/aiplatform": "^1.0.0", | |||
"chai": "^4.2.0", |
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.
chai
, and I'm guessing uuid
, should be devDependencies
if they are not strictly required to run the application code. Dependencies only used in tests go in devDependencies
.
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 uuid = require('uuid').v4; | ||
const cp = require('child_process'); | ||
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); | ||
const cwd = path.join(__dirname, '..'); |
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.
Probably don't need to define or use cwd
anywhere here - generally leaving it out works fine.
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.
.split('\n')[0]; | ||
}); | ||
|
||
after('should cancel the training pipeline and delete it', async () => { |
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.
Similar feedback left recently for @lucaswadedavis - for any of these after
hooks, you can't reasonably promise they will always run. If the process crashes, server goes down, someone locally hits CTRL-C - the resources created here will be abandoned. This eventually leads to quota errors, or lagging performance problems as the number of resources grow. We should add some code in the beginning of the test suite that does resource cleanup, reaping any old resources that should have been cleaned up but got missed here.
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.
Resolved over chat--will follow up with clean up function soon.
src/decorator.ts
Outdated
// Walk the tree of nested namespaces contained within the enhanced-types.json file | ||
function walkNamespaces( | ||
// tslint:disable-next-line no-any | ||
jsonNode: Record<string, any>, |
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.
Please treat any lint warnings as errors (we are going to fix this soon)
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.
Changed (as much as I could). There are still two uses of any
that I haven't been able to work around yet (in value-converters.ts
). I'll continue to look for ways to remove any
where used.
synth.py
Outdated
@@ -29,6 +29,19 @@ | |||
library = gapic.node_library(name, version) | |||
s.copy(library, excludes=["package.json", "README.md"]) | |||
|
|||
# Expose helper module | |||
index_file = 'src/index.ts' |
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.
Danger! We very much don't want to make code specific changes like this in synth.py
if it can be avoided. Can we double click here and talk about what's happening with @alexander-fenster and @bcoe ?
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.
Yes, this one is obviously a ❄️ . We have a plan to think how these exceptions (libraries augmented by extra stuff, like speech, vision, and this one) can be avoided, this is something I will look into in Q1.
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.
After chatting with @alexander-fenster and @sofisl , I've reverted the changes to synth.py so that we exclude the handwritten changes from being over written (rather than having custom post-processing steps in synth.py).
This PR adds the following to the AI Platform library:
After this pull request is submitted, these tasks are required for follow-up: