Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
machineuser
commited on
Commit
·
bdf492b
1
Parent(s):
4d70550
Sync widgets demo
Browse files
packages/widgets/src/lib/components/InferenceWidget/shared/WidgetWrapper/WidgetWrapper.svelte
CHANGED
|
@@ -73,15 +73,17 @@
|
|
| 73 |
|
| 74 |
onMount(() => {
|
| 75 |
(async () => {
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
| 85 |
}
|
| 86 |
|
| 87 |
const exampleFromQueryParams = {} as TWidgetExample;
|
|
@@ -110,42 +112,44 @@
|
|
| 110 |
<WidgetHeader pipeline={model.pipeline_tag} noTitle={true} />
|
| 111 |
<WidgetInfo {model} {computeTime} {error} {modelLoadInfo} {modelTooBig} />
|
| 112 |
{:else}
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
<
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
{
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
{isLoading}
|
| 131 |
-
|
|
|
|
| 132 |
/>
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
</div>
|
| 141 |
{/if}
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
<WidgetModelLoading estimatedTime={modelLoading.estimatedTime} />
|
| 147 |
-
{/if}
|
| 148 |
-
<slot name="bottom" />
|
| 149 |
-
<WidgetFooter bind:isMaximized {outputJson} {isDisabled} />
|
| 150 |
-
</div>
|
| 151 |
{/if}
|
|
|
|
| 73 |
|
| 74 |
onMount(() => {
|
| 75 |
(async () => {
|
| 76 |
+
if (model.inference === InferenceDisplayability.Yes) {
|
| 77 |
+
modelLoadInfo = await getModelLoadInfo(apiUrl, model.id, includeCredentials);
|
| 78 |
+
$modelLoadStates[model.id] = modelLoadInfo;
|
| 79 |
+
modelTooBig = modelLoadInfo?.state === "TooBig";
|
| 80 |
|
| 81 |
+
if (modelTooBig) {
|
| 82 |
+
// disable the widget
|
| 83 |
+
isDisabled = true;
|
| 84 |
+
inputSamples = allInputSamples.filter((sample) => sample.output !== undefined);
|
| 85 |
+
inputGroups = getExamplesGroups();
|
| 86 |
+
}
|
| 87 |
}
|
| 88 |
|
| 89 |
const exampleFromQueryParams = {} as TWidgetExample;
|
|
|
|
| 112 |
<WidgetHeader pipeline={model.pipeline_tag} noTitle={true} />
|
| 113 |
<WidgetInfo {model} {computeTime} {error} {modelLoadInfo} {modelTooBig} />
|
| 114 |
{:else}
|
| 115 |
+
<!-- require that we have `modelLoadInfo` for InferenceDisplayability.Yes models -->
|
| 116 |
+
{#if modelLoadInfo || model.inference !== InferenceDisplayability.Yes}
|
| 117 |
+
<div
|
| 118 |
+
class="flex w-full max-w-full flex-col
|
| 119 |
+
{isMaximized ? 'fixed inset-0 z-20 bg-white p-12' : ''}"
|
| 120 |
+
>
|
| 121 |
+
{#if isMaximized}
|
| 122 |
+
<button class="absolute right-12 top-6" on:click={() => (isMaximized = !isMaximized)}>
|
| 123 |
+
<IconCross classNames="text-xl text-gray-500 hover:text-black" />
|
| 124 |
+
</button>
|
| 125 |
+
{/if}
|
| 126 |
+
<WidgetHeader {noTitle} pipeline={model.pipeline_tag} {isDisabled}>
|
| 127 |
+
{#if !!inputGroups.length}
|
| 128 |
+
<div class="ml-auto flex gap-x-1">
|
| 129 |
+
<!-- Show samples selector when there are more than one sample -->
|
| 130 |
+
{#if inputGroups.length > 1}
|
| 131 |
+
<WidgetInputSamplesGroup
|
| 132 |
+
bind:selectedInputGroup
|
| 133 |
+
{isLoading}
|
| 134 |
+
inputGroups={inputGroups.map(({ group }) => group)}
|
| 135 |
+
/>
|
| 136 |
+
{/if}
|
| 137 |
+
<WidgetInputSamples
|
| 138 |
+
classNames={!selectedInputSamples ? "opacity-50 pointer-events-none" : ""}
|
| 139 |
{isLoading}
|
| 140 |
+
inputSamples={selectedInputSamples?.inputSamples ?? []}
|
| 141 |
+
{applyInputSample}
|
| 142 |
/>
|
| 143 |
+
</div>
|
| 144 |
+
{/if}
|
| 145 |
+
</WidgetHeader>
|
| 146 |
+
<slot name="top" {isDisabled} />
|
| 147 |
+
<WidgetInfo {model} {computeTime} {error} {modelLoadInfo} {modelTooBig} />
|
| 148 |
+
{#if modelLoading.isLoading}
|
| 149 |
+
<WidgetModelLoading estimatedTime={modelLoading.estimatedTime} />
|
|
|
|
| 150 |
{/if}
|
| 151 |
+
<slot name="bottom" />
|
| 152 |
+
<WidgetFooter bind:isMaximized {outputJson} {isDisabled} />
|
| 153 |
+
</div>
|
| 154 |
+
{/if}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
{/if}
|