Add functools.wraps for wrapper initializer
Preserve the original initializer function's metadata. See https://docs.python.org/3/library/functools.html#functools.update_wrapper
This commit is contained in:
@@ -14,8 +14,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
"""TF general model utils."""
|
"""TF general model utils."""
|
||||||
|
import functools
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -54,6 +53,7 @@ def keras_serializable(cls):
|
|||||||
if config_class is None:
|
if config_class is None:
|
||||||
raise AttributeError("Must set `config_class` to use @keras_serializable")
|
raise AttributeError("Must set `config_class` to use @keras_serializable")
|
||||||
|
|
||||||
|
@functools.wraps(initializer)
|
||||||
def wrapped_init(self, config, *args, **kwargs):
|
def wrapped_init(self, config, *args, **kwargs):
|
||||||
if isinstance(config, dict):
|
if isinstance(config, dict):
|
||||||
config = config_class.from_dict(config)
|
config = config_class.from_dict(config)
|
||||||
|
|||||||
Reference in New Issue
Block a user