-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Automl translation ga #1614
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
Automl translation ga #1614
Conversation
Java 8 is failing. |
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 - Nits that annoy only me, but do at least read them.
datasetId = | ||
bout.toString() | ||
.split("\n")[0] | ||
.split("/")[(bout.toString().split("\n")[0]).split("/").length - 1]; |
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.
should this be using got
instead? perhaps using an intermediate form?
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.
Oops, yep.
Simplified to: datasetId = got.split("Dataset id: ")[1].split("\n")[0];
// LIST MODELS | ||
ListModels.listModels(PROJECT_ID); | ||
String got = bout.toString(); | ||
modelId = got.split("\n")[1].split("/")[got.split("\n")[1].split("/").length - 1]; |
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.
ok, but shouldn't this be more efficient on 2 lines?
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.
Realized I can simplify it to: modelId = got.split("Model id: ")[1].split("\n")[0];
// Display the model information. | ||
System.out.format("Model name: %s\n", model.getName()); | ||
System.out.format( | ||
"Model id: %s\n", model.getName().split("/")[model.getName().split("/").length - 1]); |
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.
Perhaps this should use an intermediate variable?
System.out.println("\tMetadata:"); | ||
System.out.format("\t\tType Url: %s\n", operation.getMetadata().getTypeUrl()); | ||
System.out.format( | ||
"\t\tValue: %s\n", operation.getMetadata().getValue().toStringUtf8().replace("\n", "")); |
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.
ok, but could you clean this up a bit and teach something here?
System.out.println("\tResponse:"); | ||
System.out.format("\t\tType Url: %s\n", operation.getResponse().getTypeUrl()); | ||
System.out.format( | ||
"\t\tValue: %s\n", operation.getResponse().getValue().toStringUtf8().replace("\n", "")); |
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.
ok, but could you clean this up a bit and teach something here?
// Display the model information. | ||
System.out.format("Model name: %s\n", model.getName()); | ||
System.out.format( | ||
"Model id: %s\n", model.getName().split("/")[model.getName().split("/").length - 1]); |
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.
ok, but could you clean this up a bit and teach something here?
System.out.format("Dataset name: %s\n", dataset.getName()); | ||
System.out.format( | ||
"Dataset id: %s\n", | ||
dataset.getName().split("/")[dataset.getName().split("/").length - 1]); |
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.
ok, but could you clean this up a bit and teach something here? Why do I see the same code in two places?
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.
The create
, get
, list
for both datasets and models are all very similar.
System.out.format("Dataset name: %s\n", createdDataset.getName()); | ||
System.out.format( | ||
"Dataset id: %s\n", | ||
createdDataset.getName().split("/")[createdDataset.getName().split("/").length - 1]); |
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.
ok, but could you clean this up a bit and teach something 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.
Would something like this be good?
// To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
// required for other methods.
// Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
int lastIndex = createdDataset.getName().split("/").length - 1;
String datasetId = createdDataset.getName().split("/")[lastIndex];
System.out.format("Dataset id: %s\n", datasetId);
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 was thinking more like:
String[] names = createdDataset.getName().split("/");
String datasetId = names[names.length - 1];
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 will probably keep the comment in there too.
// required for other methods. | ||
// Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}` | ||
String[] names = dataset.getName().split("/"); | ||
String retrievedDatasetId = names[names.length - 1]; |
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.
Thanks -- I'm happy w/ this, though I ran across https://stackoverflow.com/a/15317034/738710 which sadly has a better answer. No need to use it, but for the future:
String retrievedDatasetId = dataset.getName().substring( sentence.lastIndexOf("/") + 1);
BTW - Java 8 is failing. |
Ah, I see why. That's the old beta files. |
DO_NOT_DELETE BRANCH |
Files moved to: #1621 |
* Convert samples to new style guides and update to GA. Add missing samples * Update samples and tests * Update ExportDataset.java * Update Prediction.java * Update based on feedback * Update ListOperationStatus.java * Update ID of test dataset * Lint: Update License header and import order
* Convert samples to new style guides and update to GA. Add missing samples * Update samples and tests * Update ExportDataset.java * Update Prediction.java * Update based on feedback * Update ListOperationStatus.java * Update ID of test dataset * Lint: Update License header and import order
* Convert samples to new style guides and update to GA. Add missing samples * Update samples and tests * Update ExportDataset.java * Update Prediction.java * Update based on feedback * Update ListOperationStatus.java * Update ID of test dataset * Lint: Update License header and import order
* Convert samples to new style guides and update to GA. Add missing samples * Update samples and tests * Update ExportDataset.java * Update Prediction.java * Update based on feedback * Update ListOperationStatus.java * Update ID of test dataset * Lint: Update License header and import order
No description provided.