Shortcuts

mmagic.utils.setup_env

Module Contents

Functions

register_all_modules(→ None)

Register all modules in mmagic into the registries.

try_import(→ Optional[types.ModuleType])

Try to import a module.

mmagic.utils.setup_env.register_all_modules(init_default_scope: bool = True) None[源代码]

Register all modules in mmagic into the registries.

参数

init_default_scope (bool) – Whether initialize the mmagic default scope. When init_default_scope=True, the global default scope will be set to mmagic, and all registries will build modules from mmagic’s registry node. To understand more about the registry, please refer to https://mmengine.readthedocs.io/en/latest/advanced_tutorials/registry.html Defaults to True.

mmagic.utils.setup_env.try_import(name: str) Optional[types.ModuleType][源代码]

Try to import a module.

参数

name (str) – Specifies what module to import in absolute or relative terms (e.g. either pkg.mod or ..mod).

返回

If importing successfully, returns the imported module, otherwise returns None.

返回类型

ModuleType or None