Skip to content

Commit f5a5841

Browse files
committed
Fix test after land race
Land race cause the API for python messages in test_actor_mesh to be out of date. fixes T231172800 Differential Revision: [D78413940](https://our.internmc.facebook.com/intern/diff/D78413940/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D78413940/)! ghstack-source-id: 296564017 Pull Request resolved: #547
1 parent 438a1e6 commit f5a5841

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

python/tests/_monarch/test_actor_mesh.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
# pyre-unsafe
88

99
import pickle
10-
from typing import List
10+
from typing import Any, List
1111

1212
import monarch
1313
import pytest
1414

15-
from monarch._rust_bindings.monarch_hyperactor.actor import PanicFlag, PythonMessage
15+
from monarch._rust_bindings.monarch_hyperactor.actor import (
16+
PanicFlag,
17+
PythonMessage,
18+
PythonMessageKind,
19+
)
1620
from monarch._rust_bindings.monarch_hyperactor.actor_mesh import (
1721
PythonActorMesh,
1822
PythonActorMeshRef,
@@ -45,12 +49,21 @@ async def handle(
4549
shape: Shape,
4650
message: PythonMessage,
4751
panic_flag: PanicFlag,
52+
local_state: List[Any] | None = None,
4853
) -> None:
4954
assert rank is not None
50-
reply_port = message.response_port
51-
assert reply_port is not None
55+
56+
# Extract response_port from the message kind
57+
call_method = message.kind
58+
assert isinstance(call_method, PythonMessageKind.CallMethod)
59+
assert call_method.response_port is not None
60+
61+
reply_port = call_method.response_port
5262
reply_port.send(
53-
mailbox, PythonMessage("pong", pickle.dumps(f"rank: {rank}"), None, rank)
63+
mailbox,
64+
PythonMessage(
65+
PythonMessageKind.Result(rank), pickle.dumps(f"rank: {rank}")
66+
),
5467
)
5568

5669

@@ -77,7 +90,9 @@ async def verify_cast(
7790
handle, receiver = mailbox.open_port()
7891
port_ref = handle.bind()
7992

80-
message = PythonMessage("echo", pickle.dumps("ping"), port_ref, None)
93+
message = PythonMessage(
94+
PythonMessageKind.CallMethod("echo", port_ref), pickle.dumps("ping")
95+
)
8196
sel = Selection.from_string("*")
8297
if isinstance(actor_mesh, PythonActorMesh):
8398
actor_mesh.cast(sel, message)
@@ -87,7 +102,9 @@ async def verify_cast(
87102
rcv_ranks = []
88103
for _ in range(len(cast_ranks)):
89104
message = await receiver.recv()
90-
rank = message.rank
105+
result_kind = message.kind
106+
assert isinstance(result_kind, PythonMessageKind.Result)
107+
rank = result_kind.rank
91108
assert rank is not None
92109
rcv_ranks.append(rank)
93110
rcv_ranks.sort()

0 commit comments

Comments
 (0)