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
This commit is contained in:
parent
f3216f4cbd
commit
0e0ad8f071
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user