MCPcopy Index your code
hub / github.com/modelscope/modelscope / discover_plugins

Function discover_plugins

modelscope/utils/plugins.py:111–140  ·  view source on GitHub ↗

Discover plugins Args: requirement_path: The file path of requirement

(requirement_path=None)

Source from the content-addressed store, hash-verified

109
110
111def discover_plugins(requirement_path=None) -> Iterable[str]:
112 """
113 Discover plugins
114
115 Args:
116 requirement_path: The file path of requirement
117
118 """
119 plugins: Set[str] = set()
120 if requirement_path is None:
121 if os.path.isfile(LOCAL_PLUGINS_FILENAME):
122 with push_python_path('.'):
123 for plugin in discover_file_plugins(LOCAL_PLUGINS_FILENAME):
124 if plugin in plugins:
125 continue
126 yield plugin
127 plugins.add(plugin)
128 if os.path.isfile(GLOBAL_PLUGINS_FILENAME):
129 for plugin in discover_file_plugins(GLOBAL_PLUGINS_FILENAME):
130 if plugin in plugins:
131 continue
132 yield plugin
133 plugins.add(plugin)
134 else:
135 if os.path.isfile(requirement_path):
136 for plugin in discover_file_plugins(requirement_path):
137 if plugin in plugins:
138 continue
139 yield plugin
140 plugins.add(plugin)
141
142
143def import_all_plugins(plugins: List[str] = None) -> List[str]:

Callers 5

test_no_pluginsMethod · 0.90
test_file_pluginsMethod · 0.90
test_custom_pluginsMethod · 0.90
test_all_pluginsMethod · 0.90
import_file_pluginsFunction · 0.85

Calls 3

push_python_pathFunction · 0.85
discover_file_pluginsFunction · 0.85
addMethod · 0.45

Tested by 4

test_no_pluginsMethod · 0.72
test_file_pluginsMethod · 0.72
test_custom_pluginsMethod · 0.72
test_all_pluginsMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…