From f51fbe2dcf3e8d9c393f42ec7e3d8dd7e45d7edc Mon Sep 17 00:00:00 2001 From: Mikhail Sveshnikov Date: Tue, 14 Feb 2023 21:39:05 +0300 Subject: [PATCH] Add setting to do deep requirement inspection (#606) Always do deep inspections for local code closes #548 --- mlem/config.py | 1 + mlem/utils/module.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mlem/config.py b/mlem/config.py index 691c2eff..2f3265bf 100644 --- a/mlem/config.py +++ b/mlem/config.py @@ -117,6 +117,7 @@ class Config: EMOJIS: bool = True STATE: Dict = {} SERVER: Dict = {} + DEEP_INSPECTION: bool = False @property def storage(self): diff --git a/mlem/utils/module.py b/mlem/utils/module.py index 0ed621a6..48d96b89 100644 --- a/mlem/utils/module.py +++ b/mlem/utils/module.py @@ -23,6 +23,7 @@ from pydantic.main import ModelMetaclass import mlem +from mlem.config import LOCAL_CONFIG from mlem.core.requirements import ( CustomRequirement, InstallableRequirement, @@ -36,7 +37,6 @@ PYTHON_BASE = os.path.dirname(threading.__file__) # pylint: disable=no-member,protected-access IGNORE_TYPES_REQ = (type(Requirements._abc_impl),) # type: ignore -DEEP_INSPECTION = False def check_pypi_module( @@ -602,9 +602,11 @@ def save(self, obj, save_persistent_id=True): if id(obj) in self.seen or isinstance(obj, IGNORE_TYPES_REQ): return None self.seen.add(id(obj)) + base_module = get_object_base_module(obj) if ( - get_object_base_module(obj) in self._modules - and not DEEP_INSPECTION + base_module in self._modules + and not is_local_module(base_module) + and not LOCAL_CONFIG.DEEP_INSPECTION ): return None self.add_requirement(obj)