Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions monai/utils/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import enum
import functools
import importlib.util
import os
import pdb
import re
Expand Down Expand Up @@ -208,9 +209,11 @@ def load_submodules(
):
if (is_pkg or load_all) and name not in sys.modules and match(exclude_pattern, name) is None:
try:
mod = import_module(name)
importer.find_spec(name).loader.load_module(name) # type: ignore
submodules.append(mod)
mod_spec = importer.find_spec(name) # type: ignore
if mod_spec and mod_spec.loader:
mod = importlib.util.module_from_spec(mod_spec)
mod_spec.loader.exec_module(mod)
submodules.append(mod)
except OptionalImportError:
pass # could not import the optional deps., they are ignored
except ImportError as e:
Expand Down