Imports the plugins found with `discover_plugins()`. Args: requirement_path: The file path of requirement
(requirement_path=None)
| 212 | |
| 213 | |
| 214 | def 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 | |
| 240 | def import_module_and_submodules(package_name: str, |
searching dependent graphs…