-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bazel build for JNI code #3918
Conversation
Test PASSed. |
Test PASSed. |
Test FAILed. |
Test PASSed. |
Test FAILed. |
BUILD.bazel
Outdated
""", | ||
mv python $(location ray_pkg) && | ||
mkdir -p $(location ray_pkg)/src/ray/raylet && | ||
for f in $(locations //:raylet_library_java); do if [[ $$f == *".so"* ]]; then cp $$f $(location ray_pkg)/src/ray/raylet/""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is $$
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When put command in """
string, $$variable
is like $variable
in shell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code doesn't seem to be well formatted. You can format it with yapf -i
as the syntax is compatible with Python.
BUILD.bazel
Outdated
"@bazel_tools//src/conditions:windows": "libraylet_library_java.dll", | ||
"@bazel_tools//src/conditions:darwin": "libraylet_library_java.dylib", | ||
"//conditions:default": "libraylet_library_java.so"}) | ||
+ "; fi done &&" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the default output file is always suffixed by .so
, and you want to rename it with different suffixes based on the OS?
It's weird that why it doesn't generate different suffixes in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do that at the beginning, but failed... I used this as a workaround.
@raulchen I tried In this PR, I only wanted to add the JNI for raylet client at the beginning. Then, I found there are many missing pieces for enabling Java. I added the JNI for Plasma Client and Arrow Java library and Raylet Java library. For the 2 java libraries, currently, it is very simple building script as a mark to remind us which is missing. We may later consider how to use it correctly. For example, the binary paths in |
Test PASSed. |
BUILD.bazel
Outdated
name="ray_java_pkg", | ||
srcs=glob([ | ||
"java/*.java", | ||
"java/*.properties", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this, the generated jar file doesn't capture anything.
I think this should be java/**/*.java
, right?
Also, we need to add the external dependencies.
A few more comments:
- instead of defining single big java library, we should probably define each module (api, runtime, test, etc) as a library.
- We should probably follow this tutorial to properly set up the java libraries.
- It seems that you want to set up java libraries later. If so, we should probably remove this
ray_java_pkg
from this PR, because it doesn't actually do anything.
Regarding the format, I can later open a PR to add linter in CI. But I think we can do that before bazel is completely ready. Regarding java libraries, I left some comments in line. |
@pcmoritz I have two questions about this PR.
|
Test FAILed. |
Test PASSed. |
@guoyuhong Bazel doesn't seem to support this at this moment. Tensorflow uses a genrule (see https://github.com/tensorflow/tensorflow/blob/53bd138262df6e141c0e196a262f4ae760c2cf5f/tensorflow/java/BUILD#L418-L427) to do renaming. |
Test PASSed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
What do these changes do?
This PR adds the bazel code to build the Java Raylet Client JNI code. From current cmake process, the output lib name differs in MacOS than in Linux.
Currently, I copy this file to folder
$(location ray_pkg)/src/ray/raylet/
corresponding tobuild/src/ray/raylet
of cmake. I think the final path should be determine in #3898 .Now I can use
find bazel-genfiles/ -name *libraylet_library_java.*
to find the dynamic lib.Related issue number