From 385c35618c0100a344bfa1cb90eb756f967b9963 Mon Sep 17 00:00:00 2001 From: Shengsheng Huang Date: Mon, 4 Jul 2022 13:10:39 +0000 Subject: [PATCH] fix proxy for tf version compatibility --- python/nano/src/bigdl/nano/automl/utils/proxy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/nano/src/bigdl/nano/automl/utils/proxy.py b/python/nano/src/bigdl/nano/automl/utils/proxy.py index 014958e1c26..e193686779e 100644 --- a/python/nano/src/bigdl/nano/automl/utils/proxy.py +++ b/python/nano/src/bigdl/nano/automl/utils/proxy.py @@ -21,7 +21,8 @@ def proxy_method(cls, name): # This unbound method will be pulled from the superclass. invalidInputError(hasattr(cls, name), - "cls should have name attribute") + f"%s should have %s attribute" % + (str(cls.__name__), name)) proxyed = getattr(cls, name) @functools.wraps(proxyed) @@ -32,5 +33,6 @@ def wrapper(self, *args, **kwargs): def proxy_methods(cls): for name in cls.PROXYED_METHODS: - setattr(cls, name, proxy_method(cls, name)) + if hasattr(cls, name): + setattr(cls, name, proxy_method(cls, name)) return cls