Skip to content

Commit d95a57a

Browse files
authored
[core] add actor labels to export events (#51687)
We added the `labels` field to actor in https://github.com/ray-project/ray/pull/48715/files. This PR populates this field to the export events. Test: - CI - Check that `labels` field are exported successfully <img width="676" alt="Screenshot 2025-03-25 at 2 37 37 PM" src="https://github.com/user-attachments/assets/5879229d-2d06-4a76-8a25-3afcdd0d63a0" /> --------- Signed-off-by: can <can@anyscale.com>
1 parent 7d24011 commit d95a57a

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/ray/gcs/gcs_server/gcs_actor_manager.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ void GcsActor::WriteActorExportEvent() const {
272272
export_actor_data_ptr->set_node_id(actor_table_data_.node_id());
273273
export_actor_data_ptr->set_placement_group_id(actor_table_data_.placement_group_id());
274274
export_actor_data_ptr->set_repr_name(actor_table_data_.repr_name());
275+
export_actor_data_ptr->mutable_labels()->insert(task_spec_.get()->labels().begin(),
276+
task_spec_.get()->labels().end());
275277

276278
RayExportEvent(export_actor_data_ptr).SendEvent();
277279
}

src/ray/gcs/gcs_server/test/export_api/gcs_actor_manager_export_event_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ TEST_F(GcsActorManagerTest, TestBasic) {
269269
rpc::CreateActorRequest create_actor_request;
270270
create_actor_request.mutable_task_spec()->CopyFrom(
271271
registered_actor->GetCreationTaskSpecification().GetMessage());
272+
create_actor_request.mutable_task_spec()->mutable_labels()->insert({"w00t", "hi"});
272273
RAY_CHECK_EQ(
273274
gcs_actor_manager_->CountFor(rpc::ActorTableData::DEPENDENCIES_UNREADY, ""), 1);
274275

@@ -319,6 +320,9 @@ TEST_F(GcsActorManagerTest, TestBasic) {
319320
"The actor is dead because all references to the actor were removed "
320321
"including lineage ref count.");
321322
}
323+
if (expected_states[event_idx] == "ALIVE") {
324+
ASSERT_EQ(event_data["labels"]["w00t"], "hi");
325+
}
322326
}
323327
return;
324328
} else {

src/ray/protobuf/export_api/export_actor_data.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,6 @@ message ExportActorData {
7373
// might depend on actor fields to be initialized in __init__.
7474
// Default to empty string if no customized repr is defined.
7575
string repr_name = 14;
76+
// The key-value labels for task and actor.
77+
map<string, string> labels = 15;
7678
}

0 commit comments

Comments
 (0)