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

Method initialize

flow-rs/src/loader/python/node.rs:77–99  ·  view source on GitHub ↗
(&mut self, res: ResourceCollection)

Source from the content-addressed store, hash-verified

75 }
76
77 async fn initialize(&mut self, res: ResourceCollection) {
78 Python::with_gil(|py| -> PyResult<()> {
79 for input in self.inputs.values() {
80 self.imp.as_ref(py).setattr(input.name.clone(), input)?;
81 }
82 for output in self.outputs.values() {
83 self.imp.as_ref(py).setattr(output.name.clone(), output)?;
84 }
85 Ok(())
86 })
87 .unwrap();
88
89 for k in res.keys() {
90 let any_r = res
91 .get_any(k.as_str())
92 .await
93 .unwrap_or_else(|| panic!("resource {} not found", k));
94 Python::with_gil(|py| {
95 let r = any_r.to_python(py);
96 self.imp.as_ref(py).setattr(k, r).unwrap();
97 });
98 }
99 }
100
101 async fn exec(&mut self) {
102 stackful(|| {

Callers 1

start_loopMethod · 0.45

Calls 5

as_refMethod · 0.80
get_anyMethod · 0.80
cloneMethod · 0.45
keysMethod · 0.45
to_pythonMethod · 0.45

Tested by

no test coverage detected