File tree Expand file tree Collapse file tree 6 files changed +34
-34
lines changed
sdk/accuracy-snapshot-storage Expand file tree Collapse file tree 6 files changed +34
-34
lines changed Original file line number Diff line number Diff line change 1
1
import { getAccuracySnapshotStorage } from "../tests/accuracy/sdk/accuracy-snapshot-storage/get-snapshot-storage.js" ;
2
+ import {
3
+ AccuracyRunStatus ,
4
+ AccuracyRunStatuses ,
5
+ } from "../tests/accuracy/sdk/accuracy-snapshot-storage/snapshot-storage.js" ;
2
6
3
- console . time ( `Marked accuracy run id - ${ process . env . MDB_ACCURACY_RUN_ID } as finished in` ) ;
7
+ let status : AccuracyRunStatuses | undefined ;
8
+ if ( process . env . MDB_ACCURACY_RUN_STATUS === "done" ) {
9
+ status = AccuracyRunStatus . Done ;
10
+ } else if ( process . env . MDB_ACCURACY_RUN_STATUS === "failed" ) {
11
+ status = AccuracyRunStatus . Failed ;
12
+ } else {
13
+ console . info ( `Unknown status - ${ process . env . MDB_ACCURACY_RUN_STATUS } , will not update accuracy run.` ) ;
14
+ process . exit ( 1 ) ;
15
+ }
16
+
17
+ console . time ( `Marked accuracy run id - ${ process . env . MDB_ACCURACY_RUN_ID } as ${ status } in` ) ;
4
18
const storage = await getAccuracySnapshotStorage ( ) ;
5
- await storage . accuracyRunFinished ( ) ;
19
+ await storage . updateAccuracyRunStatus ( status ) ;
6
20
await storage . close ( ) ;
7
- console . timeEnd ( `Marked accuracy run id - ${ process . env . MDB_ACCURACY_RUN_ID } as finished in` ) ;
21
+ console . timeEnd ( `Marked accuracy run id - ${ process . env . MDB_ACCURACY_RUN_ID } as ${ status } in` ) ;
Original file line number Diff line number Diff line change @@ -22,7 +22,10 @@ node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathPattern "
22
22
23
23
# Each test run submits an accuracy snapshot entry for each prompt with the
24
24
# accuracyRunStatus: "in-progress". When all the tests are done and jest exits
25
- # with an exit code of 0, we can safely mark accuracy run as finished.
25
+ # with an exit code of 0, we can safely mark accuracy run as finished otherwise
26
+ # failed.
26
27
if [ $? -eq 0 ]; then
27
- npx tsx scripts/mark-accuracy-run-finished.ts
28
+ MDB_ACCURACY_RUN_STATUS=" done" npx tsx scripts/mark-accuracy-run-finished.ts
29
+ else
30
+ MDB_ACCURACY_RUN_STATUS=" failed" npx tsx scripts/mark-accuracy-run-finished.ts
28
31
fi
Original file line number Diff line number Diff line change 1
1
import { describeAccuracyTests , describeSuite } from "./sdk/describe-accuracy-tests.js" ;
2
2
import { getAvailableModels } from "./sdk/models.js" ;
3
3
import { AccuracyTestConfig } from "./sdk/describe-accuracy-tests.js" ;
4
- import { collectionSchemaResponse } from "../../src/tools/mongodb/metadata/collectionSchema.js" ;
5
- import { getSimplifiedSchema } from "mongodb-schema" ;
6
4
7
5
function callsCollectionSchema ( prompt : string ) : AccuracyTestConfig {
8
6
return {
9
7
injectConnectedAssumption : true ,
10
8
prompt : prompt ,
11
- mockedTools : {
12
- "collection-schema" : async function collectionSchema ( ) {
13
- return collectionSchemaResponse (
14
- "db1" ,
15
- "coll1" ,
16
- await getSimplifiedSchema ( [
17
- {
18
- name : "Sample name1" ,
19
- dob : "28.11.2001" ,
20
- location : "NY" ,
21
- } ,
22
- {
23
- name : "Sample name1" ,
24
- dob : "28.11.2001" ,
25
- location : "NY" ,
26
- title : "Dr." ,
27
- } ,
28
- ] )
29
- ) ;
30
- } ,
31
- } ,
9
+ mockedTools : { } ,
32
10
expectedToolCalls : [
33
11
{
34
12
toolName : "collection-schema" ,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import fs from "fs/promises";
3
3
import { fileURLToPath } from "url" ;
4
4
import {
5
5
AccuracyRunStatus ,
6
+ AccuracyRunStatuses ,
6
7
AccuracySnapshotEntry ,
7
8
AccuracySnapshotEntrySchema ,
8
9
AccuracySnapshotStorage ,
@@ -57,13 +58,13 @@ export class DiskSnapshotStorage implements AccuracySnapshotStorage {
57
58
return latestRunId ? snapshot . filter ( ( entry ) => entry . accuracyRunId === latestRunId ) : [ ] ;
58
59
}
59
60
60
- async accuracyRunFinished ( ) : Promise < void > {
61
+ async updateAccuracyRunStatus ( status : AccuracyRunStatuses ) {
61
62
const snapshot = await this . readSnapshot ( ) ;
62
63
const updatedSnapshot = snapshot . map ( ( entry ) => {
63
64
if ( entry . accuracyRunId === this . accuracyRunId ) {
64
65
return {
65
66
...entry ,
66
- accuracyRunStatus : AccuracyRunStatus . Done ,
67
+ accuracyRunStatus : status ,
67
68
} ;
68
69
}
69
70
Original file line number Diff line number Diff line change 1
1
import { Collection , MongoClient } from "mongodb" ;
2
2
import {
3
3
AccuracyRunStatus ,
4
+ AccuracyRunStatuses ,
4
5
AccuracySnapshotEntry ,
5
6
AccuracySnapshotEntrySchema ,
6
7
AccuracySnapshotStorage ,
@@ -76,10 +77,10 @@ export class MongoDBSnapshotStorage implements AccuracySnapshotStorage {
76
77
return AccuracySnapshotEntrySchema . array ( ) . parse ( snapshotEntries ) ;
77
78
}
78
79
79
- async accuracyRunFinished ( ) : Promise < void > {
80
+ async updateAccuracyRunStatus ( status : AccuracyRunStatuses ) {
80
81
await this . snapshotCollection . updateMany (
81
82
{ accuracyRunId : this . accuracyRunId } ,
82
- { $set : { accuracyRunStatus : AccuracyRunStatus . Done } }
83
+ { $set : { accuracyRunStatus : status } }
83
84
) ;
84
85
}
85
86
Original file line number Diff line number Diff line change @@ -11,14 +11,17 @@ export type ActualToolCall = z.infer<typeof ActualToolCallSchema>;
11
11
12
12
export const AccuracyRunStatus = {
13
13
Done : "done" ,
14
+ Failed : "failed" ,
14
15
InProgress : "in-progress" ,
15
16
} as const ;
16
17
18
+ export type AccuracyRunStatuses = ( typeof AccuracyRunStatus ) [ keyof typeof AccuracyRunStatus ] ;
19
+
17
20
export const AccuracySnapshotEntrySchema = z . object ( {
18
21
// Git and meta information for snapshot entries
19
22
accuracyRunId : z . string ( ) ,
20
23
accuracyRunStatus : z
21
- . enum ( [ AccuracyRunStatus . Done , AccuracyRunStatus . InProgress ] )
24
+ . enum ( [ AccuracyRunStatus . Done , AccuracyRunStatus . Failed , AccuracyRunStatus . InProgress ] )
22
25
. default ( AccuracyRunStatus . InProgress ) ,
23
26
createdOn : z . number ( ) ,
24
27
commitSHA : z . string ( ) ,
@@ -67,7 +70,7 @@ export interface AccuracySnapshotStorage {
67
70
68
71
getLatestSnapshotsForCommit ( commit : string ) : Promise < AccuracySnapshotEntry [ ] > ;
69
72
70
- accuracyRunFinished ( ) : Promise < void > ;
73
+ updateAccuracyRunStatus ( status : AccuracyRunStatuses ) : Promise < void > ;
71
74
72
75
close ( ) : Promise < void > ;
73
76
}
You can’t perform that action at this time.
0 commit comments