@@ -14,47 +14,17 @@ import { basename, dirname, join, relative } from "path";
1414import { Uri , window , workspace } from "vscode" ;
1515import type { CodeQLCliServer } from "../codeql-cli/cli" ;
1616import type { App } from "../common/app" ;
17+ import type { ArtifactDownload , MinimalDownloadsType } from "../common/dca" ;
18+ import { dcaControllerRepository } from "../common/dca" ;
1719import { createTimeoutSignal } from "../common/fetch-stream" ;
1820import { extLogger } from "../common/logging/vscode" ;
1921import type { ProgressCallback } from "../common/vscode/progress" ;
2022import { reportStreamProgress , withProgress } from "../common/vscode/progress" ;
2123import { downloadTimeout , GITHUB_URL } from "../config" ;
2224import { QueryOutputDir } from "../local-queries/query-output-dir" ;
25+ import type { ComparePerformanceDescriptionData } from "../log-insights/performance-comparison" ;
2326import { tmpDir } from "../tmp-dir" ;
2427
25- type VariantId = string ;
26- type SourceId = string ;
27- type TargetId = string ;
28-
29- type TargetInfo = {
30- target_id : TargetId ;
31- variant_id : VariantId ;
32- source_id : SourceId ;
33- } ;
34-
35- type ArtifactDownload = {
36- repository : string ;
37- run_id : number ;
38- artifact_name : string ;
39- } ;
40-
41- type TargetDownloads = {
42- "evaluator-logs" : ArtifactDownload ;
43- } ;
44-
45- type MinimalDownloadsType = {
46- targets : {
47- [ target : string ] : {
48- info : TargetInfo ;
49- downloads : TargetDownloads ;
50- } ;
51- } ;
52- } ;
53-
54- const dcaControllerRepository = {
55- owner : "github" ,
56- repo : "codeql-dca-main" ,
57- } ;
5828export class RemoteLogs {
5929 private LOG_DOWNLOAD_AND_PROCESS_PROGRESS_STEPS = 4 ;
6030 private PICK_TARGETS_PROGRESS_STEPS = 4 ;
@@ -283,6 +253,7 @@ export class RemoteLogs {
283253 | {
284254 before : string ;
285255 after : string ;
256+ description : ComparePerformanceDescriptionData ;
286257 }
287258 | undefined
288259 > {
@@ -299,7 +270,11 @@ export class RemoteLogs {
299270 if ( processed . some ( ( d ) => typeof d === "undefined" ) ) {
300271 throw new Error ( "Silently failed to download or process some logs!?" ) ;
301272 }
302- return { before : processed [ 0 ] ! , after : processed [ 1 ] ! } ;
273+ return {
274+ before : processed [ 0 ] ! ,
275+ after : processed [ 1 ] ! ,
276+ description : picked . description ,
277+ } ;
303278 }
304279
305280 /**
@@ -489,20 +464,21 @@ export class RemoteLogs {
489464 } ;
490465 }
491466
492- private async getPotentialTargetInfos (
493- experimentName : string ,
494- ) : Promise < Array < MinimalDownloadsType [ "targets" ] [ "string" ] > > {
467+ private async getPotentialTargetInfos ( experimentName : string ) : Promise < {
468+ targets : Array < MinimalDownloadsType [ "targets" ] [ "string" ] > ;
469+ info : MinimalDownloadsType ;
470+ } > {
495471 const tasksDir = await this . getTasksForExperiment ( experimentName ) ;
496472
497473 const downloads = await this . getDownloadsFromTasks ( tasksDir ) ;
498474 void extLogger . log (
499475 `Found ${ Object . keys ( downloads . targets ) . length } potential targets in experiment ${ experimentName } ` ,
500476 ) ;
501- return Object . values ( downloads . targets ) ;
477+ return { targets : Object . values ( downloads . targets ) , info : downloads } ;
502478 }
503479
504480 /**
505- * Gets the "downloads" metadata from a taksks directory.
481+ * Gets the "downloads" metadata from a tasks directory.
506482 */
507483 private async getDownloadsFromTasks (
508484 tasksDir : string ,
@@ -669,6 +645,7 @@ export class RemoteLogs {
669645 | {
670646 before : ArtifactDownload ;
671647 after : ArtifactDownload ;
648+ description : ComparePerformanceDescriptionData ;
672649 }
673650 | undefined
674651 > {
@@ -696,8 +673,9 @@ export class RemoteLogs {
696673 step : 2 ,
697674 maxStep : this . PICK_TARGETS_PROGRESS_STEPS ,
698675 } ) ;
699- const targetInfos = await this . getPotentialTargetInfos ( experimentChoice ) ;
700- if ( targetInfos . length === 0 ) {
676+ const { targets, info } =
677+ await this . getPotentialTargetInfos ( experimentChoice ) ;
678+ if ( targets . length === 0 ) {
701679 throw new Error (
702680 `No targets found in experiment ${ experimentChoice } . Is the experiment complete enough yet?` ,
703681 ) ;
@@ -708,7 +686,7 @@ export class RemoteLogs {
708686 maxStep : this . PICK_TARGETS_PROGRESS_STEPS ,
709687 } ) ;
710688 const targetChoice1 = await window . showQuickPick (
711- targetInfos . map ( ( t ) => t . info . target_id ) ,
689+ targets . map ( ( t ) => t . info . target_id ) ,
712690 {
713691 title : `Pick target 1` ,
714692 ignoreFocusOut : true ,
@@ -717,7 +695,7 @@ export class RemoteLogs {
717695 if ( ! targetChoice1 ) {
718696 return undefined ;
719697 }
720- const targetInfoChoice1 = targetInfos . find (
698+ const targetInfoChoice1 = targets . find (
721699 ( t ) => t . info . target_id === targetChoice1 ,
722700 ) ! ;
723701 progress ?.( {
@@ -726,7 +704,7 @@ export class RemoteLogs {
726704 maxStep : this . PICK_TARGETS_PROGRESS_STEPS ,
727705 } ) ;
728706 const targetChoice2 = await window . showQuickPick (
729- targetInfos
707+ targets
730708 . filter (
731709 ( t ) =>
732710 t . info . target_id !== targetChoice1 &&
@@ -748,10 +726,19 @@ export class RemoteLogs {
748726 void extLogger . log (
749727 `Picked ${ experimentChoice } ${ targetChoice1 } ${ targetChoice2 } ` ,
750728 ) ;
729+ const targetInfoChoice2 = targets . find (
730+ ( t ) => t . info . target_id === targetChoice2 ,
731+ ) ! ;
751732 return {
752733 before : targetInfoChoice1 . downloads [ "evaluator-logs" ] ,
753- after : targetInfos . find ( ( t ) => t . info . target_id === targetChoice2 ) !
754- . downloads [ "evaluator-logs" ] ,
734+ after : targetInfoChoice2 . downloads [ "evaluator-logs" ] ,
735+ description : {
736+ kind : "remote-logs" ,
737+ experimentName : experimentChoice ,
738+ fromTarget : targetChoice1 ,
739+ toTarget : targetChoice2 ,
740+ info,
741+ } ,
755742 } ;
756743 }
757744}
0 commit comments