Skip to content

Commit

Permalink
first step
Browse files Browse the repository at this point in the history
  • Loading branch information
mortendahl committed May 25, 2022
1 parent d618531 commit f0363be
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pymoose/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,39 @@ impl LocalRuntime {
}
}

#[pyclass(subclass)]
pub struct GrpcRuntime {
runtime: AsyncTestRuntime,
}

#[pymethods]
impl GrpcRuntime {
#[new]
fn new(py: Python, role_assignment: HashMap<String, String>) -> Self {
let typed_role_assignment = role_assignment
.into_iter()
.map(|(role, identity)| (Role::from(role), Identity::from(identity)))
.collect::<HashMap<Role, Identity>>();

let runtime = GrpcMooseRuntime::new(typed_role_assignment);
GrpcRuntime { runtime }
}

fn evaluate_compiled_computation(
&mut self,
py: Python,
computation: PyObject,
arguments: HashMap<String, PyObject>,
) -> PyResult<Option<HashMap<String, PyObject>>> {
let computation = MooseComputation::from_py(py, computation)?.try_borrow(py)?;
self.evaluate_compiled_computation(
py,
&computation.computation,
arguments,
)
}
}

#[pyclass]
pub struct MooseComputation {
computation: Computation,
Expand Down

0 comments on commit f0363be

Please sign in to comment.