Skip to content

Commit

Permalink
[Java][API CHANGE] Rename mode SINGLE_PROCESS to LOCAL (ray-proje…
Browse files Browse the repository at this point in the history
…ct#24714)

for aligning to the key concept local mode, this PR renames SINGLE_PROCESS to LOCAL.
  • Loading branch information
jovany-wang committed May 19, 2022
1 parent 502c3e1 commit cc621ff
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ public interface RuntimeContext {
/** Returns true if the current actor was restarted, otherwise false. */
boolean wasCurrentActorRestarted();

/**
* Returns true if Ray is running in single-process mode, false if Ray is running in cluster mode.
*/
boolean isSingleProcess();
/** Returns true if Ray is running in local mode, false if Ray is running in cluster mode. */
boolean isLocalMode();

/** Get all node information in Ray cluster. */
List<NodeInfo> getAllNodeInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ private BaseActorHandle createActorImpl(
LOGGER.debug("Creating Actor {}, jvmOptions = {}.", functionDescriptor, options.jvmOptions);
}
}
if (rayConfig.runMode == RunMode.SINGLE_PROCESS
&& functionDescriptor.getLanguage() != Language.JAVA) {
if (rayConfig.runMode == RunMode.LOCAL && functionDescriptor.getLanguage() != Language.JAVA) {
throw new IllegalArgumentException(
"Ray doesn't support cross-language invocation in local mode.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public RayRuntime createRayRuntime() {
try {
logger.debug("Initializing runtime with config: {}", rayConfig);
AbstractRayRuntime innerRuntime =
rayConfig.runMode == RunMode.SINGLE_PROCESS
rayConfig.runMode == RunMode.LOCAL
? new RayDevRuntime(rayConfig)
: new RayNativeRuntime(rayConfig);
RayRuntimeInternal runtime = innerRuntime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public RayConfig(Config config) {
boolean isDriver = workerMode == WorkerType.DRIVER;
// Run mode.
if (config.hasPath("ray.local-mode")) {
runMode = config.getBoolean("ray.local-mode") ? RunMode.SINGLE_PROCESS : RunMode.CLUSTER;
runMode = config.getBoolean("ray.local-mode") ? RunMode.LOCAL : RunMode.CLUSTER;
} else {
runMode = config.getEnum(RunMode.class, "ray.run-mode");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public enum RunMode {
* Ray is running in one single Java process, without Raylet backend, object store, and GCS. It's
* useful for debug.
*/
SINGLE_PROCESS,
LOCAL,

/** Ray is running on one or more nodes, with multiple processes. */
CLUSTER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public TaskId getCurrentTaskId() {

@Override
public boolean wasCurrentActorRestarted() {
if (isSingleProcess()) {
if (isLocalMode()) {
return false;
}
return runtime.getGcsClient().wasCurrentActorRestarted(getCurrentActorId());
}

@Override
public boolean isSingleProcess() {
return RunMode.SINGLE_PROCESS == runtime.getRayConfig().runMode;
public boolean isLocalMode() {
return RunMode.LOCAL == runtime.getRayConfig().runMode;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions java/runtime/src/main/resources/ray.default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ ray {

// Run mode, available options are:
//
// `SINGLE_PROCESS`: Ray is running in one single Java process, without Raylet backend,
// object store, and GCS. It's useful for debug.
// `LOCAL`: Ray is running in one single Java process, without Raylet backend,
// object store, and GCS. It's useful for debug.
// `CLUSTER`: Ray is running on one or more nodes, with multiple processes.
run-mode: CLUSTER

Expand Down
2 changes: 1 addition & 1 deletion java/serve/src/main/java/io/ray/serve/RayServeMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public enum RayServeMetrics {
public static final String TAG_REPLICA = "replica";

private static final boolean canBeUsed =
Ray.isInitialized() && !Ray.getRuntimeContext().isSingleProcess();
Ray.isInitialized() && !Ray.getRuntimeContext().isLocalMode();

private static volatile boolean enabled = true;

Expand Down
7 changes: 3 additions & 4 deletions java/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ run_testng() {
# exit_code == 2 means there are skipped tests.
if [ $exit_code -ne 2 ] && [ $exit_code -ne 0 ] ; then
# Only print log files if it ran in cluster mode
if [[ ! "$*" =~ SINGLE_PROCESS ]]; then
if [[ ! "$*" =~ LOCAL ]]; then
if [ $exit_code -gt 128 ] ; then
# Test crashed. Print the driver log for diagnosis.
cat /tmp/ray/session_latest/logs/java-core-driver-*$pid*
Expand Down Expand Up @@ -101,9 +101,8 @@ while true; do
fi
done

echo "Running tests under single-process mode."
# bazel test //java:all_tests --jvmopt="-Dray.run-mode=SINGLE_PROCESS" --config=ci || single_exit_code=$?
run_testng java -Dray.run-mode="SINGLE_PROCESS" -cp "$ROOT_DIR"/../bazel-bin/java/all_tests_shaded.jar org.testng.TestNG -d /tmp/ray_java_test_output "$ROOT_DIR"/testng.xml
echo "Running tests under local mode."
run_testng java -Dray.run-mode="LOCAL" -cp "$ROOT_DIR"/../bazel-bin/java/all_tests_shaded.jar org.testng.TestNG -d /tmp/ray_java_test_output "$ROOT_DIR"/testng.xml

echo "Running connecting existing cluster tests."
case "${OSTYPE}" in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.testng.Assert;
import org.testng.annotations.Test;

public class SingleProcessModeTest extends BaseTest {
public class LocalModeTest extends BaseTest {

private static final int NUM_ACTOR_INSTANCE = 10;

Expand All @@ -25,7 +25,7 @@ public long getThreadId() {
}
}

@Test(groups = {"singleProcess"})
@Test(groups = {"local"})
public void testActorTasksInOneThread() {
List<ActorHandle<MyActor>> actors = new ArrayList<>();
Map<ActorId, Long> actorThreadIds = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void testInDriver() {
testMultiThreading();
}

// Single-process mode doesn't have real workers.
// Local mode doesn't have real workers.
@Test(groups = {"cluster"})
public void testInWorker() {
ObjectRef<String> obj = Ray.task(MultiThreadingTest::testMultiThreading).remote();
Expand Down
2 changes: 1 addition & 1 deletion java/test/src/main/java/io/ray/test/PlasmaFreeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void testDeleteObjects() {
.wait(ImmutableList.of(((ObjectRefImpl<String>) helloId).getId()), 1, 0, true)
.get(0),
50);
if (TestUtils.isSingleProcessMode()) {
if (TestUtils.isLocalMode()) {
Assert.assertTrue(result);
} else {
// The object will not be deleted under cluster mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public class RayAlterSuiteListener implements IAlterSuiteListener {
@Override
public void alter(List<XmlSuite> suites) {
XmlSuite suite = suites.get(0);
String excludedGroup =
RayConfig.create().runMode == RunMode.SINGLE_PROCESS ? "cluster" : "singleProcess";
String excludedGroup = RayConfig.create().runMode == RunMode.LOCAL ? "cluster" : "local";
XmlGroups groups = new XmlGroups();
XmlRun run = new XmlRun();
run.onExclude(excludedGroup);
Expand Down
4 changes: 2 additions & 2 deletions java/test/src/main/java/io/ray/test/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public LargeObject(int size) {

private static final int WAIT_INTERVAL_MS = 5;

public static boolean isSingleProcessMode() {
return getRuntime().getRayConfig().runMode == RunMode.SINGLE_PROCESS;
public static boolean isLocalMode() {
return getRuntime().getRayConfig().runMode == RunMode.LOCAL;
}

/**
Expand Down

0 comments on commit cc621ff

Please sign in to comment.