mirror of
https://github.com/wassname/ray.git
synced 2026-07-21 12:50:45 +08:00
Allow address instead of redis_address (#5412)
* addr * wip * fix typo * add to start * switch to ray address for train * say address * disambiguate help * comments 2
This commit is contained in:
@@ -93,6 +93,38 @@ def include_java_from_redis(redis_client):
|
||||
return redis_client.get("INCLUDE_JAVA") == b"1"
|
||||
|
||||
|
||||
def find_redis_address_or_die():
|
||||
try:
|
||||
import psutil
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Please install `psutil` to automatically detect the Ray cluster.")
|
||||
pids = psutil.pids()
|
||||
redis_addresses = set()
|
||||
for pid in pids:
|
||||
try:
|
||||
proc = psutil.Process(pid)
|
||||
for arglist in proc.cmdline():
|
||||
for arg in arglist.split(" "):
|
||||
if arg.startswith("--redis-address="):
|
||||
addr = arg.split("=")[1]
|
||||
redis_addresses.add(addr)
|
||||
except psutil.AccessDenied:
|
||||
pass
|
||||
except psutil.NoSuchProcess:
|
||||
pass
|
||||
if len(redis_addresses) > 1:
|
||||
raise ConnectionError(
|
||||
"Found multiple active Ray instances: {}. ".format(redis_addresses)
|
||||
+ "Please specify the one to connect to by setting `address`.")
|
||||
sys.exit(1)
|
||||
elif not redis_addresses:
|
||||
raise ConnectionError(
|
||||
"Could not find any running Ray instance. "
|
||||
"Please specify the one to connect to by setting `address`.")
|
||||
return redis_addresses.pop()
|
||||
|
||||
|
||||
def get_address_info_from_redis_helper(redis_address,
|
||||
node_ip_address,
|
||||
redis_password=None):
|
||||
|
||||
Reference in New Issue
Block a user