@@ -147,6 +147,7 @@ def register_component(self, component, *args, **kwargs):
147147
148148 c_path = component .path
149149 c_class = component .__class__ .__name__
150+ c_mod = component .__class__ .__module__
150151
151152 _args = []
152153
@@ -163,7 +164,7 @@ def register_component(self, component, *args, **kwargs):
163164 del _kwargs [key ]
164165 info ("Failed to serialize \" " , key , "\" in " , component .path , sep = "" )
165166
166- obj = {"class" : c_class , "args" : _args , "kwargs" : _kwargs }
167+ obj = {"class" : c_class , "module" : c_mod , " args" : _args , "kwargs" : _kwargs }
167168 self ._json_objects ['components' ][c_path ] = obj
168169
169170 def add_component (self , component ):
@@ -272,6 +273,8 @@ def save_to_json(self, directory, model_name=None, custom_save=True, overwrite=F
272273 for c_path , component in self ._json_objects ['components' ].items ():
273274 if "parameter_map" in component ['kwargs' ].keys ():
274275 del component ['kwargs' ]["parameter_map" ]
276+ if "module" in component .keys ():
277+ del component ['module' ]
275278
276279 obj = {"components" : self ._json_objects ['components' ]}
277280 if len (hp .keys ()) != 0 :
@@ -455,9 +458,7 @@ def make_modules(self):
455458 modules = {}
456459 jComponents = self ._json_objects ['components' ]
457460 for c_path , c in jComponents .items ():
458- mod = load_module (c ["class" ]).__name__
459-
460- module = "." .join (mod .split ("." )[:- 1 ])
461+ module = load_module (c ["module" ], absolute_path = True ).__name__
461462 klass = c ["class" ]
462463
463464 if module not in modules .keys ():
0 commit comments