Skip to content

Commit 096e701

Browse files
committed
feat: enrich the remote logs info table
1 parent c04c42c commit 096e701

File tree

3 files changed

+60
-28
lines changed

3 files changed

+60
-28
lines changed

extensions/ql-vscode/src/compare-performance/remote-logs.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import type { ProgressCallback } from "../common/vscode/progress";
2222
import { reportStreamProgress, withProgress } from "../common/vscode/progress";
2323
import { downloadTimeout, GITHUB_URL } from "../config";
2424
import { QueryOutputDir } from "../local-queries/query-output-dir";
25-
import { tmpDir } from "../tmp-dir";
2625
import type { ComparePerformanceDescriptionData } from "../log-insights/performance-comparison";
26+
import { tmpDir } from "../tmp-dir";
2727

2828
export class RemoteLogs {
2929
private LOG_DOWNLOAD_AND_PROCESS_PROGRESS_STEPS = 4;
@@ -464,16 +464,17 @@ export class RemoteLogs {
464464
};
465465
}
466466

467-
private async getPotentialTargetInfos(
468-
experimentName: string,
469-
): Promise<Array<MinimalDownloadsType["targets"]["string"]>> {
467+
private async getPotentialTargetInfos(experimentName: string): Promise<{
468+
targets: Array<MinimalDownloadsType["targets"]["string"]>;
469+
info: MinimalDownloadsType;
470+
}> {
470471
const tasksDir = await this.getTasksForExperiment(experimentName);
471472

472473
const downloads = await this.getDownloadsFromTasks(tasksDir);
473474
void extLogger.log(
474475
`Found ${Object.keys(downloads.targets).length} potential targets in experiment ${experimentName}`,
475476
);
476-
return Object.values(downloads.targets);
477+
return { targets: Object.values(downloads.targets), info: downloads };
477478
}
478479

479480
/**
@@ -672,8 +673,9 @@ export class RemoteLogs {
672673
step: 2,
673674
maxStep: this.PICK_TARGETS_PROGRESS_STEPS,
674675
});
675-
const targetInfos = await this.getPotentialTargetInfos(experimentChoice);
676-
if (targetInfos.length === 0) {
676+
const { targets, info } =
677+
await this.getPotentialTargetInfos(experimentChoice);
678+
if (targets.length === 0) {
677679
throw new Error(
678680
`No targets found in experiment ${experimentChoice}. Is the experiment complete enough yet?`,
679681
);
@@ -684,7 +686,7 @@ export class RemoteLogs {
684686
maxStep: this.PICK_TARGETS_PROGRESS_STEPS,
685687
});
686688
const targetChoice1 = await window.showQuickPick(
687-
targetInfos.map((t) => t.info.target_id),
689+
targets.map((t) => t.info.target_id),
688690
{
689691
title: `Pick target 1`,
690692
ignoreFocusOut: true,
@@ -693,7 +695,7 @@ export class RemoteLogs {
693695
if (!targetChoice1) {
694696
return undefined;
695697
}
696-
const targetInfoChoice1 = targetInfos.find(
698+
const targetInfoChoice1 = targets.find(
697699
(t) => t.info.target_id === targetChoice1,
698700
)!;
699701
progress?.({
@@ -702,7 +704,7 @@ export class RemoteLogs {
702704
maxStep: this.PICK_TARGETS_PROGRESS_STEPS,
703705
});
704706
const targetChoice2 = await window.showQuickPick(
705-
targetInfos
707+
targets
706708
.filter(
707709
(t) =>
708710
t.info.target_id !== targetChoice1 &&
@@ -724,7 +726,7 @@ export class RemoteLogs {
724726
void extLogger.log(
725727
`Picked ${experimentChoice} ${targetChoice1} ${targetChoice2}`,
726728
);
727-
const targetInfoChoice2 = targetInfos.find(
729+
const targetInfoChoice2 = targets.find(
728730
(t) => t.info.target_id === targetChoice2,
729731
)!;
730732
return {
@@ -733,8 +735,9 @@ export class RemoteLogs {
733735
description: {
734736
kind: "remote-logs",
735737
experimentName: experimentChoice,
736-
fromTarget: targetInfoChoice1,
737-
toTarget: targetInfoChoice2,
738+
fromTarget: targetChoice1,
739+
toTarget: targetChoice2,
740+
info,
738741
},
739742
};
740743
}

extensions/ql-vscode/src/log-insights/performance-comparison.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ export type ComparePerformanceDescriptionData =
6262
| {
6363
kind: "remote-logs";
6464
experimentName: string;
65-
fromTarget: MinimalDownloadsType["targets"]["string"];
66-
toTarget: MinimalDownloadsType["targets"]["string"];
65+
fromTarget: string;
66+
toTarget: string;
67+
info: MinimalDownloadsType;
6768
};
6869

6970
export class PerformanceOverviewScanner implements EvaluationLogScanner {

extensions/ql-vscode/src/view/common/ComparePerformanceRemoteLogsDescription.tsx

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { styled } from "styled-components";
12
import type { ComparePerformanceDescriptionData } from "../../log-insights/performance-comparison";
23

34
// XXX same as in dca.ts, but importing that file here hangs esbuild?!
@@ -23,50 +24,74 @@ function getActionsRunUrl(run: { repository: string; run_id: number }) {
2324
return `${GITHUB_URL.toString()}${run.repository}/actions/runs/${run.run_id}`;
2425
}
2526

27+
function getRepoTreeUrl(source: { repository: string; sha: string }) {
28+
return `${GITHUB_URL.toString()}${source.repository}/tree/${source.sha}`;
29+
}
30+
2631
const TargetRow = ({
2732
kind,
2833
target,
34+
info,
2935
}: {
3036
kind: string;
3137
target: Props["fromTarget"] | Props["toTarget"];
38+
info: Props["info"];
3239
}) => {
40+
const targetObj = info.targets[target];
41+
const sourceObj = info.sources[targetObj.info.source_id];
3342
return (
3443
// TODO make these rows richer
3544
<tr>
3645
<td>{kind}</td>
37-
<td>{target.info.target_id}</td>
38-
<td>{target.info.variant_id}</td>
39-
<td>{target.info.source_id}</td>
46+
<td>{target}</td>
47+
<td>
48+
<a href={getRepoTreeUrl(sourceObj.info)}>
49+
{sourceObj.info.repository}@{sourceObj.info.sha.slice(0, 7)}
50+
</a>
51+
</td>
4052
<td>
41-
<a href={getActionsRunUrl(target.downloads["evaluator-logs"])}>
42-
{target.downloads["evaluator-logs"].run_id}
53+
<a href={getActionsRunUrl(targetObj.downloads["evaluator-logs"])}>
54+
{targetObj.downloads["evaluator-logs"].run_id}
4355
</a>
4456
</td>
4557
</tr>
4658
);
4759
};
60+
61+
const TargetTableDiv = styled.div`
62+
table {
63+
border-collapse: collapse;
64+
}
65+
66+
table td {
67+
padding: 5px;
68+
border: 1px solid #aaa;
69+
}
70+
71+
tr.head {
72+
background: #eee;
73+
}
74+
`;
75+
4876
const TargetTable = ({
4977
fromTarget,
5078
toTarget,
51-
}: {
52-
fromTarget: Props["fromTarget"];
53-
toTarget: Props["toTarget"];
54-
}) => {
79+
info,
80+
}: Pick<Props, "fromTarget" | "toTarget" | "info">) => {
5581
// show a table of the targets and their details: fullTargetId, variantId, source repository, runId
5682
return (
5783
<table>
5884
<thead>
5985
<tr>
6086
<th>Kind</th>
6187
<th>Target</th>
62-
<th>Variant</th>
6388
<th>Source</th>
6489
<th>Run</th>
6590
</tr>
6691
</thead>
6792
<tbody>
68-
<TargetRow kind="from" target={fromTarget} />
69-
<TargetRow kind="to" target={toTarget} />
93+
<TargetRow kind="from" target={fromTarget} info={info} />
94+
<TargetRow kind="to" target={toTarget} info={info} />
7095
</tbody>
7196
</table>
7297
);
@@ -76,6 +101,7 @@ export const ComparePerformanceRemoteLogsDescription = ({
76101
experimentName,
77102
fromTarget,
78103
toTarget,
104+
info,
79105
}: Props) => {
80106
return (
81107
<div>
@@ -85,7 +111,9 @@ export const ComparePerformanceRemoteLogsDescription = ({
85111
<a href={getExperimentUrl(experimentName)}>{experimentName}</a>
86112
</strong>
87113
</p>
88-
{TargetTable({ fromTarget, toTarget })}
114+
<TargetTableDiv>
115+
<TargetTable {...{ fromTarget, toTarget, info }} />
116+
</TargetTableDiv>
89117
</div>
90118
);
91119
};

0 commit comments

Comments
 (0)