Skip to content

Commit fd5d717

Browse files
MengjinYandayshah
andauthored
[Core][Doc] Add Description for Named Placement Group to Require a Namespace (#51285)
This PR adds the description for named placement group to require a namespace. The corresponding code example is updated as well. Closes #51149 --------- Signed-off-by: Mengjin Yan <mengjinyan3@gmail.com> Co-authored-by: Dhyey Shah <dhyey2019@gmail.com>
1 parent 26a8a77 commit fd5d717

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

doc/source/ray-core/doc_code/placement_group_example.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,13 @@ def ready(self):
129129

130130
# __get_pg_start__
131131
# first_driver.py
132-
# Create a placement group with a global name.
133-
pg = placement_group([{"CPU": 1}], name="global_name")
132+
# Create a placement group with a unique name within a namespace.
133+
# Start Ray or connect to a Ray cluster using: ray.init(namespace="pg_namespace")
134+
pg = placement_group([{"CPU": 1}], name="pg_name")
134135
ray.get(pg.ready())
135136

136137
# second_driver.py
137-
# Retrieve a placement group with a global name.
138-
pg = ray.util.get_placement_group("global_name")
138+
# Retrieve a placement group with a unique name within a namespace.
139+
# Start Ray or connect to a Ray cluster using: ray.init(namespace="pg_namespace")
140+
pg = ray.util.get_placement_group("pg_name")
139141
# __get_pg_end__

doc/source/ray-core/scheduling/placement-group.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,12 +585,19 @@ child tasks and actors to the same placement group, specify ``PlacementGroupSche
585585
[Advanced] Named Placement Group
586586
--------------------------------
587587
588-
A placement group can be given a globally unique name.
589-
This allows you to retrieve the placement group from any job in the Ray cluster.
590-
This can be useful if you cannot directly pass the placement group handle to
588+
Within a :ref:`namespace <namespaces-guide>`, you can *name* a placement group.
589+
You can use the name of a placement group to retrieve the placement group from any job
590+
in the Ray cluster, as long as the job is within the same namespace.
591+
This is useful if you can't directly pass the placement group handle to
591592
the actor or task that needs it, or if you are trying to
592-
access a placement group launched by another driver.
593-
Note that the placement group is still destroyed if its lifetime isn't `detached`.
593+
access a placement group launched by another driver.
594+
595+
The placement group is destroyed when the original creation job completes if its
596+
lifetime isn't `detached`. You can avoid this by using a :ref:`detached placement group <placement-group-detached>`
597+
598+
Note that this feature requires that you specify a
599+
:ref:`namespace <namespaces-guide>` associated with it, or else you can't retrieve the
600+
placement group across jobs.
594601
595602
.. tab-set::
596603

0 commit comments

Comments
 (0)