92
92
from monarch ._rust_bindings .monarch_hyperactor .actor_mesh import ActorMeshProtocol
93
93
from monarch ._rust_bindings .monarch_hyperactor .mailbox import PortReceiverBase
94
94
from monarch ._src .actor .proc_mesh import _ControllerController , ProcMesh
95
+ from monarch ._src .actor .v1 .proc_mesh import (
96
+ _ControllerController as _ControllerControllerV1 ,
97
+ ProcMesh as ProcMeshV1 ,
98
+ )
95
99
from monarch ._src .actor .telemetry import get_monarch_tracer
96
100
97
101
CallMethod = PythonMessageKind .CallMethod
@@ -142,7 +146,7 @@ def actor_id(self) -> ActorId:
142
146
...
143
147
144
148
@property
145
- def proc (self ) -> "ProcMesh" :
149
+ def proc (self ) -> "ProcMesh | ProcMeshV1 " :
146
150
"""
147
151
The singleton proc mesh that corresponds to just this actor.
148
152
"""
@@ -155,14 +159,14 @@ def proc(self) -> "ProcMesh":
155
159
The actors __init__ message.
156
160
"""
157
161
rank : Point
158
- proc_mesh : "ProcMesh"
159
- _controller_controller : "_ControllerController"
162
+ proc_mesh : "ProcMesh | ProcMeshV1 "
163
+ _controller_controller : "_ControllerController | _ControllerControllerV1 "
160
164
161
165
# this property is used to hold the handles to actors and processes launched by this actor
162
166
# in order to keep them alive until this actor exits.
163
- _children : "Optional[List[ActorMesh | ProcMesh]]"
167
+ _children : "Optional[List[ActorMesh | ProcMesh | ProcMeshV1 ]]"
164
168
165
- def _add_child (self , child : "ActorMesh | ProcMesh" ) -> None :
169
+ def _add_child (self , child : "ActorMesh | ProcMesh | ProcMeshV1 " ) -> None :
166
170
if self ._children is None :
167
171
self ._children = [child ]
168
172
else :
@@ -212,13 +216,16 @@ def context() -> Context:
212
216
if c is None :
213
217
c = Context ._root_client_context ()
214
218
_context .set (c )
219
+
220
+ # FIXME: Switch to the v1 APIs when it becomes the default.
215
221
from monarch ._src .actor .host_mesh import create_local_host_mesh
216
222
from monarch ._src .actor .proc_mesh import _get_controller_controller
217
223
218
224
c .actor_instance .proc_mesh , c .actor_instance ._controller_controller = (
219
225
_get_controller_controller ()
220
226
)
221
- c .actor_instance .proc_mesh ._host_mesh = create_local_host_mesh ()
227
+
228
+ c .actor_instance .proc_mesh ._host_mesh = create_local_host_mesh () # type: ignore
222
229
return c
223
230
224
231
@@ -281,7 +288,7 @@ def __init__(
281
288
self ,
282
289
actor_mesh : "ActorMeshProtocol" ,
283
290
shape : Shape ,
284
- proc_mesh : "Optional[ProcMesh]" ,
291
+ proc_mesh : "Optional[ProcMesh] | Optional[ProcMeshV1] " ,
285
292
name : MethodSpecifier ,
286
293
impl : Callable [Concatenate [Any , P ], Awaitable [R ]],
287
294
propagator : Propagator ,
@@ -931,7 +938,7 @@ def __init__(
931
938
Class : Type [T ],
932
939
inner : "ActorMeshProtocol" ,
933
940
shape : Shape ,
934
- proc_mesh : "Optional[ProcMesh]" ,
941
+ proc_mesh : "Optional[ProcMesh] | Optional[ProcMeshV1] " ,
935
942
) -> None :
936
943
self .__name__ : str = Class .__name__
937
944
self ._class : Type [T ] = Class
@@ -986,8 +993,9 @@ def _create(
986
993
Class : Type [T ],
987
994
actor_mesh : "PythonActorMesh" ,
988
995
shape : Shape ,
989
- proc_mesh : "ProcMesh" ,
990
- controller_controller : Optional ["_ControllerController" ],
996
+ proc_mesh : "ProcMesh | ProcMeshV1" ,
997
+ controller_controller : Optional ["_ControllerController" ]
998
+ | Optional ["_ControllerControllerV1" ],
991
999
# args and kwargs are passed to the __init__ method of the user defined
992
1000
# python actor object.
993
1001
* args : Any ,
@@ -1019,7 +1027,7 @@ def from_actor_id(
1019
1027
return cls (Class , _SingletonActorAdapator (actor_id ), singleton_shape , None )
1020
1028
1021
1029
def __reduce_ex__ (self , protocol : ...) -> "Tuple[Type[ActorMesh], Tuple[Any, ...]]" :
1022
- return ActorMesh , (self ._class , self ._inner , self ._shape , None )
1030
+ return ActorMesh , (self ._class , self ._inner , self ._shape , self . _proc_mesh )
1023
1031
1024
1032
@property
1025
1033
def _ndslice (self ) -> NDSlice :
0 commit comments