mirror of
https://github.com/wassname/ray.git
synced 2026-06-30 08:46:01 +08:00
[Core] Allow users to specify the classpath and import path (#10560)
* move job resource path to job config * job resource path support list * job resource path support for python * fix job_resource_path support * fix worker command * fix job config * use jar file instead of parent path * fix job resource path * add test to test.sh * lint * Update java/runtime/src/main/resources/ray.default.conf Co-authored-by: Kai Yang <kfstorm@outlook.com> * fix testGetFunctionFromLocalResource * lint * fix rebase * add jars in resource path to classloader * add job_resource_path to worker * add ray stop * rename job_resource_path to resource_path * fix resource_path * refine resource_path comments * rename job resource path to code search path * Add instruction about starting a cross-language cluster * fix ClassLoaderTest.java * add code-search-path to RunManager * refine comments for code-search-path * rename resourcePath to codeSearchPath * Update doc * fix * rename resourcePath to codeSearchPath * update doc * filter out empty path * fix comments * fix comments * fix tests * revert pom * lint * fix doc * update doc * Apply suggestions from code review * lint Co-authored-by: Kai Yang <kfstorm@outlook.com> Co-authored-by: Hao Chen <chenh1024@gmail.com>
This commit is contained in:
+21
-23
@@ -11,16 +11,15 @@ import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import redis
|
||||
|
||||
import colorama
|
||||
import colorful as cf
|
||||
import psutil
|
||||
# Ray modules
|
||||
import ray
|
||||
import ray.ray_constants as ray_constants
|
||||
import psutil
|
||||
|
||||
import redis
|
||||
from ray.autoscaler.cli_logger import cli_logger
|
||||
import colorful as cf
|
||||
|
||||
resource = None
|
||||
if sys.platform != "win32":
|
||||
@@ -71,11 +70,6 @@ DEFAULT_WORKER_EXECUTABLE = os.path.join(
|
||||
os.path.abspath(os.path.dirname(__file__)),
|
||||
"core/src/ray/cpp/default_worker" + EXE_SUFFIX)
|
||||
|
||||
DEFAULT_JAVA_WORKER_CLASSPATH = [
|
||||
os.path.join(
|
||||
os.path.abspath(os.path.dirname(__file__)), "../../../build/java/*"),
|
||||
]
|
||||
|
||||
# Logger for this module. It should be configured at the entry point
|
||||
# into the program using Ray. Ray provides a default configuration at
|
||||
# entry/init points.
|
||||
@@ -1282,7 +1276,8 @@ def start_raylet(redis_address,
|
||||
socket_to_use=None,
|
||||
head_node=False,
|
||||
start_initial_python_workers_for_first_job=False,
|
||||
object_spilling_config=None):
|
||||
object_spilling_config=None,
|
||||
code_search_path=None):
|
||||
"""Start a raylet, which is a combined local scheduler and object manager.
|
||||
|
||||
Args:
|
||||
@@ -1320,6 +1315,9 @@ def start_raylet(redis_address,
|
||||
include_java (bool): If True, the raylet backend can also support
|
||||
Java worker.
|
||||
java_worker_options (list): The command options for Java worker.
|
||||
code_search_path (list): Code search path for worker. code_search_path
|
||||
is added to worker command in non-multi-tenancy mode and job_config
|
||||
in multi-tenancy mode.
|
||||
Returns:
|
||||
ProcessInfo for the process that was started.
|
||||
"""
|
||||
@@ -1348,16 +1346,15 @@ def start_raylet(redis_address,
|
||||
gcs_ip_address, gcs_port = redis_address.split(":")
|
||||
|
||||
if include_java is True:
|
||||
default_cp = os.pathsep.join(DEFAULT_JAVA_WORKER_CLASSPATH)
|
||||
java_worker_command = build_java_worker_command(
|
||||
json.loads(java_worker_options)
|
||||
if java_worker_options else ["-classpath", default_cp],
|
||||
json.loads(java_worker_options) if java_worker_options else [],
|
||||
redis_address,
|
||||
node_manager_port,
|
||||
plasma_store_name,
|
||||
raylet_name,
|
||||
redis_password,
|
||||
session_dir,
|
||||
code_search_path,
|
||||
)
|
||||
else:
|
||||
java_worker_command = []
|
||||
@@ -1384,6 +1381,8 @@ def start_raylet(redis_address,
|
||||
f"--config-list={config_str}", f"--temp-dir={temp_dir}",
|
||||
f"--metrics-agent-port={metrics_agent_port}"
|
||||
]
|
||||
if code_search_path:
|
||||
start_worker_command.append(f"--code-search-path={code_search_path}")
|
||||
if redis_password:
|
||||
start_worker_command += [f"--redis-password={redis_password}"]
|
||||
|
||||
@@ -1398,6 +1397,9 @@ def start_raylet(redis_address,
|
||||
if max_worker_port is None:
|
||||
max_worker_port = 0
|
||||
|
||||
if code_search_path is not None and len(code_search_path) > 0:
|
||||
load_code_from_local = True
|
||||
|
||||
if load_code_from_local:
|
||||
start_worker_command += ["--load-code-from-local"]
|
||||
|
||||
@@ -1493,15 +1495,10 @@ def get_ray_jars_dir():
|
||||
return os.path.abspath(os.path.join(current_dir, "jars"))
|
||||
|
||||
|
||||
def build_java_worker_command(
|
||||
java_worker_options,
|
||||
redis_address,
|
||||
node_manager_port,
|
||||
plasma_store_name,
|
||||
raylet_name,
|
||||
redis_password,
|
||||
session_dir,
|
||||
):
|
||||
def build_java_worker_command(java_worker_options, redis_address,
|
||||
node_manager_port, plasma_store_name,
|
||||
raylet_name, redis_password, session_dir,
|
||||
code_search_path):
|
||||
"""This method assembles the command used to start a Java worker.
|
||||
|
||||
Args:
|
||||
@@ -1512,6 +1509,7 @@ def build_java_worker_command(
|
||||
raylet_name (str): The name of the raylet socket to create.
|
||||
redis_password (str): The password of connect to redis.
|
||||
session_dir (str): The path of this session.
|
||||
code_search_path (list): Teh job code search path.
|
||||
Returns:
|
||||
The command string for starting Java worker.
|
||||
"""
|
||||
@@ -1532,7 +1530,7 @@ def build_java_worker_command(
|
||||
pairs.append(("ray.home", RAY_HOME))
|
||||
pairs.append(("ray.logging.dir", os.path.join(session_dir, "logs")))
|
||||
pairs.append(("ray.session-dir", session_dir))
|
||||
|
||||
pairs.append(("ray.job.code-search-path", code_search_path))
|
||||
command = ["java"] + ["-D{}={}".format(*pair) for pair in pairs]
|
||||
|
||||
command += ["RAY_WORKER_RAYLET_CONFIG_PLACEHOLDER"]
|
||||
|
||||
Reference in New Issue
Block a user