Skip to content

Commit 18f1af2

Browse files
committed
fix: remove labels from inference setup
1 parent 172ddb2 commit 18f1af2

3 files changed

Lines changed: 122 additions & 28 deletions

File tree

client/src/components/InputSelector.js

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -81,34 +81,30 @@ function InputSelector(props) {
8181
}
8282
/>
8383
</Form.Item>
84-
<Form.Item
85-
label={
86-
<Space align="center">
87-
<span>
88-
{type === "training" ? "Input Label" : "Input Label (Optional)"}
89-
</span>
90-
<InlineHelpChat
91-
taskKey={type}
92-
label="Input Label"
93-
yamlKey="DATASET.LABEL_NAME"
94-
value={workflow.inputLabel}
95-
projectContext={projectContext}
96-
taskContext={taskContext}
97-
/>
98-
</Space>
99-
}
100-
>
101-
<UnifiedFileInput
102-
placeholder="Please select or input label path"
103-
onChange={handleLabelChange}
104-
value={getValue(workflow.inputLabel)}
105-
selectionType={
106-
type === "training" || type === "inference"
107-
? "fileOrDirectory"
108-
: "file"
84+
{type === "training" && (
85+
<Form.Item
86+
label={
87+
<Space align="center">
88+
<span>Input Label</span>
89+
<InlineHelpChat
90+
taskKey={type}
91+
label="Input Label"
92+
yamlKey="DATASET.LABEL_NAME"
93+
value={workflow.inputLabel}
94+
projectContext={projectContext}
95+
taskContext={taskContext}
96+
/>
97+
</Space>
10998
}
110-
/>
111-
</Form.Item>
99+
>
100+
<UnifiedFileInput
101+
placeholder="Please select or input label path"
102+
onChange={handleLabelChange}
103+
value={getValue(workflow.inputLabel)}
104+
selectionType="fileOrDirectory"
105+
/>
106+
</Form.Item>
107+
)}
112108
{type === "training" ? (
113109
<Form.Item
114110
label={
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import React from "react";
2+
import { render, screen } from "@testing-library/react";
3+
4+
import InputSelector from "./InputSelector";
5+
import { AppContext } from "../contexts/GlobalContext";
6+
7+
jest.mock("antd", () => {
8+
const Form = ({ children }) => <form>{children}</form>;
9+
Form.Item = ({ label, children, help }) => (
10+
<div>
11+
{label}
12+
{children}
13+
{help ? <div>{help}</div> : null}
14+
</div>
15+
);
16+
17+
return {
18+
Form,
19+
Space: ({ children }) => <div>{children}</div>,
20+
};
21+
});
22+
23+
jest.mock("./UnifiedFileInput", () => (props) => (
24+
<input
25+
aria-label={props.placeholder}
26+
data-selection-type={props.selectionType}
27+
readOnly
28+
value={typeof props.value === "string" ? props.value : ""}
29+
/>
30+
));
31+
32+
jest.mock("./InlineHelpChat", () => () => null);
33+
34+
beforeAll(() => {
35+
Object.defineProperty(window, "matchMedia", {
36+
writable: true,
37+
value: jest.fn().mockImplementation((query) => ({
38+
matches: false,
39+
media: query,
40+
onchange: null,
41+
addListener: jest.fn(),
42+
removeListener: jest.fn(),
43+
addEventListener: jest.fn(),
44+
removeEventListener: jest.fn(),
45+
dispatchEvent: jest.fn(),
46+
})),
47+
});
48+
});
49+
50+
function renderWithContext(type) {
51+
const contextValue = {
52+
trainingState: {
53+
inputImage: "",
54+
inputLabel: "",
55+
outputPath: "",
56+
logPath: "",
57+
checkpointPath: "",
58+
setInputImage: jest.fn(),
59+
setInputLabel: jest.fn(),
60+
setOutputPath: jest.fn(),
61+
setLogPath: jest.fn(),
62+
setCheckpointPath: jest.fn(),
63+
},
64+
inferenceState: {
65+
inputImage: "",
66+
inputLabel: "/tmp/stale-label.tif",
67+
outputPath: "",
68+
logPath: "",
69+
checkpointPath: "",
70+
setInputImage: jest.fn(),
71+
setInputLabel: jest.fn(),
72+
setOutputPath: jest.fn(),
73+
setLogPath: jest.fn(),
74+
setCheckpointPath: jest.fn(),
75+
},
76+
};
77+
78+
return render(
79+
<AppContext.Provider value={contextValue}>
80+
<InputSelector type={type} />
81+
</AppContext.Provider>,
82+
);
83+
}
84+
85+
describe("InputSelector", () => {
86+
it("shows an input label field for training", () => {
87+
renderWithContext("training");
88+
89+
expect(screen.getByText("Input Label")).toBeTruthy();
90+
});
91+
92+
it("does not show an input label field for inference", () => {
93+
renderWithContext("inference");
94+
95+
expect(screen.queryByText("Input Label")).toBeNull();
96+
expect(screen.queryByText("Input Label (Optional)")).toBeNull();
97+
});
98+
});

client/src/views/ModelInference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function ModelInference({ isInferring, setIsInferring }) {
5454
applyInputPaths(yamlData, {
5555
mode: "inference",
5656
inputImagePath: getPath(inference.inputImage),
57-
inputLabelPath: getPath(inference.inputLabel),
57+
inputLabelPath: "",
5858
inputPath: "",
5959
outputPath: getPath(inference.outputPath),
6060
});

0 commit comments

Comments
 (0)