@@ -236,8 +236,9 @@ class ApplyDataTypeGeneralizationPasses(SamplePass, ResumableSamplePassMixin):
236236 "output_dir": "/path/to/output",
237237 "model_path_prefix": "",
238238 "model_runnable_predicator_filepath": "...",
239- "model_runnable_predicator_class_name": "...",
240- "model_runnable_predicator_config": {...},
239+ "resume": ,
240+ "limits_handled_models": ,
241+ "try_run": ,
241242 }
242243 """
243244
@@ -250,6 +251,9 @@ def __init__(self, config: Dict[str, Any]):
250251 raise ValueError ("output_dir is required in config" )
251252
252253 self .model_path_prefix = config .get ("model_path_prefix" , "" )
254+ self .model_runnable_predicator_class_name = "RunModelPredicator"
255+ self .model_runnable_predicator_config = {"use_dummy_inputs" : True }
256+ self .try_run = config .get ("try_run" , True )
253257
254258 # model_runnable_predicator is required to ensure generated code is runnable
255259 if "model_runnable_predicator_filepath" not in config :
@@ -264,21 +268,17 @@ def declare_config(
264268 output_dir : str ,
265269 model_path_prefix : str ,
266270 model_runnable_predicator_filepath : str ,
267- model_runnable_predicator_class_name : str ,
268- model_runnable_predicator_config : dict ,
269271 resume : bool = False ,
270272 limits_handled_models : int = None ,
273+ try_run : bool = True ,
271274 ):
272275 pass
273276
274277 def _make_model_runnable_predicator (self , config : Dict [str , Any ]):
275278 """Create model runnable predicator from config."""
276279 module = load_module (config ["model_runnable_predicator_filepath" ])
277- cls = getattr (
278- module ,
279- config .get ("model_runnable_predicator_class_name" , "RunModelPredicator" ),
280- )
281- predicator_config = config .get ("model_runnable_predicator_config" , {})
280+ cls = getattr (module , self .model_runnable_predicator_class_name )
281+ predicator_config = self .model_runnable_predicator_config
282282 return cls (predicator_config )
283283
284284 def sample_handled (self , rel_model_path : str ) -> bool :
@@ -430,11 +430,12 @@ def _apply_pass_and_generate(
430430 self ._update_sample_metadata (output_sample_dir , dtype )
431431
432432 # Validate generated sample (required - generated code must be runnable)
433- if not self .model_runnable_predicator (str (output_sample_dir )):
434- raise RuntimeError (
435- f"Generated sample failed validation: { output_sample_dir } "
436- )
437- logging .info (f"Generated sample validated: { output_sample_dir } " )
433+ if self .try_run :
434+ if not self .model_runnable_predicator (str (output_sample_dir )):
435+ raise RuntimeError (
436+ f"Generated sample failed validation: { output_sample_dir } "
437+ )
438+ logging .info (f"Generated sample validated: { output_sample_dir } " )
438439
439440 return str (output_sample_dir )
440441
0 commit comments