44 get_context , add_context , get_current_path , get_current_context , set_new_context , load_module , is_pre_loaded
55from ngcsimlib import preload_modules
66from ngcsimlib .compilers .command_compiler import dynamic_compile , wrap_command
7- import json , os , shutil
7+ import json , os , shutil , copy
88
99
1010
@@ -241,8 +241,8 @@ def save_to_json(self, directory, model_name=None, custom_save=True, overwrite=F
241241
242242 with open (path + "/components.json" , 'w' ) as fp :
243243 hyperparameters = {}
244-
245- for c_path , component in self . _json_objects [ 'components' ] .items ():
244+ _components = copy . deepcopy ( self . _json_objects [ 'components' ])
245+ for c_path , component in _components .items ():
246246 if component ['kwargs' ].get ('parameter_map' , None ) is not None :
247247 for cKey , pKey in component ['kwargs' ]['parameter_map' ].items ():
248248 pVal = component ['kwargs' ][cKey ]
@@ -264,19 +264,19 @@ def save_to_json(self, directory, model_name=None, custom_save=True, overwrite=F
264264
265265 for c_path , cKey , _ in hyperparameters [param ]:
266266 if matched :
267- self . _json_objects [ 'components' ] [c_path ]['kwargs' ][cKey ] = param
267+ _components [c_path ]['kwargs' ][cKey ] = param
268268
269269 else :
270270 warn ("Unable to extract hyperparameter" , param ,
271271 "as it is mismatched between components. Parameter will not be extracted" )
272272
273- for c_path , component in self . _json_objects [ 'components' ] .items ():
273+ for c_path , component in _components .items ():
274274 if "parameter_map" in component ['kwargs' ].keys ():
275275 del component ['kwargs' ]["parameter_map" ]
276276 if "module" in component .keys ():
277277 del component ['module' ]
278278
279- obj = {"components" : self . _json_objects [ 'components' ] }
279+ obj = {"components" : _components }
280280 if len (hp .keys ()) != 0 :
281281 obj ["hyperparameters" ] = hp
282282
0 commit comments