Skip to content

Commit 59dad1b

Browse files
committed
fix: removed none and enforced runtime exlusion
Signed-off-by: Brian <[email protected]>
1 parent 6913af8 commit 59dad1b

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ import { beforeEach, vi, test, expect } from 'vitest';
2121
import { render, fireEvent, within } from '@testing-library/svelte';
2222
import InferenceRuntimeSelect from '/@/lib/select/InferenceRuntimeSelect.svelte';
2323
import { InferenceType } from '@shared/models/IInference';
24+
import * as os from 'node:os';
2425

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

2829
beforeEach(() => {
2930
// mock scrollIntoView
@@ -95,3 +96,22 @@ test('Exclude specific runtime from list', async () => {
9596
expect(itemTexts).toContain(included);
9697
});
9798
});
99+
100+
test('Does not show OPENVINO on macOS', async () => {
101+
const platformSpy = vi.spyOn(os, 'platform').mockReturnValue('darwin');
102+
103+
const { container } = render(InferenceRuntimeSelect, {
104+
value: undefined,
105+
disabled: false,
106+
});
107+
108+
const input = within(container).getByLabelText('Select Inference Runtime');
109+
await fireEvent.pointerUp(input);
110+
111+
const items = container.querySelectorAll('div[class~="list-item"]');
112+
const itemTexts = Array.from(items).map(item => item.textContent?.trim());
113+
114+
expect(itemTexts).not.toContain(InferenceType.OPENVINO);
115+
116+
platformSpy.mockRestore();
117+
});

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.svelte

Lines changed: 3 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;

0 commit comments

Comments
 (0)