Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Add bundles_to_node_id info in placement_group_table #35122

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions python/ray/_private/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ def get_strategy(strategy):
bundle.bundle_id.bundle_index: MessageToDict(bundle)["unitResources"]
for bundle in placement_group_info.bundles
},
"bundles_to_node_id": {
bundle.bundle_id.bundle_index: binary_to_hex(bundle.node_id)
for bundle in placement_group_info.bundles
},
"strategy": get_strategy(placement_group_info.strategy),
"state": get_state(placement_group_info.state),
"stats": {
Expand Down
18 changes: 17 additions & 1 deletion python/ray/tests/test_placement_group_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def test_pending_placement_group_wait(ray_start_cluster, connect_to_client):
assert len(ready) == 0
table = ray.util.placement_group_table(placement_group)
assert table["state"] == "PENDING"
for i in range(3):
assert len(table["bundles_to_node_id"][i]) == 0

with pytest.raises(ray.exceptions.GetTimeoutError):
ray.get(placement_group.ready(), timeout=0.1)

Expand All @@ -115,11 +118,24 @@ def test_placement_group_wait(ray_start_cluster, connect_to_client):
assert len(ready) == 1
table = ray.util.placement_group_table(placement_group)
assert table["state"] == "CREATED"

pg = ray.get(placement_group.ready())
assert pg.bundle_specs == placement_group.bundle_specs
assert pg.id.binary() == placement_group.id.binary()

@ray.remote
def get_node_id():
return ray.get_runtime_context().get_node_id()

for i in range(2):
scheduling_strategy = PlacementGroupSchedulingStrategy(
placement_group=placement_group,
placement_group_bundle_index=i,
)
node_id = ray.get(
get_node_id.options(scheduling_strategy=scheduling_strategy).remote()
)
assert node_id == table["bundles_to_node_id"][i]


@pytest.mark.parametrize("connect_to_client", [False, True])
def test_schedule_placement_group_when_node_add(ray_start_cluster, connect_to_client):
Expand Down