1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::cache::Cache;
use crate::helper::load_script;
use pyo3::prelude::*;
pub fn exec(module: &str) -> Result<Vec<String>, crate::Error> {
let script = load_script(&module)?;
let cache = Cache::new()?;
let gil = Python::acquire_gil();
let py = gil.python();
let pym = PyModule::from_code(py, &script, "plan.py", "plan")?;
let sps = serde_json::to_string(&cache.get_problems()?)?;
let stags = serde_json::to_string(&cache.get_tags()?)?;
let res: Vec<String> = pym.call1("plan", (sps, stags))?.extract()?;
Ok(res)
}