MCPcopy Create free account
hub / github.com/FareedKhan-dev/ai-long-task / export_traces

Function export_traces

utils/trace_export_utils.py:356–385  ·  view source on GitHub ↗

A high-level wrapper to export traces to a specified format. Args: traces: A list of trace objects. output_path: The path to save the file. format: The desired output format ('jsonl', 'json', 'hdf5'). compress: If True, compress the output (currently for jso

(
    traces: List[Any],
    output_path: Union[str, Path],
    format: str = "jsonl",
    compress: bool = False,
    metadata: Optional[Dict[str, Any]] = None,
)

Source from the content-addressed store, hash-verified

354
355
356def export_traces(
357 traces: List[Any],
358 output_path: Union[str, Path],
359 format: str = "jsonl",
360 compress: bool = False,
361 metadata: Optional[Dict[str, Any]] = None,
362) -> None:
363 """
364 A high-level wrapper to export traces to a specified format.
365
366 Args:
367 traces: A list of trace objects.
368 output_path: The path to save the file.
369 format: The desired output format ('jsonl', 'json', 'hdf5').
370 compress: If True, compress the output (currently for jsonl only).
371 metadata: Optional metadata (for json and hdf5 formats only).
372 """
373 # Normalize format string to lowercase
374 format = format.lower()
375
376 # Dispatch to the appropriate export function based on the format
377 if format == "jsonl":
378 export_traces_jsonl(traces, output_path, compress=compress)
379 elif format == "json":
380 export_traces_json(traces, output_path, metadata=metadata)
381 elif format == "hdf5":
382 export_traces_hdf5(traces, output_path, metadata=metadata)
383 else:
384 # Raise an error for unsupported formats
385 raise ValueError(f"Unsupported format: {format}. Use 'jsonl', 'json', or 'hdf5'")
386
387
388def load_traces(

Callers 2

closeMethod · 0.90

Calls 3

export_traces_jsonlFunction · 0.85
export_traces_jsonFunction · 0.85
export_traces_hdf5Function · 0.85

Tested by

no test coverage detected