Skip to content

Conversation

@cjac
Copy link

@cjac cjac commented Jan 4, 2023

Fixes customer issue

An example of how to create a vertex-ai managed notebook using the Java SDK

@cjac cjac requested review from a team and yoshi-approver as code owners January 4, 2023 02:08
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jan 4, 2023
@cjac
Copy link
Author

cjac commented Jan 4, 2023

Hi there Les!

Looking forward to your review.

@kweinmeister
Copy link
Contributor

FYI @balajismaniam @ivanmkc

Copy link
Contributor

@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.

It should work, but really you can simplify things for the user and yourself.

Comment on lines +10 to +11
Project ID
Project Number
Copy link
Contributor

Choose a reason for hiding this comment

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

Why both?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just use ADC? Ideally gcloud auth login or gcloud auth application-default login should be sufficient.

Copy link
Author

Choose a reason for hiding this comment

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

yeah, good point. The code used to require them. I fixed it in the code but forgot to update the docs.

Copy link
Author

Choose a reason for hiding this comment

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

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}[email protected]" \
--role="roles/notebooks.admin"

Comment on lines +18 to +19
private static String serviceAccount = "[email protected]";
private static String parentProject = "projects/example-project-id/locations/us-central1";
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these hard coded?
You can get them from ADC

Copy link
Author

Choose a reason for hiding this comment

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

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.

Comment on lines +19 to +20
directory with the value of $(eval echo
"io.grpc.internal.PickFirstLoadBalancerProvider")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be inside backticks? (code font)

![in the cloud console](img/project-view.png).

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
Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

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)

Comment on lines +32 to +38
`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`
Copy link
Contributor

Choose a reason for hiding this comment

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

You might be able to get away with just using mvn clean package

Comment on lines +46 to +56
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}[email protected]" \
--role="roles/notebooks.admin"
```
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +17 to +18
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely shouldn't be 1.7, 11 is a better choice these days.

Comment on lines +68 to +76
<!-- 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>
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems a bit excessive.

@lesv
Copy link
Contributor

lesv commented Jan 4, 2023

The key things:

  • Learn about auth and how it works with ML.
  • Learn about how testing works. (things are obviously failing now)
  • You really haven't written any tests, please fix that.

@lesv lesv assigned cjac and unassigned lesv Jan 6, 2023
@averikitsch averikitsch added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 6, 2023
@averikitsch
Copy link
Contributor

Please reopen when development restarts, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Indicates a pull request not ready for merge, due to either quality or timing. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants