feat: rc variable (#246)

* feat: rc variable

* feat: implement variable in engine

* add exports

* fix bindings and improve clone accuracy

* fix tests, fix bindings

* fix fmt

* improve code
This commit is contained in:
stefan-gorules
2024-09-30 18:34:54 +02:00
committed by GitHub
parent 06df117694
commit 91598166ce
55 changed files with 1148 additions and 1399 deletions
+6 -6
View File
@@ -6,7 +6,7 @@ use pyo3::{pyclass, pymethods, PyAny, PyObject, PyResult, Python, ToPyObject};
use pyo3_asyncio::tokio;
use pythonize::depythonize;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use zen_engine::model::DecisionContent;
use zen_engine::{DecisionEngine, EvaluationOptions};
@@ -82,7 +82,7 @@ impl PyZenEngine {
ctx: &PyDict,
opts: Option<&PyDict>,
) -> PyResult<PyObject> {
let context = depythonize(ctx).context("Failed to convert dict")?;
let context: Value = depythonize(ctx).context("Failed to convert dict")?;
let options: PyZenEvaluateOptions = if let Some(op) = opts {
depythonize(op).context("Failed to convert dict")?
} else {
@@ -92,7 +92,7 @@ impl PyZenEngine {
let graph = self.graph.clone();
let result = futures::executor::block_on(graph.evaluate_with_opts(
key,
&context,
context.into(),
EvaluationOptions {
max_depth: options.max_depth,
trace: options.trace,
@@ -113,7 +113,7 @@ impl PyZenEngine {
ctx: &PyDict,
opts: Option<&PyDict>,
) -> PyResult<&PyAny> {
let context = depythonize(ctx).context("Failed to convert dict")?;
let context: Value = depythonize(ctx).context("Failed to convert dict")?;
let options: PyZenEvaluateOptions = if let Some(op) = opts {
depythonize(op).context("Failed to convert dict")?
} else {
@@ -124,7 +124,7 @@ impl PyZenEngine {
tokio::future_into_py(py, async move {
let result = futures::executor::block_on(graph.evaluate_with_opts(
key,
&context,
context.into(),
EvaluationOptions {
max_depth: options.max_depth,
trace: options.trace,
@@ -148,7 +148,7 @@ impl PyZenEngine {
Ok(PyZenDecision::from(decision))
}
pub fn get_decision<'py>(&'py self, py: Python<'py>, key: String) -> PyResult<PyZenDecision> {
pub fn get_decision<'py>(&'py self, _py: Python<'py>, key: String) -> PyResult<PyZenDecision> {
let decision = futures::executor::block_on(self.graph.get_decision(&key))
.context("Failed to find decision with given key")?;