Some codes in MONAI import many components from the parent modules (look at example below). This is generally fine but can increase the chance of circular import in MONAI core. Although we should avoid such situations with some tricks like deferred imports, it would be a good practice to import the modules with more granularity in the core MONAI.
This is an example of what we can see in MONAI:
from monai.utils import InterpolateMode, deprecated_arg, ensure_tuple, ensure_tuple_rep, min_version, optional_import
from monai.utils.enums import PostFix
and a better way to import would be:
from monai.utils.deprecate_utils import deprecated_arg
from monai.utils.enums import InterpolateMode, PostFix
from monai.utils.misc import ensure_tuple, ensure_tuple_rep
from monai.utils.module import min_version, optional_import
The changes are small and easy per each file but there are more than 200 instances of this kind of imports, which makes it a tedious task to improve. I suggest to look for this imports in any PR review and gradually fix the previous ones.
Some codes in MONAI import many components from the parent modules (look at example below). This is generally fine but can increase the chance of circular import in MONAI core. Although we should avoid such situations with some tricks like deferred imports, it would be a good practice to import the modules with more granularity in the core MONAI.
This is an example of what we can see in MONAI:
and a better way to import would be:
The changes are small and easy per each file but there are more than 200 instances of this kind of imports, which makes it a tedious task to improve. I suggest to look for this imports in any PR review and gradually fix the previous ones.