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

Method _get_module

modelscope/utils/import_utils.py:480–495  ·  view source on GitHub ↗
(self, module_name: str)

Source from the content-addressed store, hash-verified

478 return value
479
480 def _get_module(self, module_name: str):
481 try:
482 module_name_full = self.__name__ + '.' + module_name
483 if not any(
484 module_name_full.startswith(f'modelscope.{prefix}')
485 for prefix in ['hub', 'utils', 'version', 'fileio']):
486 # check requirements before module import
487 ast_index = self.get_ast_index()
488 if module_name_full in ast_index[REQUIREMENT_KEY]:
489 requirements = ast_index[REQUIREMENT_KEY][module_name_full]
490 requires(module_name_full, requirements)
491 return importlib.import_module('.' + module_name, self.__name__)
492 except Exception as e:
493 raise RuntimeError(
494 f'Failed to import {self.__name__}.{module_name} because of the following error '
495 f'(look up to see its traceback):\n{e}') from e
496
497 def __reduce__(self):
498 return self.__class__, (self._name, self.__file__,

Callers 1

__getattr__Method · 0.95

Calls 3

get_ast_indexMethod · 0.95
requiresFunction · 0.85
import_moduleMethod · 0.80

Tested by

no test coverage detected