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] improve Java API module #2783

Merged
merged 17 commits into from
Sep 2, 2018

Conversation

raulchen
Copy link
Contributor

@raulchen raulchen commented Aug 31, 2018

API module (ray/java/api dir) includes all public APIs provided by Ray, it should be the only module that normal Ray users need to face.

The purpose of this PR to first improve the code quality of the API module. Subsequent PRs will improve other modules later. The changes of this PR include the following aspects:

  1. Only keep interfaces in api module, to hide implementation details from users and fix circular dependencies among modules.
  2. Document everything in the api module.
  3. Improve naming.
  4. Add more tests for API.
  5. Also fix/improve related code in other modules.
  6. Remove some unused code.

(Apologize for posting such a large PR. Java worker code has been lack of maintenance for a while. There're a lot of code quality issues that need to be fixed. We plan to use a couple of large PRs to address them. After that, future changes will come in small PRs.)

@raulchen
Copy link
Contributor Author

cc @jovan-wong @guoyuhong

@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/7898/
Test FAILed.

@robertnishihara
Copy link
Collaborator

jenkins, retest this please

@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/7901/
Test FAILed.

@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/7899/
Test FAILed.

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.

Left some comments. The others look pretty good to me.

return ins;
}

public static RayParameters getParams() {
return params;
}

public abstract void cleanUp();
public abstract void shutdown();
Copy link
Contributor

Choose a reason for hiding this comment

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

@Override

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch

* RayObject<T> is a handle for T object, which may or may not be available now.
* That said, RayObject can be viewed as a Future object with metadata.
* Represents an object in the object store.
* @param <T> The object type.
Copy link
Contributor

Choose a reason for hiding this comment

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

@param <T> The primitive type of an object. ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's actually a non-primitive type. In java, primitive types are int, long, double, boolean, etc.


private final List<RayObject<T>> readyOnes;
private final List<RayObject<T>> remainOnes;
private final List<RayObject<T>> ready;
Copy link
Contributor

Choose a reason for hiding this comment

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

readys and unreadys

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ready is an adjective, not a noun.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it allowed to use an adj to represent a member in Java?

public class RayCallGenerator extends BaseGenerator {

/**
* @return whole file content of `RayCall.java`
Copy link
Contributor

Choose a reason for hiding this comment

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

Whole

RayObject<Integer> result8 = Ray.call(Adder::testObjectList, adder);
Assert.assertEquals(11, (int) result8.get());
public int incr(int delta) {
value += delta;
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 increase would be better.
But this is a test file, it's ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

incr is a commonly used in code as an abbreviation of increase. I think it would not cause ambiguity here.

RayLog.core.info(methods2.toString());

Assert.assertEquals(methods2.functions.size(), 9);
Assert.assertEquals(methods2.staticFunctions.size(), 1);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

one more line

@@ -15,6 +14,6 @@ public void testRunStarted(Description description) {

@Override
public void testRunFinished(Result result) {
RayRuntime.getInstance().cleanUp();
Ray.shutdown();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

also a new line.

@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/7945/
Test PASSed.

@robertnishihara robertnishihara merged commit 3b0a2c4 into ray-project:master Sep 2, 2018
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.

4 participants