-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Adding a C# example for Cloud ML Engine's online prediction API #290
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
Conversation
|
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. |
|
Fixed my email address to avoid CLA bot warning. |
|
|
||
| try | ||
| { | ||
| Person person = new Person |
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.
Minor comment -- I'd expect you should be able to use dynamic here rather than have to define a Person class and use strong typing, just for filling in a bunch of fields.
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 originally did that, but then thought user in production probably has structured data. If, in fact, anonymous types are pretty ubiquitous, happy to change.
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.
Well, you're already using dynamic in dealing with the response, as well as an anonymous type in constructing the request (new { instances = instances }) itself ... hence this bit might as well do the same.
| client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearer_token); | ||
|
|
||
| var version_suffix = version == null ? "" : $"/version/{version}"; | ||
| var model_uri = $"projects/{project}/models/{model}{version_suffix}"; |
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.
From a style point of view, C# code doesn't use underscores. This would be modelUri.
| } | ||
|
|
||
| // [START predict_json] | ||
| static async Task<dynamic> Predict(String project, String model, List<Person> instances, String version = null) |
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.
In the total nit category -- was slightly bugging me to see model and version parameters separated apart. Signature could be (instances, project, model, version). :)
No description provided.