@@ -107,11 +107,15 @@ def fit(self, context: Context) -> None:
107107 self ._logger .info ("%s node optimization is finished! saving best assets" , self .node_info .node_type )
108108 # TODO refactor the following code (via implementing `autointent.load_module(path)` utility)
109109 trial_idx = context .optimization_info .get_best_trial_idx (self .node_type )
110- trial = context .optimization_info .trials .get_trial (self .node_type , trial_idx ) # type: ignore[arg-type]
111- module_type , module_kwargs = scored_modules [trial_idx ] # type: ignore[index]
112- best_module : Module = module_type (** module_kwargs )
113- best_module .load (trial .module_dump_dir ) # type: ignore[arg-type]
114- context .optimization_info .artifacts .add_artifact (self .node_type , best_module .get_artifact (context ))
110+ if context .is_ram_to_clear ():
111+ trial = context .optimization_info .trials .get_trial (self .node_type , trial_idx ) # type: ignore[arg-type]
112+ module_type , module_kwargs = scored_modules [trial_idx ] # type: ignore[index]
113+ best_module : Module = module_type (** module_kwargs )
114+ best_module .load (trial .module_dump_dir ) # type: ignore[arg-type]
115+ else :
116+ best_module = context .optimization_info .modules .get (self .node_type )[trial_idx ]
117+ artifact = best_module .get_artifact (context )
118+ context .optimization_info .artifacts .add_artifact (self .node_type , artifact )
115119
116120 def get_module_dump_dir (self , dump_dir : Path , module_name : str , j_combination : int ) -> str :
117121 """
0 commit comments