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

Function load

flow-rs/src/loader/mod.rs:49–78  ·  view source on GitHub ↗
(local_key: u64, cfg: &LoaderConfig)

Source from the content-addressed store, hash-verified

47static ONCE_LOAD_FROM_SCOPE: Once = Once::new();
48
49pub(crate) fn load(local_key: u64, cfg: &LoaderConfig) -> Result<()> {
50 let loader = <Box<dyn Loader>>::registry_global().get(&cfg.ty).unwrap();
51 ONCE_LOAD_FROM_SCOPE.call_once(|| {
52 for plugin in loader
53 .load_from_scope(local_key)
54 .expect("cannot load plugins from current scope")
55 {
56 plugin.submit();
57 }
58 });
59
60 if let Some(plugin_path) = &cfg.plugin_path {
61 for entry in fs::read_dir(&plugin_path)? {
62 let entry = entry?;
63 let pathbuf = entry.path();
64 let path: &Path = pathbuf.as_ref();
65 if let Some(path) = cfg.ty.check(path) {
66 for plugin in loader.load_from_file(
67 local_key,
68 cfg.module_path.as_ref().map(|x| x.as_ref()),
69 path.as_path(),
70 )? {
71 plugin.submit();
72 }
73 }
74 }
75 }
76
77 Ok(())
78}
79
80impl PluginType {
81 fn check(&self, path: &Path) -> Option<PathBuf> {

Callers 3

graph_registerFunction · 0.85
load_pluginsMethod · 0.85
load_implFunction · 0.85

Calls 6

load_from_scopeMethod · 0.80
submitMethod · 0.80
as_refMethod · 0.80
checkMethod · 0.80
load_from_fileMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected