@@ -262,7 +262,7 @@ def print_report():
262
262
# Fetch required fields, including total_cost and total_tokens
263
263
c .execute (
264
264
"""
265
- SELECT file_name, execution_status, time_taken, total_embedding_cost, total_embedding_tokens, total_llm_cost, total_llm_tokens
265
+ SELECT file_name, execution_status, time_taken, total_embedding_cost, total_embedding_tokens, total_llm_cost, total_llm_tokens, error_message
266
266
FROM file_status
267
267
"""
268
268
)
@@ -274,36 +274,49 @@ def print_report():
274
274
if report_data :
275
275
# Tabulate the data with column headers
276
276
headers = [
277
- textwrap .fill (header , width = 20 )
278
- for header in [
279
- "File Name" ,
280
- "Execution Status" ,
281
- "Time Elapsed (seconds)" ,
282
- "Total Embedding Cost" ,
283
- "Total Embedding Tokens" ,
284
- "Total LLM Cost" ,
285
- "Total LLM Tokens" ,
286
- ]
277
+ "File Name" ,
278
+ "Execution Status" ,
279
+ "Time Elapsed (seconds)" ,
280
+ "Total Embedding Cost" ,
281
+ "Total Embedding Tokens" ,
282
+ "Total LLM Cost" ,
283
+ "Total LLM Tokens" ,
284
+ "Error Message"
287
285
]
288
-
286
+
287
+ column_widths = {
288
+ "File Name" : 30 ,
289
+ "Execution Status" : 20 ,
290
+ "Time Elapsed (seconds)" : 20 ,
291
+ "Total Embedding Cost" : 20 ,
292
+ "Total Embedding Tokens" : 20 ,
293
+ "Total LLM Cost" : 20 ,
294
+ "Total LLM Tokens" : 20 ,
295
+ "Error Message" : 30 ,
296
+ }
289
297
290
298
formatted_data = []
291
- # Wrap text in each column to a specific width (e.g., 30 characters for file names and 20 for others) and return None if the value is NULL
299
+ # Format and wrap each row's data to match column widths
292
300
for row in report_data :
293
- formatted_row = [
294
- "None" if cell is None else
295
- textwrap .fill (str (cell ), width = 30 ) if isinstance (cell , str ) else
296
- cell if idx == 2 else f"{ cell :.8f} " if isinstance (cell , float ) else cell
297
- for idx , cell in enumerate (row )
298
- ]
299
- formatted_data .append (formatted_row )
300
-
301
+ formatted_row = []
302
+ for idx , cell in enumerate (row ):
303
+ header = headers [idx ]
304
+ width = column_widths [header ]
305
+ cell_value = "None" if cell is None else str (cell )
306
+ if header == "Error Message" and len (cell_value ) > 50 :
307
+ # Truncate long error messages
308
+ cell_value = textwrap .fill (cell_value [:100 ], width = width ) + "..."
309
+ else :
310
+ cell_value = textwrap .fill (cell_value , width = width )
311
+ formatted_row .append (cell_value )
312
+ formatted_data .append (formatted_row )
313
+
314
+ # Print the table
301
315
print (tabulate (formatted_data , headers = headers , tablefmt = "pretty" ))
302
316
else :
303
317
print ("No records found in the database." )
304
-
305
- # Suggest CSV report for error details
306
- print ("\n Note: Use the `--export_csv` argument to generate a CSV report that includes error messages." )
318
+
319
+ print ("\n Note: For more detailed error messages, use the CSV report argument." )
307
320
308
321
def export_report_to_csv (output_path ):
309
322
conn = sqlite3 .connect (DB_NAME )
@@ -622,4 +635,4 @@ def main():
622
635
623
636
624
637
if __name__ == "__main__" :
625
- main ()
638
+ main ()
0 commit comments