Skip to content
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

[Java] Support calling functions returning void #5494

Merged
merged 14 commits into from
Aug 23, 2019

Conversation

raulchen
Copy link
Contributor

@raulchen raulchen commented Aug 21, 2019

Why are these changes needed?

What do these changes do?

  • Support calling functions that return void.
  • In this case, no return value will be put in the object store.
  • Fix the issue that Ray.call can't take a RayFunc with throws Exception declaration.

Related issue number

Linter

  • I've run scripts/format.sh to lint the changes in this PR.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16427/
Test PASSed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16428/
Test PASSed.

@@ -7,5 +7,6 @@
*/
@FunctionalInterface
public interface RayFunc0<R> extends RayFunc {
R apply();

R apply() throws Exception;
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I missed something else, just wondering how does this relate to supporting void return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a small fix for another issue. Without this, Ray.call can't take a RayFunc with throws Exception declaration.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks.

@@ -143,15 +146,15 @@ public RayObject callPy(String moduleName, String functionName, Object[] args,
checkPyArguments(args);
PyFunctionDescriptor functionDescriptor = new PyFunctionDescriptor(moduleName, "",
functionName);
return callNormalFunction(functionDescriptor, args, options);
return callNormalFunction(functionDescriptor, args, 1, options);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a comment somewhere that void return is not supported for cross-lang calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a comment above this line.

Copy link
Member

@kfstorm kfstorm left a comment

Choose a reason for hiding this comment

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

LGTM. Left some comments.

@@ -70,10 +70,10 @@ public TaskExecutor(AbstractRayRuntime runtime) {

List<NativeRayObject> returnObjects = new ArrayList<>();
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
// Find the executable object.
RayFunction rayFunction = runtime.getFunctionManager()
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible that it can't find the method and results in an exception thrown here? Since you moved it out of the try-catch clause, this will make the worker process crash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the method can't be found, this line will only return null, won't throw exceptions.

Copy link
Member

Choose a reason for hiding this comment

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

OK. A NullPointerException would be thrown inside try block and caught by catch block. Then you access rayFunction again in catch block, again a new NullPointerException would be thrown.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. But I think it's desirable to crash worker if rayFunction is null. because it indicates a system bug, not an app-level exception. I'll add a checkNonNull to make it more explicit.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Thanks!

* @param object The object to put.
* @param objectId Object id.
*/
public void put(Object object, ObjectId objectId) {
Copy link
Member

Choose a reason for hiding this comment

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

Since you've added a put method for testing purposes, can you search and update test code not related to this PR? I believe there are some existing test cases which achieve the same by executing objectStore.putRaw(objectStore.serialize(object), objectId).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated testPutWithDuplicateId

Copy link
Contributor

@zhijunfu zhijunfu left a comment

Choose a reason for hiding this comment

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

LGTM. thanks.

Copy link
Contributor

@jovany-wang jovany-wang left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16449/
Test PASSed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16451/
Test PASSed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16461/
Test PASSed.

@raulchen raulchen merged commit 239c177 into ray-project:master Aug 23, 2019
@raulchen raulchen deleted the java_void_func branch August 23, 2019 13:10
@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/16496/
Test FAILed.

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

Successfully merging this pull request may close these issues.

5 participants