MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / new

Method new

flow-rs/src/loader/python/node.rs:43–75  ·  view source on GitHub ↗
(
        instance_name: String,
        args: &toml::value::Table,
        params: &RegistryNodeParams,
    )

Source from the content-addressed store, hash-verified

41
42impl PyNode {
43 pub fn new(
44 instance_name: String,
45 args: &toml::value::Table,
46 params: &RegistryNodeParams,
47 ) -> PyNode {
48 let mut inputs = HashMap::new();
49 let mut outputs = HashMap::new();
50 for port in &params.inputs {
51 let (k, v) = parse(port);
52 inputs.insert(k, v);
53 }
54 for port in &params.outputs {
55 let (k, v) = parse(port);
56 outputs.insert(k, v);
57 }
58 let imp = Python::with_gil(|py| -> _ {
59 let pyargs = toml2dict(py, args).expect("convert toml to python dict fault");
60 match params.code.call1(py, (instance_name.as_str(), pyargs)) {
61 Err(err) => {
62 err.print(py);
63 panic!("parse python code fault");
64 }
65 Ok(ret) => ret,
66 }
67 });
68 PyNode {
69 inputs,
70 outputs,
71 imp,
72 name: params.name.clone(),
73 exclusive: params.exclusive,
74 }
75 }
76
77 async fn initialize(&mut self, res: ResourceCollection) {
78 Python::with_gil(|py| -> PyResult<()> {

Callers

nothing calls this directly

Calls 4

toml2dictFunction · 0.85
insertMethod · 0.80
parseFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected