From 0e0ad8f071ce8978196a50d5615cf31ca0b57c5a Mon Sep 17 00:00:00 2001 From: Yin Li Date: Tue, 8 Sep 2020 13:47:10 -0400 Subject: [PATCH] Fix import bug that prevents pickling of norm functions https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly https://stackoverflow.com/questions/43819653/pickling-objects-imported-with-importlib-util/53696167#53696167 --- map2map/utils/imp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/map2map/utils/imp.py b/map2map/utils/imp.py index b79a77b..75dd7f1 100644 --- a/map2map/utils/imp.py +++ b/map2map/utils/imp.py @@ -1,4 +1,5 @@ import os +import sys import importlib @@ -51,6 +52,7 @@ def import_attr(name, *pkgs, callback_at=None): spec = importlib.util.spec_from_file_location(mod, callback_at) module = importlib.util.module_from_spec(spec) + sys.modules[mod] = module spec.loader.exec_module(module) return getattr(module, attr)