Skip to content

Commit c222810

Browse files
pzhan9facebook-github-bot
authored andcommitted
Migrate to PythonActorMesh and PythonActorMeshRef (#770)
Summary: Pull Request resolved: #770 Pull Request resolved: #557 This diff swaps `_ActorMeshRefImpl` with `PythonActorMesh[Ref]`. The swap itself should be straightforward since `PythonActorMesh[Ref]` should be drop-in replacements for `_ActorMeshRefImpl`. Most of the complexity in this diff is from how I tried to add a toggle between them, just in case there is any bugs with `PythonActorMesh[Ref]`, so we can quickly switch back to `_ActorMeshRefImpl`. What I did is: 1. Add wrapper classes `EitherPyActorMesh[Ref]`, whose underlying type can be either `PythonActorMesh[Ref]` or `_ActorMeshRefImpl`; 2. a env var `USE_STANDIN_ACTOR_MESH` is used to which one would be used when instantiating `EitherPyActorMesh[Ref]`. The landing of this diff would mean all Python-side mesh API calls should go through Rust-side's `cast` code path, except several usages of `ActorIdRef`. Reviewed By: zdevito Differential Revision: D78355743 fbshipit-source-id: 4aea0a8168b7dc0fff0cb24462869df0434e3ee6
1 parent 7d767cf commit c222810

File tree

8 files changed

+311
-107
lines changed

8 files changed

+311
-107
lines changed

monarch_hyperactor/src/actor_mesh.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ impl PythonActorMesh {
119119
}
120120

121121
fn try_inner(&self) -> PyResult<SharedCellRef<RootActorMesh<'static, PythonActor>>> {
122-
self.inner
123-
.borrow()
124-
.map_err(|_| PyRuntimeError::new_err("`PythonActorMesh` has already been stopped"))
122+
self.inner.borrow().map_err(|_| {
123+
SupervisionError::new_err("`PythonActorMesh` has already been stopped".to_string())
124+
})
125125
}
126126

127127
fn pickling_err(&self) -> PyErr {
@@ -144,13 +144,13 @@ impl PythonActorMesh {
144144
match &*unhealthy_event {
145145
Unhealthy::SoFarSoGood => (),
146146
Unhealthy::Crashed(event) => {
147-
return Err(PyRuntimeError::new_err(format!(
147+
return Err(SupervisionError::new_err(format!(
148148
"actor mesh is unhealthy with reason: {:?}",
149149
event
150150
)));
151151
}
152152
Unhealthy::StreamClosed => {
153-
return Err(PyRuntimeError::new_err(
153+
return Err(SupervisionError::new_err(
154154
"actor mesh is stopped due to proc mesh shutdown".to_string(),
155155
));
156156
}

0 commit comments

Comments
 (0)