From f0363be15b6673d7c363df87286f98cf3840f31a Mon Sep 17 00:00:00 2001 From: Morten Dahl Date: Wed, 25 May 2022 14:40:21 +0200 Subject: [PATCH] first step --- pymoose/src/bindings.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pymoose/src/bindings.rs b/pymoose/src/bindings.rs index fe858e20b..3f510d949 100644 --- a/pymoose/src/bindings.rs +++ b/pymoose/src/bindings.rs @@ -265,6 +265,39 @@ impl LocalRuntime { } } +#[pyclass(subclass)] +pub struct GrpcRuntime { + runtime: AsyncTestRuntime, +} + +#[pymethods] +impl GrpcRuntime { + #[new] + fn new(py: Python, role_assignment: HashMap) -> Self { + let typed_role_assignment = role_assignment + .into_iter() + .map(|(role, identity)| (Role::from(role), Identity::from(identity))) + .collect::>(); + + let runtime = GrpcMooseRuntime::new(typed_role_assignment); + GrpcRuntime { runtime } + } + + fn evaluate_compiled_computation( + &mut self, + py: Python, + computation: PyObject, + arguments: HashMap, + ) -> PyResult>> { + let computation = MooseComputation::from_py(py, computation)?.try_borrow(py)?; + self.evaluate_compiled_computation( + py, + &computation.computation, + arguments, + ) + } +} + #[pyclass] pub struct MooseComputation { computation: Computation,