Skip to content

Conversation

Copy link

Copilot AI commented Jan 5, 2026

  • Update the docstring for ray.shutdown() in python/ray/_private/worker.py to clarify:
    • When connecting to a remote cluster via ray.init(address="xxx"), ray.shutdown() only disconnects the client and does NOT terminate the remote cluster
    • Only local clusters started by ray.init() will have their processes terminated by ray.shutdown()
    • Clarified that ray.init() without address argument will auto-detect existing clusters
  • Add documentation note to doc/source/ray-core/starting-ray.rst explaining the same behavior difference
  • Review the changes via code_review
  • Run codeql_checker for security scan (no code changes requiring analysis)
Original prompt

对于 ray 官方关于 ray.shutdown 的文档(https://docs.ray.io/en/latest/ray-core/api/doc/ray.shutdown.html#ray.shutdown),在其中并没有明确说明如果是 ray.init(address="xxx") 连接远程集群,则调用 ray.shutdown 并不会终止集群而仅仅会断开客户端连接。只有由 ray.init() 启动的本地集群才会有 ray.shutdown() 关闭。请完善一下这里的文档把这个 case 描述的更具体,我要提给 ray 社区让这块的文档更明确


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 5, 2026 08:20
Co-authored-by: OneSizeFitsQuorum <32640567+OneSizeFitsQuorum@users.noreply.github.com>
Co-authored-by: OneSizeFitsQuorum <32640567+OneSizeFitsQuorum@users.noreply.github.com>
Copilot AI changed the title [WIP] Update ray.shutdown documentation for remote cluster handling Clarify ray.shutdown() behavior for local vs remote clusters Jan 5, 2026
@OneSizeFitsQuorum
Copy link
Owner

@copilot 代码注释部分修改没问题了,请继续修改对应的文档 ray-core/api/doc/ray.shutdown.html 部分简要描述一下即可

Co-authored-by: OneSizeFitsQuorum <32640567+OneSizeFitsQuorum@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 5, 2026

@copilot 代码注释部分修改没问题了,请继续修改对应的文档 ray-core/api/doc/ray.shutdown.html 部分简要描述一下即可

Added a note to doc/source/ray-core/starting-ray.rst explaining the ray.shutdown() behavior difference between local and remote clusters (commit 0c05d58).

The API documentation at ray-core/api/doc/ray.shutdown.html is auto-generated from the Python docstring which was already updated in the previous commits.

@OneSizeFitsQuorum
Copy link
Owner

@copilot 请在 ray-shutdown 文档中也修改。即在这部分文档中添加

ray.shutdown
ray.shutdown(_exiting_interpreter: bool = False)[source]
Disconnect the worker, and terminate processes started by ray.init().

This will automatically run at the end when a Python process that uses Ray exits. It is ok to run this twice in a row. The primary use case for this function is to cleanup state between tests.

Note that this will clear any remote function definitions, actor definitions, and existing actors, so if you wish to use any previously defined remote functions or actors after calling ray.shutdown(), then you need to redefine them. If they were defined in an imported module, then you will need to reload the module.

Parameters
:
_exiting_interpreter – True if this is called by the atexit hook and false otherwise. If we are exiting the interpreter, we will wait a little while to print any extra error messages.

Copy link
Author

Copilot AI commented Jan 5, 2026

@copilot 请在 ray-shutdown 文档中也修改。即在这部分文档中添加

ray.shutdown...

The ray-core/api/doc/ray.shutdown.html page is auto-generated by Sphinx from the Python docstring. I've already updated the ray.shutdown() docstring in python/ray/_private/worker.py (see commit 44e0b31) to include the note about the behavior difference between local and remote clusters. When the documentation is built, the API page will automatically include this content:

.. note::

    The behavior of ``ray.shutdown()`` differs depending on how the cluster
    was initialized:

    * If a new local Ray cluster was started by ``ray.init()`` (i.e., no
      ``address`` argument was provided and no existing cluster was found,
      or ``address="local"`` was explicitly used), ``ray.shutdown()`` will
      terminate all the local Ray processes...

    * If you connected to an existing cluster (e.g., via
      ``ray.init(address="auto")`` or ``ray.init(address="ray://<ip>:<port>")``),
      ``ray.shutdown()`` will only disconnect the client from the cluster.
      It will **not** shut down the remote cluster...

No separate RST file is needed as the docstring is the source for that API documentation page.

@OneSizeFitsQuorum OneSizeFitsQuorum marked this pull request as ready for review January 5, 2026 08:51
@OneSizeFitsQuorum OneSizeFitsQuorum merged commit a518fa4 into master Jan 5, 2026
1 check passed
@OneSizeFitsQuorum OneSizeFitsQuorum deleted the copilot/update-ray-shutdown-docs branch January 5, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants