@@ -240,7 +240,8 @@ def definition(self) -> str:
240
240
"""Converts a request structure to string representation for workflow service calls."""
241
241
request_dict = self .to_request ()
242
242
request_dict ["PipelineExperimentConfig" ] = interpolate (
243
- request_dict ["PipelineExperimentConfig" ]
243
+ request_dict ["PipelineExperimentConfig" ],
244
+ {}
244
245
)
245
246
callback_output_to_step_map = _map_callback_outputs (self .steps )
246
247
request_dict ["Steps" ] = interpolate (
@@ -266,7 +267,9 @@ def format_start_parameters(parameters: Dict[str, Any]) -> List[Dict[str, Any]]:
266
267
return [{"Name" : name , "Value" : str (value )} for name , value in parameters .items ()]
267
268
268
269
269
- def interpolate (request_obj : RequestType , ** kwargs ) -> RequestType :
270
+ def interpolate (
271
+ request_obj : RequestType , callback_output_to_step_map : Dict [str , str ]
272
+ ) -> RequestType :
270
273
"""Replaces Parameter values in a list of nested Dict[str, Any] with their workflow expression.
271
274
272
275
Args:
@@ -276,13 +279,10 @@ def interpolate(request_obj: RequestType, **kwargs) -> RequestType:
276
279
RequestType: The request dict with Parameter values replaced by their expression.
277
280
"""
278
281
request_obj_copy = deepcopy (request_obj )
279
- return _interpolate (
280
- request_obj_copy ,
281
- callback_output_to_step_map = kwargs .get ("callback_output_to_step_map" , None ),
282
- )
282
+ return _interpolate (request_obj_copy , callback_output_to_step_map = callback_output_to_step_map )
283
283
284
284
285
- def _interpolate (obj : Union [RequestType , Any ], ** kwargs ):
285
+ def _interpolate (obj : Union [RequestType , Any ], callback_output_to_step_map : Dict [ str , str ] ):
286
286
"""Walks the nested request dict, replacing Parameter type values with workflow expressions.
287
287
288
288
Args:
@@ -291,22 +291,14 @@ def _interpolate(obj: Union[RequestType, Any], **kwargs):
291
291
if isinstance (obj , (Expression , Parameter , Properties )):
292
292
return obj .expr
293
293
if isinstance (obj , CallbackOutput ):
294
- callback_output_to_step_map = kwargs .get ("callback_output_to_step_map" , {})
295
294
step_name = callback_output_to_step_map [obj .output_name ]
296
295
return obj .expr (step_name )
297
296
if isinstance (obj , dict ):
298
297
new = obj .__class__ ()
299
298
for key , value in obj .items ():
300
- new [key ] = interpolate (
301
- value , callback_output_to_step_map = kwargs .get ("callback_output_to_step_map" , None )
302
- )
299
+ new [key ] = interpolate (value , callback_output_to_step_map )
303
300
elif isinstance (obj , (list , set , tuple )):
304
- new = obj .__class__ (
305
- interpolate (
306
- value , callback_output_to_step_map = kwargs .get ("callback_output_to_step_map" , None )
307
- )
308
- for value in obj
309
- )
301
+ new = obj .__class__ (interpolate (value , callback_output_to_step_map ) for value in obj )
310
302
else :
311
303
return obj
312
304
return new
0 commit comments