Skip to content
This repository was archived by the owner on Sep 9, 2023. It is now read-only.

samples: adds custom model, action recognition samples and tests #111

Merged
merged 15 commits into from
Dec 16, 2020

Conversation

telpirion
Copy link
Contributor

Adds new code snippets.

@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • samples/snippets/pom.xml

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Dec 11, 2020
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Dec 11, 2020
@snippet-bot
Copy link

snippet-bot bot commented Dec 11, 2020

Here is the summary of changes.

You added 15 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link

Choose a reason for hiding this comment

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

Copyright & license on human created files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ew, I didn't mean to include that. Sorry! I'll remove that from this PR.

Copy link

@lesv lesv left a comment

Choose a reason for hiding this comment

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

Consider comments

Comment on lines 24 to 31
//import com.google.cloud.aiplatform.v1beta1.ClassOfConditionalParameterDecay;
//import com.google.cloud.aiplatform.v1beta1.ClassOfConditionalParameterLearningRate;
//import com.google.cloud.aiplatform.v1beta1.ClassOfDiscreteValueSpec;
//import com.google.cloud.aiplatform.v1beta1.ClassOfDoubleValueSpec;
//import com.google.cloud.aiplatform.v1beta1.ClassOfMetric;
//import com.google.cloud.aiplatform.v1beta1.ClassOfParameter;
//import com.google.cloud.aiplatform.v1beta1.ClassOfParameterSpec;
//import com.google.cloud.aiplatform.v1beta1.ClassOfParentDiscreteValues;
Copy link

Choose a reason for hiding this comment

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

We don't usually leave these in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +53 to +56
PipelineServiceSettings settings =
PipelineServiceSettings.newBuilder()
.setEndpoint("us-central1-aiplatform.googleapis.com:443")
.build();
Copy link

Choose a reason for hiding this comment

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

Why are we doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Acknowledged.

AI Platform doesn't have a global hostname, only locale-specific hostnames.

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a comment to this effect.

Copy link
Contributor Author

@telpirion telpirion Dec 16, 2020

Choose a reason for hiding this comment

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

Acknowledged.

We've used this technique on every single sample in this repo. I'll create a GitHub issue to go back and add a comment in all of the places where we do this.

Comment on lines 72 to 73
// A working docker image can be found at
// gs://cloud-samples-data/ai-platform/mnist_tfrecord/custom_job
Copy link

Choose a reason for hiding this comment

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

If it's a docker image, why not use gcr.io or it's successor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case we are pointing the user to the Dockerfile and its content, since real use cases require the user to build and bring their own.

Value trainingTaskInputs = trainingTaskInputsBuilder.build();
String trainingTaskDefinition =
"gs://google-cloud-aiplatform/schema/trainingjob/definition/custom_task_1.0.0.yaml";
String imageUri = "gcr.io/cloud-aiplatform/prediction/tf-cpu.1-15:latest";
Copy link

Choose a reason for hiding this comment

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

:latest is typically frowned upon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • samples/snippets/pom.xml

@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • samples/snippets/pom.xml

@codecov
Copy link

codecov bot commented Dec 11, 2020

Codecov Report

Merging #111 (e562308) into master (e2d8e42) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #111   +/-   ##
=========================================
  Coverage     78.22%   78.22%           
  Complexity      704      704           
=========================================
  Files            48       48           
  Lines          5124     5124           
  Branches         69       69           
=========================================
  Hits           4008     4008           
  Misses         1027     1027           
  Partials         89       89           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2d8e42...e562308. Read the comment docs.

@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • samples/snippets/pom.xml

@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • samples/snippets/pom.xml

@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • samples/snippets/pom.xml

@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • samples/snippets/pom.xml

@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • samples/snippets/pom.xml

@telpirion telpirion added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 13, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 13, 2020
@telpirion telpirion marked this pull request as ready for review December 14, 2020 00:51
@telpirion telpirion requested a review from a team December 14, 2020 00:51
@telpirion telpirion requested review from a team as code owners December 14, 2020 00:51
@telpirion telpirion requested a review from chingor13 December 14, 2020 00:51
@telpirion
Copy link
Contributor Author

Thank you for the review, @lesv !

@chingor13 : It looks like this PR is still having issues with env vars. Your help is appreciated. Similarly, we accidentally deleted some of our test resources recently. I think that might be causing some of the 'Model is missing' errors in this PR.

Comment on lines 44 to 47
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1</version>
<type>jar</type>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use either Jackson2 or GSON here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 75 to 77
JsonObject jsonModelParameters = Json.createObjectBuilder().build();
Value.Builder modelParametersBuilder = Value.newBuilder();
JsonFormat.parser().merge(jsonModelParameters.toString(), modelParametersBuilder);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is pretty confusing - it looks like jsonModelParameters would be something empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that is correct. You need to pass an empty Value object to the service for that field.

I'll add a note that clarifies this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • samples/snippets/pom.xml

@telpirion telpirion requested a review from chingor13 December 15, 2020 03:21
Copy link
Contributor

@chingor13 chingor13 left a comment

Choose a reason for hiding this comment

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

We should encourage usage of resource name helpers when available - they are more friendly than building the strings from scratch.

BatchPredictionJob batchPredictionJob =
BatchPredictionJob.newBuilder()
.setDisplayName(displayName)
// Format: 'projects/{project}/locations/{location}/models/{model_id}'
Copy link
Contributor

Choose a reason for hiding this comment

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

For any resource name, we should probably demonstrate the resource name helpers:

String model = com.google.cloud.aiplatform.v1beta1.ModelName.of("project", "location", "model").toString();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

DataLabelingJob dataLabelingJob =
DataLabelingJob.newBuilder()
.setDisplayName(displayName)
// Full resource name: projects/{project}/locations/{location}/datasets/{dataset_id}
Copy link
Contributor

Choose a reason for hiding this comment

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

DatasetName.of("project", "location", "dataset");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

"aiplatform.googleapis.com/annotation_set_name",
"data_labeling_job_specialist_pool")
// Full resource name:
// projects/{project}/locations/{location}/specialistPools/{specialist_pool_id}
Copy link
Contributor

Choose a reason for hiding this comment

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

SpecialistPoolName.of("project", "location", "specialistPool");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +53 to +56
PipelineServiceSettings settings =
PipelineServiceSettings.newBuilder()
.setEndpoint("us-central1-aiplatform.googleapis.com:443")
.build();
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a comment to this effect.

@telpirion telpirion merged commit 081f87e into master Dec 16, 2020
@telpirion telpirion deleted the additional-samples branch December 16, 2020 23:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants