Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

google cloud run scoring implementation #156

Merged
merged 8 commits into from
Feb 13, 2020
Merged

Conversation

nkpng2k
Copy link
Contributor

@nkpng2k nkpng2k commented Feb 11, 2020

First attempt at scoring implementation that works for google cloud run, on customer request for scoring option in gcp.

@osery I tried to make this as minimalist as possible so there is almost no copy paste. I had to make a few things in the local rest scorer public in order to do so though, but I think nothing too scary.

basically the only difference between this and local rest scorer is that it tries to download mojo and license from gcs before starting

@nkpng2k nkpng2k requested review from mmalohlava and osery February 11, 2020 01:07
Copy link
Contributor

@osery osery left a comment

Choose a reason for hiding this comment

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

Could we get away without the config file and the controller file? We could just do the downloading and call the local-rest-scorer's main. No need to have anything spring related. Wdyt? That way we don't risk people accidentally adding stuff here for new endpoints and such.

@nkpng2k nkpng2k requested a review from osery February 12, 2020 00:09
@nkpng2k
Copy link
Contributor Author

nkpng2k commented Feb 12, 2020

@osery Thank you for the fast review. Made some changes as per your recommendations let me know what you think when you have the chance. Thanks!

Copy link
Contributor

@osery osery left a comment

Choose a reason for hiding this comment

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

Thanks for all the changes @nkpng2k 🙏.
LGTM, only nits left.

I created a PR #157 which may be unneeded now. But still probably makes sense to have it...


// Docker image configuration.
jib {
extraDirectories {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not need this, no? Should be brought in as the dependency already, I think 🤔.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes it technically is. Some weird issue with jib from what I could find... regarding this and the below comment. One of the jib issues I found while googling up on this: GoogleContainerTools/jib#954. But long story short is that jib doesn't use the springboot bootjar as one would expect, but takes the .class files created inside the build dir of the project. So the required local-rest-scorer .class files don't get added to the classpath and things don't work.

Side Note: we could use arg containerizingMode = 'packaged' which essentially places the actual boot jar into the classpath and we can then override the entrypoint, but it increases the size of the resultant docker image by nearly 30% so I figured this to be the less impactful method.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to mark the bootJar in local-rest-scorer as archiveClassifier = "boot" so that the dependency in the gcp one actually brings in the plain jar as opposed to the bootJar (which has a special form and the ScorerApplication class is well hidden deep inside it).

I tried it removing the extraDirectories and extraClasspath and it seems to work.

I would personally rather use that than the packaged mode. Not pushing though.

More context: https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/#packaging-executable-and-normal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh this looks interesting. Let me try quickly. If it works I will push a change before the merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@osery this worked great! can't believe I didn't notice this. Thanks! Made change to remove extraDirectories and extraClasspath values and added archiveClassifier = 'boot' to local-rest-scorer build.gradle

ran the docker image for local rest scorer and updated readme with correct jar for local run.

gcp-cloud-run/build.gradle Outdated Show resolved Hide resolved
@nkpng2k nkpng2k force-pushed the npng/master/google-cloud-run branch from 14b9fe4 to 2ace036 Compare February 12, 2020 18:00
Copy link
Contributor

@osery osery left a comment

Choose a reason for hiding this comment

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

LGTM, assuming the proposed fix work.

I have one more possibly late comment. Did you think about other providers? E.g., AWS?
Should we have some naming convention in the subprojects and possibly also the resulting docker images?

For example: local-rest-scorer, gcp-rest-scorer, aws-rest-scorer, ...? Wdyt? Or maybe even better rest-scorer-local, rest-scorer-gcp, ...


// Docker image configuration.
jib {
extraDirectories {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to mark the bootJar in local-rest-scorer as archiveClassifier = "boot" so that the dependency in the gcp one actually brings in the plain jar as opposed to the bootJar (which has a special form and the ScorerApplication class is well hidden deep inside it).

I tried it removing the extraDirectories and extraClasspath and it seems to work.

I would personally rather use that than the packaged mode. Not pushing though.

More context: https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/#packaging-executable-and-normal

@nkpng2k
Copy link
Contributor Author

nkpng2k commented Feb 13, 2020

LGTM, assuming the proposed fix work.

I have one more possibly late comment. Did you think about other providers? E.g., AWS?
Should we have some naming convention in the subprojects and possibly also the resulting docker images?

For example: local-rest-scorer, gcp-rest-scorer, aws-rest-scorer, ...? Wdyt? Or maybe even better rest-scorer-local, rest-scorer-gcp, ...

I really like the above comment... let us open an issue for it and handle it separately. One thing to keep in mind though is that we should likely keep the product in the name somewhere. So I agree, but caveat: rest-scorer-local, rest-scorer-gcp-cloud-run, rest-scorer-aws-lambda, rest-scorer-aws-sagemaker. Either that or nest the projects to a dir structure:

dai-deployment-templates
|-- aws
    |-- lambda
    |-- sagemaker
|-- gcp
    |-- cloud-run
|-- local

wdyt?

@nkpng2k nkpng2k merged commit f48205a into master Feb 13, 2020
@nkpng2k nkpng2k deleted the npng/master/google-cloud-run branch February 13, 2020 19:41
@nkpng2k
Copy link
Contributor Author

nkpng2k commented Feb 13, 2020

@osery just fyi, merged and opened a new issue #159 to track your above comment. Hope this is ok. We can address anything I missed in an additional pr. Sorry if merged prematurely...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants