ray-project / ray

Ray is an AI compute engine. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://ray.io
Apache License 2.0
34k stars 5.78k forks source link

[Test Bug] Matching `psutil.Process.name()` doesn't work on macOS #20982

Open kfstorm opened 2 years ago

kfstorm commented 2 years ago

Python workers leverage setproctitle to update the process title to something like ray::IDLE or ray::IDLE_SpillWorker. Sometimes we need to match the titles of processes returned from psutil.process_iter() to get the info of workers. e.g.

https://github.com/ray-project/ray/blob/b3a9d4d87d31255e0871852efaf1ddff7acdc390/python/ray/tests/test_multi_node.py#L69-L79

This works on Linux. However, on macOS, psutil.Process.name() returns the original command line while psutil.Process.cmdline() returns a list of strings with the modified process title included.

> ps 93591
  PID   TT  STAT      TIME COMMAND
93591 s000  S      0:01.57 ray::IDLE
> python -c 'import psutil; proc = psutil.Process(93591); print(proc.name()); print(proc.cmdline());'
python3.7
['ray::IDLE', '', '', '', '', '', '', '', '', '', '', '', '']

As a result, some test cases may not behave correctly on macOS.

stale[bot] commented 2 years ago

Hi, I'm a bot from the Ray team :)

To help human contributors to focus on more relevant issues, I will automatically add the stale label to issues that have had no activity for more than 4 months.

If there is no further activity in the 14 days, the issue will be closed!

You can always ask for help on our discussion forum or Ray's public slack channel.

kfstorm commented 2 years ago

Still valid

stale[bot] commented 2 years ago

Hi, I'm a bot from the Ray team :)

To help human contributors to focus on more relevant issues, I will automatically add the stale label to issues that have had no activity for more than 4 months.

If there is no further activity in the 14 days, the issue will be closed!

You can always ask for help on our discussion forum or Ray's public slack channel.

kfstorm commented 2 years ago

Still valid

stale[bot] commented 1 year ago

Hi, I'm a bot from the Ray team :)

To help human contributors to focus on more relevant issues, I will automatically add the stale label to issues that have had no activity for more than 4 months.

If there is no further activity in the 14 days, the issue will be closed!

You can always ask for help on our discussion forum or Ray's public slack channel.