FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Automl translation ga by nnegrey · Pull Request #1614 · GoogleCloudPlatform/java-docs-samples · GitHub

Automl translation ga - #1614

Merged
nnegrey merged 12 commits into
masterfrom
automl-translation-ga
Oct 17, 2019
Merged

Automl translation ga#1614
nnegrey merged 12 commits into
masterfrom
automl-translation-ga

Conversation

nnegrey commented Oct 14, 2019

Copy link
Copy Markdown
Contributor

No description provided.

nnegrey requested a review from a team October 14, 2019 20:23
googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 14, 2019

lesv commented Oct 14, 2019

Copy link
Copy Markdown
Contributor

Java 8 is failing.

lesv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

should this be using got instead? perhaps using an intermediate form?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

ok, but shouldn't this be more efficient on 2 lines?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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", ""));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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", ""));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

ok, but could you clean this up a bit and teach something here? Why do I see the same code in two places?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

ok, but could you clean this up a bit and teach something here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I was thinking more like:

String[] names = createdDataset.getName().split("/");
String datasetId = names[names.length - 1];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

👍 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];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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);

lesv commented Oct 16, 2019

Copy link
Copy Markdown
Contributor

BTW - Java 8 is failing.

nnegrey commented Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

Ah, I see why. That's the old beta files.
I have a PR to fix those tests: #1606

nnegrey merged commit 6423b40 into master Oct 17, 2019

nnegrey commented Oct 17, 2019
edited
Loading

Copy link
Copy Markdown
Contributor Author

DO_NOT_DELETE BRANCH
TODO: Update docs samples to master branch
TODO: Move samples to refactored location

nnegrey commented Oct 28, 2019

Copy link
Copy Markdown
Contributor Author

Files moved to: #1621

kurtisvg deleted the automl-translation-ga branch November 15, 2019 21:36
bradmiro pushed a commit that referenced this pull request Dec 2, 2019
* 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
Shabirmean pushed a commit that referenced this pull request Nov 17, 2022
* 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
Shabirmean pushed a commit that referenced this pull request Nov 18, 2022
* 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
anguillanneuf pushed a commit that referenced this pull request Dec 5, 2022
* 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL