Skip to content

Commit 05c82b2

Browse files
committed
fix: removed none and enforced runtime exlusion
Signed-off-by: Brian <[email protected]>
1 parent 6cd4a8f commit 05c82b2

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

packages/frontend/src/lib/select/InferenceRuntimeSelect.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import InferenceRuntimeSelect from '/@/lib/select/InferenceRuntimeSelect.svelte'
2323
import { InferenceType } from '@shared/models/IInference';
2424

2525
const getFilteredOptions = (exclude: InferenceType[] = []): InferenceType[] =>
26-
Object.values(InferenceType).filter(type => !exclude.includes(type));
26+
Object.values(InferenceType).filter(type => type !== InferenceType.NONE && !exclude.includes(type));
2727

2828
beforeEach(() => {
2929
// mock scrollIntoView

packages/frontend/src/lib/select/InferenceRuntimeSelect.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface Props {
1010
let { value = $bindable(), disabled, exclude = [] }: Props = $props();
1111
1212
// Filter options based on optional exclude list
13-
const options = Object.values(InferenceType).filter(type => !exclude.includes(type));
13+
const options = Object.values(InferenceType).filter(type => type !== InferenceType.NONE && !exclude.includes(type));
1414
1515
function handleOnChange(nValue: { value: string } | undefined): void {
1616
if (nValue) {

packages/frontend/src/pages/PlaygroundCreate.spec.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,32 @@ beforeEach(() => {
102102
vi.mocked(tasksStore).tasks = tasksList;
103103
});
104104

105-
test('model should be selected by default', () => {
105+
test('model should not be selected by default when no runtime is set', () => {
106+
const modelsInfoList = writable<ModelInfo[]>([dummyLlamaCppModel]);
107+
vi.mocked(modelsInfoStore).modelsInfo = modelsInfoList;
108+
109+
const { container } = render(PlaygroundCreate);
110+
111+
// Model should not be displayed because it's filtered out when runtime is undefined
112+
const model = within(container).queryByText(dummyLlamaCppModel.name);
113+
expect(model).toBeNull();
114+
});
115+
116+
test('model should be selected by default when runtime is set', async () => {
106117
const modelsInfoList = writable<ModelInfo[]>([dummyLlamaCppModel]);
107118
vi.mocked(modelsInfoStore).modelsInfo = modelsInfoList;
108119

109120
vi.mocked(studioClient.requestCreatePlayground).mockRejectedValue('error creating playground');
110121

111122
const { container } = render(PlaygroundCreate);
112123

124+
// Select our runtime
125+
const dropdown = within(container).getByLabelText('Select Inference Runtime');
126+
await userEvent.click(dropdown);
127+
128+
const llamacppOption = within(container).getByText(InferenceType.LLAMA_CPP);
129+
await userEvent.click(llamacppOption);
130+
113131
const model = within(container).getByText(dummyLlamaCppModel.name);
114132
expect(model).toBeInTheDocument();
115133
});
@@ -152,6 +170,12 @@ test('should display error message if createPlayground fails', async () => {
152170
const errorMessage = within(container).queryByLabelText('Error Message Content');
153171
expect(errorMessage).not.toBeInTheDocument();
154172

173+
//make sure to select model
174+
const dropdown = within(container).getByLabelText('Select Model');
175+
await userEvent.click(dropdown);
176+
const option = within(container).getByText(dummyLlamaCppModel.name);
177+
await userEvent.click(option);
178+
155179
const createButton = within(container).getByTitle('Create playground');
156180
await userEvent.click(createButton);
157181

packages/frontend/src/pages/PlaygroundCreate.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ import ModelSelect from '/@/lib/select/ModelSelect.svelte';
1616
import { InferenceType } from '@shared/models/IInference';
1717
import InferenceRuntimeSelect from '/@/lib/select/InferenceRuntimeSelect.svelte';
1818
19-
// Preset the runtime selection
2019
let runtime: InferenceType | undefined = undefined;
21-
// exlude whisper.cpp from selection
20+
// exlude certain runtimes from selection
2221
let exclude: InferenceType[] = [InferenceType.WHISPER_CPP];
2322
let localModels: ModelInfo[];
24-
// Special case for "ALL" returns runtimes with optional exclution
2523
$: localModels = $modelsInfo.filter(
2624
model => model.file && (!runtime || model.backend === runtime) && !exclude.includes(model.backend as InferenceType),
2725
);
@@ -38,7 +36,8 @@ let trackingId: string | undefined = undefined;
3836
// The trackedTasks are the tasks linked to the trackingId
3937
let trackedTasks: Task[] = [];
4038
41-
$: if (localModels.length > 0) {
39+
// Preset model selection depending on runtime
40+
$: if (runtime && localModels.length > 0) {
4241
model = localModels[0];
4342
} else {
4443
model = undefined;
@@ -158,6 +157,7 @@ export function goToUpPage(): void {
158157
Inference Runtime
159158
</label>
160159
<InferenceRuntimeSelect bind:value={runtime} exclude={exclude} />
160+
161161
<!-- model input -->
162162
<label for="model" class="pt-4 block mb-2 font-bold text-[var(--pd-content-card-header-text)]">Model</label>
163163
<ModelSelect models={localModels} disabled={submitted} bind:value={model} />

0 commit comments

Comments
 (0)