@@ -18,7 +18,6 @@ import {
1818 window ,
1919 workspace ,
2020} from 'vscode' ;
21- import * as JsonlParser from 'stream-json/jsonl/Parser' ;
2221import { QueryHistoryConfig } from './config' ;
2322import {
2423 showAndLogErrorMessage ,
@@ -53,6 +52,7 @@ import { EvalLogData, parseViewerData } from './pure/log-summary-parser';
5352import { PipelineInfo , SummarySymbols } from './log-insights/summary-parser' ;
5453import { DiagnosticSeverity } from 'vscode-languageclient' ;
5554import { EvaluationLogProblemReporter , EvaluationLogScannerProvider } from './log-insights/log-scanner' ;
55+ import { readJsonlFile } from './log-insights/jsonl-reader' ;
5656
5757/**
5858 * query-history.ts
@@ -983,7 +983,7 @@ export class QueryHistoryManager extends DisposableObject {
983983 }
984984
985985 // Summary log file doesn't exist.
986- if ( finalSingleItem . evalLogLocation && fs . pathExists ( finalSingleItem . evalLogLocation ) ) {
986+ if ( finalSingleItem . evalLogLocation && await fs . pathExists ( finalSingleItem . evalLogLocation ) ) {
987987 // If raw log does exist, then the summary log is still being generated.
988988 this . warnInProgressEvalLogSummary ( ) ;
989989 } else {
@@ -1008,14 +1008,13 @@ export class QueryHistoryManager extends DisposableObject {
10081008 }
10091009
10101010 // TODO(angelapwen): Stream the file in.
1011- void fs . readFile ( finalSingleItem . jsonEvalLogSummaryLocation , async ( err , buffer ) => {
1012- if ( err ) {
1013- throw new Error ( `Could not read evaluator log summary JSON file to generate viewer data at ${ finalSingleItem . jsonEvalLogSummaryLocation } .` ) ;
1014- }
1015- const evalLogData : EvalLogData [ ] = parseViewerData ( buffer . toString ( ) ) ;
1011+ try {
1012+ const evalLogData : EvalLogData [ ] = await parseViewerData ( finalSingleItem . jsonEvalLogSummaryLocation ) ;
10161013 const evalLogTreeBuilder = new EvalLogTreeBuilder ( finalSingleItem . getQueryName ( ) , evalLogData ) ;
10171014 this . evalLogViewer . updateRoots ( await evalLogTreeBuilder . getRoots ( ) ) ;
1018- } ) ;
1015+ } catch ( e ) {
1016+ throw new Error ( `Could not read evaluator log summary JSON file to generate viewer data at ${ finalSingleItem . jsonEvalLogSummaryLocation } .` ) ;
1017+ }
10191018 }
10201019
10211020 /**
@@ -1027,12 +1026,12 @@ export class QueryHistoryManager extends DisposableObject {
10271026 query : LocalQueryInfo
10281027 ) : Promise < void > {
10291028 this . diagnosticCollection . clear ( ) ;
1030- if ( query . evalLogJsonSummaryLocation ) {
1031- const diagnostics = await this . scanLog ( query . evalLogJsonSummaryLocation , query . evalLogSummarySymbolsLocation ) ;
1029+ if ( query . jsonEvalLogSummaryLocation ) {
1030+ const diagnostics = await this . scanLog ( query . jsonEvalLogSummaryLocation , query . evalLogSummarySymbolsLocation ) ;
10321031 const uri = Uri . file ( query . evalLogSummaryLocation ! ) ;
10331032 this . diagnosticCollection . set ( uri , diagnostics ) ;
10341033 } else {
1035- this . warnNoEvalLog ( ) ;
1034+ this . warnNoEvalLogs ( ) ;
10361035 }
10371036 }
10381037
@@ -1244,17 +1243,10 @@ export class QueryHistoryManager extends DisposableObject {
12441243
12451244 const scanners = [ ...this . scannerProviders . values ( ) ] . map ( p => p . createScanner ( problemReporter ) ) ;
12461245
1247- const stream = fs . createReadStream ( jsonSummaryLocation )
1248- . pipe ( JsonlParser . parser ( ) )
1249- . on ( 'data' , ( { value } ) => {
1250- scanners . forEach ( scanner => {
1251- scanner . onEvent ( value ) ;
1252- } ) ;
1246+ await readJsonlFile ( jsonSummaryLocation , async obj => {
1247+ scanners . forEach ( scanner => {
1248+ scanner . onEvent ( obj ) ;
12531249 } ) ;
1254-
1255- await new Promise ( function ( resolve , reject ) {
1256- stream . on ( 'end' , resolve ) ;
1257- stream . on ( 'error' , reject ) ;
12581250 } ) ;
12591251
12601252 scanners . forEach ( scanner => scanner . onDone ( ) ) ;
0 commit comments