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

Function import_plugins

modelscope/utils/plugins.py:176–211  ·  view source on GitHub ↗

Imports the plugins listed in the arguments.

(plugins: List[str] = None)

Source from the content-addressed store, hash-verified

174
175
176def import_plugins(plugins: List[str] = None) -> List[str]:
177 """
178 Imports the plugins listed in the arguments.
179 """
180 imported_plugins: List[str] = []
181 if plugins is None or len(plugins) == 0:
182 return imported_plugins
183
184 # Workaround for a presumed Python issue where spawned processes can't find modules in the current directory.
185 cwd = os.getcwd()
186 if cwd not in sys.path:
187 sys.path.append(cwd)
188
189 for module_name in plugins:
190 try:
191 # TODO: include and exclude should be configurable, hard code now
192 import_module_and_submodules(
193 module_name,
194 include={
195 'easycv.toolkit.modelscope',
196 'easycv.hooks',
197 'easycv.models',
198 'easycv.core',
199 'easycv.toolkit',
200 'easycv.predictors',
201 },
202 exclude={
203 'easycv.toolkit.*',
204 'easycv.*',
205 })
206 logger.info('Plugin %s available', module_name)
207 imported_plugins.append(module_name)
208 except ModuleNotFoundError as e:
209 logger.error(f'Plugin {module_name} could not be loaded: {e}')
210
211 return imported_plugins
212
213
214def import_file_plugins(requirement_path=None) -> List[str]:

Callers 3

test_custom_pluginsMethod · 0.90
import_all_pluginsFunction · 0.85
register_plugins_repoFunction · 0.85

Calls 3

infoMethod · 0.80
appendMethod · 0.45

Tested by 1

test_custom_pluginsMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…