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

Function import_file_plugins

modelscope/utils/plugins.py:214–237  ·  view source on GitHub ↗

Imports the plugins found with `discover_plugins()`. Args: requirement_path: The file path of requirement

(requirement_path=None)

Source from the content-addressed store, hash-verified

212
213
214def import_file_plugins(requirement_path=None) -> List[str]:
215 """
216 Imports the plugins found with `discover_plugins()`.
217
218 Args:
219 requirement_path: The file path of requirement
220
221 """
222 imported_plugins: List[str] = []
223
224 # Workaround for a presumed Python issue where spawned processes can't find modules in the current directory.
225 cwd = os.getcwd()
226 if cwd not in sys.path:
227 sys.path.append(cwd)
228
229 for module_name in discover_plugins(requirement_path):
230 try:
231 importlib.import_module(module_name)
232 logger.info('Plugin %s available', module_name)
233 imported_plugins.append(module_name)
234 except ModuleNotFoundError as e:
235 logger.error(f'Plugin {module_name} could not be loaded: {e}')
236
237 return imported_plugins
238
239
240def import_module_and_submodules(package_name: str,

Callers 2

test_file_pluginsMethod · 0.90
import_all_pluginsFunction · 0.85

Calls 4

discover_pluginsFunction · 0.85
import_moduleMethod · 0.80
infoMethod · 0.80
appendMethod · 0.45

Tested by 1

test_file_pluginsMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…