a small sample to create a managed notebook using the Java SDK#7532
a small sample to create a managed notebook using the Java SDK#7532cjac wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
Conversation
|
Hi there Les! Looking forward to your review. |
lesv
left a comment
There was a problem hiding this comment.
It should work, but really you can simplify things for the user and yourself.
| Project ID | ||
| Project Number |
There was a problem hiding this comment.
Why not just use ADC? Ideally gcloud auth login or gcloud auth application-default login should be sufficient.
There was a problem hiding this comment.
yeah, good point. The code used to require them. I fixed it in the code but forgot to update the docs.
There was a problem hiding this comment.
oh, I still see references to PROJECT_ID and PROJECT_NUMBER in the docs, for instance:
gcloud projects add-iam-policy-binding ${PROJECT_ID} \
--member="serviceAccount:${PROJECT_NUMBER}-compute@developer.gserviceaccount.com" \
--role="roles/notebooks.admin"
| private static String serviceAccount = "000000000007-compute@developer.gserviceaccount.com"; | ||
| private static String parentProject = "projects/example-project-id/locations/us-central1"; |
There was a problem hiding this comment.
Why are these hard coded?
You can get them from ADC
There was a problem hiding this comment.
Thanks. Can you provide an example? I didn't see anything helpful at that linked URL and I couldn't find it with what felt like reasonable queries.
| directory with the value of $(eval echo | ||
| "io.grpc.internal.PickFirstLoadBalancerProvider") |
There was a problem hiding this comment.
Should this be inside backticks? (code font)
| . | ||
|
|
||
| In order to set a default load balancer provider, this maven package has a file | ||
| called io.grpc.LoadBalancerProvider in the java-docs-samples/vertex-ai/managed_notebook/src/main/resources/META-INF/services |
There was a problem hiding this comment.
should you highlight the path?
| directory with the value of $(eval echo | ||
| "io.grpc.internal.PickFirstLoadBalancerProvider") | ||
|
|
||
| - https://stackoverflow.com/questions/55484043/how-to-fix-could-not-find-policy-pick-first-with-google-tts-java-client |
There was a problem hiding this comment.
Perhaps you would want to explain a bit more what the problem is here, and why you picked this solution. (and why they might choose another one in other circumstances)
| `mvn clean compile` | ||
|
|
||
| - [To include all dependencies in this .jar | ||
| file](https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-runnable-jar-with-dependencies-using-maven), | ||
| you would run the following: | ||
|
|
||
| `mvn assembly:single` |
There was a problem hiding this comment.
You might be able to get away with just using mvn clean package
| Be sure that you have granted the notebooks.runtimes.create permission to your | ||
| service account. The roles/notebooks.admin role includes this permission, but | ||
| may be too permissive. If this is the case, consider creating a new role with | ||
| only the permissions necessary. The following is an example of granting the | ||
| notebooks.admin role: | ||
|
|
||
| ```bash | ||
| gcloud projects add-iam-policy-binding ${PROJECT_ID} \ | ||
| --member="serviceAccount:${PROJECT_NUMBER}-compute@developer.gserviceaccount.com" \ | ||
| --role="roles/notebooks.admin" | ||
| ``` |
There was a problem hiding this comment.
Is there a reason you chose this over using gcloud auth application-default login ? We are now setting the billing project with it, or you can at least add that option. It simplifies things, but it's not a production option, but it might better guide production.
For production, you don't want to hard code service accounts, you either get them through an envVar or better from the Metadata server.
| <maven.compiler.source>1.7</maven.compiler.source> | ||
| <maven.compiler.target>1.7</maven.compiler.target> |
There was a problem hiding this comment.
Definitely shouldn't be 1.7, 11 is a better choice these days.
| <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> | ||
| <plugin> | ||
| <artifactId>maven-site-plugin</artifactId> | ||
| <version>3.7.1</version> | ||
| </plugin> | ||
| <plugin> | ||
| <artifactId>maven-project-info-reports-plugin</artifactId> | ||
| <version>3.0.0</version> | ||
| </plugin> |
|
The key things:
|
|
Please reopen when development restarts, thanks! |
Fixes customer issue
An example of how to create a vertex-ai managed notebook using the Java SDK