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

Method import_module

modelscope/utils/import_utils.py:508–523  ·  view source on GitHub ↗

import a lazy import module using signature Args: signature (tuple): a tuple of str, (registry_name, registry_group_name, module_name)

(signature)

Source from the content-addressed store, hash-verified

506
507 @staticmethod
508 def import_module(signature):
509 """ import a lazy import module using signature
510
511 Args:
512 signature (tuple): a tuple of str, (registry_name, registry_group_name, module_name)
513 """
514 ast_index = LazyImportModule.get_ast_index()
515 if signature in ast_index[INDEX_KEY]:
516 mod_index = ast_index[INDEX_KEY][signature]
517 module_name = mod_index[MODULE_KEY]
518 if module_name in ast_index[REQUIREMENT_KEY]:
519 requirements = ast_index[REQUIREMENT_KEY][module_name]
520 requires(module_name, requirements)
521 importlib.import_module(module_name)
522 else:
523 logger.warning(f'{signature} not found in ast index file')
524
525
526def has_attr_in_class(cls, attribute_name) -> bool:

Callers 15

try_import_from_hfFunction · 0.80
get_pluginFunction · 0.80
_get_moduleMethod · 0.80
build_from_cfgFunction · 0.80
import_file_pluginsFunction · 0.80
get_all_imported_modulesFunction · 0.80
_computeMethod · 0.80
initialize_configFunction · 0.80
__init__Method · 0.80

Calls 2

requiresFunction · 0.85
get_ast_indexMethod · 0.80

Tested by

no test coverage detected