Skip to content

Commit 385e000

Browse files
authored
[Core] Vendor setproctitle (#53471)
Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
1 parent 1c4ffac commit 385e000

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1861
-166
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ build:clang-cl --per_file_copt="-\\.(asm|S)$@-Werror"
5757
build:msvc-cl --per_file_copt="-\\.(asm|S)$@-WX"
5858
# Ignore warnings for protobuf generated files and external projects.
5959
build --per_file_copt="\\.pb\\.cc$@-w"
60+
build --per_file_copt="src/ray/thirdparty/.*$@-w"
6061
build:linux --per_file_copt="-\\.(asm|S)$,external/.*@-w,-Wno-error=implicit-function-declaration,-Wno-error=unused-function"
6162
build:macos --per_file_copt="-\\.(asm|S)$,external/.*@-w,-Wno-error=implicit-function-declaration,-Wno-error=unused-function,-Wno-missing-template-arg-list-after-template-kw"
6263
# Ignore warnings for host tools, which we generally can't control.

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exclude: |
1010
release/release_logs/|
1111
rllib/tests/data|
1212
thirdparty/patches/|
13+
src/ray/thirdparty/|
1314
doc/external/|
1415
doc/source/
1516
)

BUILD.bazel

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -901,31 +901,6 @@ cc_proto_library(
901901
deps = [":extra_actions_base_proto_lib"],
902902
)
903903

904-
ray_cc_library(
905-
name = "sha256",
906-
srcs = [
907-
"src/ray/thirdparty/sha256.c",
908-
],
909-
hdrs = [
910-
"src/ray/thirdparty/sha256.h",
911-
],
912-
)
913-
914-
ray_cc_library(
915-
name = "aligned_alloc",
916-
srcs = [
917-
"src/ray/thirdparty/aligned_alloc.c",
918-
],
919-
hdrs = [
920-
"src/ray/thirdparty/aligned_alloc.h",
921-
],
922-
)
923-
924-
ray_cc_library(
925-
name = "dlmalloc",
926-
hdrs = ["src/ray/thirdparty/dlmalloc.c"],
927-
)
928-
929904
alias(
930905
name = "hiredis",
931906
actual = "@com_github_redis_hiredis//:hiredis",
@@ -983,6 +958,7 @@ pyx_library(
983958
"//src/ray/util:memory",
984959
"//src/ray/util:stream_redirection",
985960
"//src/ray/util:stream_redirection_options",
961+
"//src/ray/thirdparty/setproctitle:setproctitle",
986962
],
987963
)
988964

LICENSE

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,3 +480,36 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
480480
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
481481
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
482482
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
483+
484+
--------------------------------------------------------------------------------
485+
486+
Code in src/ray/thirdparty/setproctitle is adapted from https://github.com/dvarrazzo/py-setproctitle
487+
488+
BSD 3-Clause License
489+
490+
Copyright (c) 2009, Daniele Varrazzo <daniele.varrazzo@gmail.com>
491+
492+
Redistribution and use in source and binary forms, with or without
493+
modification, are permitted provided that the following conditions are met:
494+
495+
1. Redistributions of source code must retain the above copyright notice, this
496+
list of conditions and the following disclaimer.
497+
498+
2. Redistributions in binary form must reproduce the above copyright notice,
499+
this list of conditions and the following disclaimer in the documentation
500+
and/or other materials provided with the distribution.
501+
502+
3. Neither the name of the copyright holder nor the names of its
503+
contributors may be used to endorse or promote products derived from
504+
this software without specific prior written permission.
505+
506+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
507+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
508+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
509+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
510+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
511+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
512+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
513+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
514+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
515+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ci/env/install-dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ install_thirdparty_packages() {
415415
fi
416416
mkdir -p "${WORKSPACE_DIR}/python/ray/thirdparty_files"
417417
RAY_THIRDPARTY_FILES="$(realpath "${WORKSPACE_DIR}/python/ray/thirdparty_files")"
418-
CC=gcc python -m pip install psutil==5.9.6 setproctitle==1.2.2 colorama==0.4.6 --target="${RAY_THIRDPARTY_FILES}"
418+
CC=gcc python -m pip install psutil==5.9.6 colorama==0.4.6 --target="${RAY_THIRDPARTY_FILES}"
419419
}
420420

421421
install_dependencies() {

ci/env/install-toolchains.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ install_clang() {
5151
}
5252

5353
install_toolchains() {
54-
local uses_clang=1 some_lightweight_target="//:sha256"
54+
local uses_clang=1 some_lightweight_target="//src/ray/thirdparty:sha256"
5555
if bazel aquery --config=get-toolchain --output=textproto "${some_lightweight_target}" |
5656
grep "external_Slocal_Uconfig_Ucc_Cmsvc_Ucompiler_Ufiles" > /dev/null; then
5757
# We detected that we use MSVC, not Clang

ci/lint/check_import_order.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
This script ensures python files conform to ray's import ordering rules.
3-
In particular, we make sure psutil and setproctitle is imported _after_
4-
importing ray due to our bundling of the two libraries.
3+
In particular, we make sure psutil is imported _after_
4+
importing ray due to our bundling of the library.
55
66
Usage:
77
$ python check_import_order.py SOURCE_DIR -s SKIP_DIR
@@ -19,7 +19,7 @@
1919

2020

2121
def check_import(file):
22-
check_to_lines = {"import ray": -1, "import psutil": -1, "import setproctitle": -1}
22+
check_to_lines = {"import ray": -1, "import psutil": -1}
2323

2424
with io.open(file, "r", encoding="utf-8") as f:
2525
for i, line in enumerate(f):
@@ -39,7 +39,7 @@ def check_import(file):
3939
):
4040
check_to_lines[check] = i
4141

42-
for import_lib in ["import psutil", "import setproctitle"]:
42+
for import_lib in ["import psutil"]:
4343
if check_to_lines[import_lib] != -1:
4444
import_psutil_line = check_to_lines[import_lib]
4545
import_ray_line = check_to_lines["import ray"]

ci/lint/format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ fi
353353
check_docstyle
354354

355355
# Ensure import ordering
356-
# Make sure that for every import psutil; import setproctitle
356+
# Make sure that for every import psutil
357357
# There's a import ray above it.
358358

359359
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-python}

doc/source/ray-contribute/development.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,4 +448,4 @@ Then you should run the following commands:
448448
.. code-block:: bash
449449
450450
rm -rf python/ray/thirdparty_files/
451-
python3 -m pip install setproctitle
451+
python3 -m pip install psutil

doc/source/ray-core/miscellaneous.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ And specify a name for tasks (and actor methods too) at task submission time:
6767

6868
.. testcode::
6969

70-
import setproctitle
70+
import psutil
7171

7272
@ray.remote
7373
def f(x):
74-
assert setproctitle.getproctitle() == "ray::special_f"
74+
assert psutil.Process().cmdline()[0] == "ray::special_f"
7575
return x + 1
7676

7777
obj = f.options(name="special_f").remote(3)

0 commit comments

Comments
 (0)