-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathModelEvaluation.tsx
More file actions
80 lines (71 loc) · 2.41 KB
/
ModelEvaluation.tsx
File metadata and controls
80 lines (71 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { styled } from "styled-components";
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react";
import type { ModeledMethod } from "../../model-editor/modeled-method";
import type { ModelEditorViewState } from "../../model-editor/shared/view-state";
import type { ModelEvaluationRunState } from "../../model-editor/shared/model-evaluation-run-state";
import { modelEvaluationRunIsRunning } from "../../model-editor/shared/model-evaluation-run-state";
import { ModelEditorProgressRing } from "./ModelEditorProgressRing";
import { LinkIconButton } from "../common/LinkIconButton";
import { Link } from "../common/Link";
export type Props = {
viewState: ModelEditorViewState;
modeledMethods: Record<string, ModeledMethod[]>;
modifiedSignatures: Set<string>;
onStartEvaluation: () => void;
onStopEvaluation: () => void;
openModelAlertsView: () => void;
evaluationRun: ModelEvaluationRunState | undefined;
};
const RunLink = styled(Link)`
display: flex;
align-items: center;
`;
export const ModelEvaluation = ({
viewState,
modeledMethods,
modifiedSignatures,
onStartEvaluation,
onStopEvaluation,
openModelAlertsView,
evaluationRun,
}: Props) => {
if (!viewState.showEvaluationUi) {
return null;
}
const shouldShowEvaluateButton =
!evaluationRun || !modelEvaluationRunIsRunning(evaluationRun);
const shouldShowStopButton = !shouldShowEvaluateButton;
const shouldShowEvaluationRunLink =
!!evaluationRun && evaluationRun.variantAnalysis;
const customModelsExist = Object.values(modeledMethods).some(
(methods) => methods.filter((m) => m.type !== "none").length > 0,
);
const unsavedChanges = modifiedSignatures.size > 0;
return (
<>
{shouldShowEvaluateButton && (
<VSCodeButton
onClick={onStartEvaluation}
appearance="secondary"
disabled={!customModelsExist || unsavedChanges}
>
Evaluate
</VSCodeButton>
)}
{shouldShowStopButton && (
<VSCodeButton onClick={onStopEvaluation} appearance="secondary">
<ModelEditorProgressRing />
Stop evaluation
</VSCodeButton>
)}
{shouldShowEvaluationRunLink && (
<RunLink>
<LinkIconButton onClick={openModelAlertsView}>
<span slot="end" className="codicon codicon-link-external"></span>
Evaluation run
</LinkIconButton>
</RunLink>
)}
</>
);
};