@@ -235,19 +235,63 @@ def __repr__(self) -> str:
235235 """Custom repr to properly show image count instead of image objects."""
236236 # For images, show count instead of full list
237237 images_repr = f"[{ len (self .images )} PIL Images]" if self .images else "[]"
238-
239238 # Build repr string
239+
240+ def _repr_nested (obj ) -> str :
241+ if isinstance (obj , list ):
242+ return "[" + ", " .join (_repr_nested (x ) for x in obj ) + "]"
243+ if isinstance (obj , OmniRequestOutput ):
244+ return obj ._repr_multiline (indent = " " )
245+ return repr (obj )
246+
240247 parts = [
241248 f"request_id={ self .request_id !r} " ,
242249 f"finished={ self .finished } " ,
243250 f"stage_id={ self .stage_id } " ,
244251 f"final_output_type={ self .final_output_type !r} " ,
245- f"request_output={ self .request_output } " ,
252+ f"request_output={ _repr_nested ( self .request_output ) } " ,
246253 f"images={ images_repr } " ,
247254 f"prompt={ self .prompt !r} " ,
248255 f"latents={ self .latents } " ,
249256 f"metrics={ self .metrics } " ,
250257 f"multimodal_output={ self ._multimodal_output } " ,
251258 ]
252-
253259 return f"OmniRequestOutput({ ', ' .join (parts )} )"
260+
261+
262+ def _repr_multiline (self , indent : str = "" ) -> str :
263+ """Helper to produce multi-line, indented repr for nested logging."""
264+ images_repr = f"[{ len (self .images )} PIL Images]" if self .images else "[]"
265+
266+ def _repr_nested (obj , ind : str ) -> str :
267+ if isinstance (obj , list ):
268+ inner = ",\n " .join (_repr_nested (x , ind + " " ) for x in obj )
269+ return "[\n " + inner + "\n " + ind + "]"
270+ if isinstance (obj , OmniRequestOutput ):
271+ return obj ._repr_multiline (indent = ind + " " )
272+ return repr (obj )
273+
274+ # Format metrics with each key-value pair on a separate line
275+ if self .metrics :
276+ metrics_indent = indent + " "
277+ metrics_lines = f",\n { metrics_indent } " .join (
278+ f"{ k !r} : { v !r} " for k , v in self .metrics .items ()
279+ )
280+ metrics_repr = f"{{\n { metrics_indent } { metrics_lines } \n { indent } }}"
281+ else :
282+ metrics_repr = "{}"
283+
284+ lines = [
285+ f"{ indent } OmniRequestOutput(" ,
286+ f"{ indent } request_id={ self .request_id !r} ," ,
287+ f"{ indent } finished={ self .finished } ," ,
288+ f"{ indent } stage_id={ self .stage_id } ," ,
289+ f"{ indent } final_output_type={ self .final_output_type !r} ," ,
290+ f"{ indent } request_output={ _repr_nested (self .request_output , indent + ' ' )} ," ,
291+ f"{ indent } images={ images_repr } ," ,
292+ f"{ indent } prompt={ self .prompt !r} ," ,
293+ f"{ indent } latents={ self .latents } ," ,
294+ f"{ indent } metrics={ metrics_repr } ," ,
295+ f"{ indent } )" ,
296+ ]
297+ return "\n " .join (lines )
0 commit comments