Move setproctitle to ray[debug] package (#3415)

This commit is contained in:
Eric Liang
2018-11-27 09:50:59 -08:00
committed by Robert Nishihara
parent 20b8b1d891
commit 0d56fc10cc
8 changed files with 28 additions and 13 deletions
+3 -2
View File
@@ -56,8 +56,9 @@ class MemoryMonitor(object):
if not psutil:
logger.warning(
"WARNING: Not monitoring node memory since `psutil` is not "
"installed. Install this with `pip install psutil` to enable "
"debugging of memory-related crashes.")
"installed. Install this with `pip install psutil` "
"(or ray[debug]) to enable debugging of memory-related "
"crashes.")
def raise_if_low_memory(self):
if not psutil:
+1 -1
View File
@@ -651,7 +651,7 @@ def stack():
COMMAND = """
pyspy=`which py-spy`
if [ ! -e "$pyspy" ]; then
echo "ERROR: Please 'pip install py-spy' first"
echo "ERROR: Please 'pip install py-spy' (or ray[debug]) first"
exit 1
fi
# Set IFS to iterate over lines instead of over words.
+2 -1
View File
@@ -236,7 +236,8 @@ class TrialRunner(object):
return "Memory usage on this node: {}/{} GB{}".format(
round(used_gb, 1), round(total_gb, 1), warn)
except ImportError:
return "Unknown memory usage (`pip install psutil` to resolve)"
return ("Unknown memory usage. Please run `pip install psutil` "
"(or ray[debug]) to resolve)")
def has_resources(self, resources):
"""Returns whether this runner has at least the specified resources."""
+15 -4
View File
@@ -12,7 +12,6 @@ import logging
import numpy as np
import os
import redis
import setproctitle
import signal
import sys
import threading
@@ -73,6 +72,15 @@ DEFAULT_ACTOR_CREATION_CPUS_SPECIFIED_CASE = 1
# using logging.basicConfig in its entry/init points.
logger = logging.getLogger(__name__)
try:
import setproctitle
except ImportError:
setproctitle = None
logger.warning(
"WARNING: Not updating worker name since `setproctitle` is not "
"installed. Install this with `pip install setproctitle` "
"(or ray[debug]) to enable monitoring of worker processes.")
class RayTaskError(Exception):
"""An object used internally to represent a task that threw an exception.
@@ -1916,7 +1924,8 @@ def connect(info,
# Initialize some fields.
if mode is WORKER_MODE:
worker.worker_id = random_string()
setproctitle.setproctitle("ray_worker")
if setproctitle:
setproctitle.setproctitle("ray_worker")
else:
# This is the code path of driver mode.
if driver_id is None:
@@ -2163,9 +2172,11 @@ def disconnect(worker=global_worker):
@contextmanager
def _changeproctitle(title, next_title):
setproctitle.setproctitle(title)
if setproctitle:
setproctitle.setproctitle(title)
yield
setproctitle.setproctitle(next_title)
if setproctitle:
setproctitle.setproctitle(next_title)
def _try_to_compute_deterministic_class_id(cls, depth=5):
+4 -2
View File
@@ -64,7 +64,10 @@ else:
optional_ray_files += ray_autoscaler_files
extras = {"rllib": ["pyyaml", "gym[atari]", "opencv-python", "lz4", "scipy"]}
extras = {
"rllib": ["pyyaml", "gym[atari]", "opencv-python", "lz4", "scipy"],
"debug": ["psutil", "setproctitle", "py-spy"],
}
class build_ext(_build_ext.build_ext):
@@ -139,7 +142,6 @@ requires = [
"pytest",
"pyyaml",
"redis",
"setproctitle",
# The six module is required by pyarrow.
"six >= 1.0.0",
"flatbuffers",