Upload folder using huggingface_hub
Browse files
6.25.0/workflowcanvas/workflow/WorkflowCanvas.svelte
CHANGED
|
@@ -8,9 +8,6 @@
|
|
| 8 |
import NodeModelPicker from "./NodeModelPicker.svelte";
|
| 9 |
import WorkflowEmptyState from "./WorkflowEmptyState.svelte";
|
| 10 |
import WorkflowApiPanel from "./WorkflowApiPanel.svelte";
|
| 11 |
-
import WorkflowHistoryPanel from "./WorkflowHistoryPanel.svelte";
|
| 12 |
-
import WorkflowHistoryConnect from "./WorkflowHistoryConnect.svelte";
|
| 13 |
-
import { push_record_to_bucket } from "@gradio/client";
|
| 14 |
import CheckIcon from "./icons/CheckIcon.svelte";
|
| 15 |
import LayoutIcon from "./icons/LayoutIcon.svelte";
|
| 16 |
import InfoIcon from "./icons/InfoIcon.svelte";
|
|
@@ -141,6 +138,12 @@
|
|
| 141 |
void auth.init();
|
| 142 |
});
|
| 143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
let oauthHintShown = false;
|
| 145 |
$effect(() => {
|
| 146 |
if (
|
|
@@ -148,6 +151,7 @@
|
|
| 148 |
auth.isHFSpace &&
|
| 149 |
auth.writeAccessKnown &&
|
| 150 |
!auth.canWrite &&
|
|
|
|
| 151 |
!auth.oauthAvailable
|
| 152 |
) {
|
| 153 |
oauthHintShown = true;
|
|
@@ -340,37 +344,6 @@
|
|
| 340 |
let showShortcuts = $state(false);
|
| 341 |
let showUserMenu = $state(false);
|
| 342 |
let showApiPanel = $state(false);
|
| 343 |
-
let showHistoryPanel = $state(false);
|
| 344 |
-
let showHistoryConnect = $state(false);
|
| 345 |
-
let historyRefreshCount = $state(0);
|
| 346 |
-
|
| 347 |
-
// Root URL for the /gradio_api/history/* routes. Prefers the client's
|
| 348 |
-
// configured root (correct for tunnels / mounted-at-path deployments),
|
| 349 |
-
// falls back to the page origin.
|
| 350 |
-
const historyRoot = $derived(
|
| 351 |
-
gradio_client?.config?.root ?? window.location.origin
|
| 352 |
-
);
|
| 353 |
-
|
| 354 |
-
// Per-workflow bucket id, persisted in localStorage keyed by workflow name.
|
| 355 |
-
const bucketStorageKey = $derived(
|
| 356 |
-
`gradio:workflow-history:bucket:${$workflow.name || "default"}`
|
| 357 |
-
);
|
| 358 |
-
let bucketId = $state<string>("");
|
| 359 |
-
$effect(() => {
|
| 360 |
-
try {
|
| 361 |
-
bucketId = window.localStorage.getItem(bucketStorageKey) ?? "";
|
| 362 |
-
} catch {
|
| 363 |
-
bucketId = "";
|
| 364 |
-
}
|
| 365 |
-
});
|
| 366 |
-
function setBucketId(id: string): void {
|
| 367 |
-
bucketId = id;
|
| 368 |
-
try {
|
| 369 |
-
if (id) window.localStorage.setItem(bucketStorageKey, id);
|
| 370 |
-
else window.localStorage.removeItem(bucketStorageKey);
|
| 371 |
-
} catch {}
|
| 372 |
-
}
|
| 373 |
-
|
| 374 |
// Popover shown when the "Run only" badge is clicked, explaining why editing
|
| 375 |
// is disabled and how to enable it.
|
| 376 |
let showAccessInfo = $state(false);
|
|
@@ -1771,58 +1744,6 @@
|
|
| 1771 |
abortController = null;
|
| 1772 |
|
| 1773 |
const hasErrors = Object.values(nodeStatus).some((s) => s === "error");
|
| 1774 |
-
|
| 1775 |
-
// Push a run record to the bucket if configured. Fire-and-forget.
|
| 1776 |
-
if (bucketId && !hasErrors) {
|
| 1777 |
-
try {
|
| 1778 |
-
const now = new Date().toISOString();
|
| 1779 |
-
const inputs: Record<string, unknown> = {};
|
| 1780 |
-
for (const ref of wfToRun.references) {
|
| 1781 |
-
const node = legacyView.nodes.find((n) => n.id === ref.id);
|
| 1782 |
-
const outPort = node?.outputs?.[0];
|
| 1783 |
-
if (!node || !outPort) continue;
|
| 1784 |
-
const value = node.data?.[outPort.id] ?? null;
|
| 1785 |
-
inputs[ref.id] = {
|
| 1786 |
-
value,
|
| 1787 |
-
type: outPort.type,
|
| 1788 |
-
label: node.label,
|
| 1789 |
-
port_id: outPort.id
|
| 1790 |
-
};
|
| 1791 |
-
}
|
| 1792 |
-
const outputs: Record<string, unknown> = {};
|
| 1793 |
-
for (const subj of wfToRun.subjects) {
|
| 1794 |
-
const node = legacyView.nodes.find((n) => n.id === subj.id);
|
| 1795 |
-
const inPort = node?.inputs?.[0];
|
| 1796 |
-
if (!node || !inPort) continue;
|
| 1797 |
-
const value = node.data?.[inPort.id] ?? null;
|
| 1798 |
-
outputs[subj.id] = {
|
| 1799 |
-
value,
|
| 1800 |
-
type: inPort.type,
|
| 1801 |
-
label: node.label
|
| 1802 |
-
};
|
| 1803 |
-
}
|
| 1804 |
-
const record: any = {
|
| 1805 |
-
id: crypto.randomUUID().replace(/-/g, "").slice(0, 24),
|
| 1806 |
-
timestamp: now,
|
| 1807 |
-
started_at: now,
|
| 1808 |
-
status: "completed",
|
| 1809 |
-
subgraph: $workflow.name || "workflow",
|
| 1810 |
-
subject_ids: wfToRun.subjects.map((s) => s.id),
|
| 1811 |
-
inputs,
|
| 1812 |
-
outputs,
|
| 1813 |
-
user: null
|
| 1814 |
-
};
|
| 1815 |
-
push_record_to_bucket(historyRoot, bucketId, record);
|
| 1816 |
-
if (showHistoryPanel) {
|
| 1817 |
-
setTimeout(() => {
|
| 1818 |
-
historyRefreshCount++;
|
| 1819 |
-
}, 1500);
|
| 1820 |
-
}
|
| 1821 |
-
} catch {
|
| 1822 |
-
// history push is best-effort
|
| 1823 |
-
}
|
| 1824 |
-
}
|
| 1825 |
-
|
| 1826 |
showToast(
|
| 1827 |
hasErrors ? "Workflow finished with errors" : "Workflow complete",
|
| 1828 |
hasErrors ? 5000 : 3000,
|
|
@@ -2408,23 +2329,6 @@
|
|
| 2408 |
<CodeIcon />
|
| 2409 |
View API
|
| 2410 |
</button>
|
| 2411 |
-
{#if bucketId}
|
| 2412 |
-
<button
|
| 2413 |
-
class="tool-btn history-btn"
|
| 2414 |
-
onclick={() => (showHistoryPanel = true)}
|
| 2415 |
-
title="Browse generation history"
|
| 2416 |
-
>
|
| 2417 |
-
History
|
| 2418 |
-
</button>
|
| 2419 |
-
{:else}
|
| 2420 |
-
<button
|
| 2421 |
-
class="tool-btn connect-bucket-btn"
|
| 2422 |
-
onclick={() => (showHistoryConnect = true)}
|
| 2423 |
-
title="Connect a HF Hub bucket to persist generation history"
|
| 2424 |
-
>
|
| 2425 |
-
Connect bucket
|
| 2426 |
-
</button>
|
| 2427 |
-
{/if}
|
| 2428 |
{#if saveIndicator}
|
| 2429 |
<span
|
| 2430 |
class="save-indicator"
|
|
@@ -2924,42 +2828,6 @@
|
|
| 2924 |
/>
|
| 2925 |
{/if}
|
| 2926 |
|
| 2927 |
-
{#if showHistoryConnect}
|
| 2928 |
-
<WorkflowHistoryConnect
|
| 2929 |
-
root={historyRoot}
|
| 2930 |
-
workflowName={$workflow.name}
|
| 2931 |
-
onconnected={(id) => {
|
| 2932 |
-
setBucketId(id);
|
| 2933 |
-
showHistoryConnect = false;
|
| 2934 |
-
showHistoryPanel = true;
|
| 2935 |
-
}}
|
| 2936 |
-
onclose={() => (showHistoryConnect = false)}
|
| 2937 |
-
/>
|
| 2938 |
-
{/if}
|
| 2939 |
-
|
| 2940 |
-
{#if showHistoryPanel && bucketId}
|
| 2941 |
-
<WorkflowHistoryPanel
|
| 2942 |
-
root={historyRoot}
|
| 2943 |
-
{bucketId}
|
| 2944 |
-
triggerRefresh={historyRefreshCount}
|
| 2945 |
-
onclose={() => (showHistoryPanel = false)}
|
| 2946 |
-
onchange={() => {
|
| 2947 |
-
showHistoryPanel = false;
|
| 2948 |
-
showHistoryConnect = true;
|
| 2949 |
-
}}
|
| 2950 |
-
onload={(inputs) => {
|
| 2951 |
-
for (const [nodeId, input] of Object.entries(
|
| 2952 |
-
inputs as Record<string, any>
|
| 2953 |
-
)) {
|
| 2954 |
-
const portId: string = (input as any).port_id ?? "out_0";
|
| 2955 |
-
const value = (input as any).value;
|
| 2956 |
-
updateNodeData(nodeId, portId, value);
|
| 2957 |
-
}
|
| 2958 |
-
showHistoryPanel = false;
|
| 2959 |
-
}}
|
| 2960 |
-
/>
|
| 2961 |
-
{/if}
|
| 2962 |
-
|
| 2963 |
{#if fullscreenImage}
|
| 2964 |
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
|
| 2965 |
<div
|
|
|
|
| 8 |
import NodeModelPicker from "./NodeModelPicker.svelte";
|
| 9 |
import WorkflowEmptyState from "./WorkflowEmptyState.svelte";
|
| 10 |
import WorkflowApiPanel from "./WorkflowApiPanel.svelte";
|
|
|
|
|
|
|
|
|
|
| 11 |
import CheckIcon from "./icons/CheckIcon.svelte";
|
| 12 |
import LayoutIcon from "./icons/LayoutIcon.svelte";
|
| 13 |
import InfoIcon from "./icons/InfoIcon.svelte";
|
|
|
|
| 138 |
void auth.init();
|
| 139 |
});
|
| 140 |
|
| 141 |
+
$effect(() => {
|
| 142 |
+
if (server?.get_oauth_available && !auth.oauthAvailableKnown) {
|
| 143 |
+
void auth.refreshOAuthAvailable();
|
| 144 |
+
}
|
| 145 |
+
});
|
| 146 |
+
|
| 147 |
let oauthHintShown = false;
|
| 148 |
$effect(() => {
|
| 149 |
if (
|
|
|
|
| 151 |
auth.isHFSpace &&
|
| 152 |
auth.writeAccessKnown &&
|
| 153 |
!auth.canWrite &&
|
| 154 |
+
auth.oauthAvailableKnown &&
|
| 155 |
!auth.oauthAvailable
|
| 156 |
) {
|
| 157 |
oauthHintShown = true;
|
|
|
|
| 344 |
let showShortcuts = $state(false);
|
| 345 |
let showUserMenu = $state(false);
|
| 346 |
let showApiPanel = $state(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
// Popover shown when the "Run only" badge is clicked, explaining why editing
|
| 348 |
// is disabled and how to enable it.
|
| 349 |
let showAccessInfo = $state(false);
|
|
|
|
| 1744 |
abortController = null;
|
| 1745 |
|
| 1746 |
const hasErrors = Object.values(nodeStatus).some((s) => s === "error");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1747 |
showToast(
|
| 1748 |
hasErrors ? "Workflow finished with errors" : "Workflow complete",
|
| 1749 |
hasErrors ? 5000 : 3000,
|
|
|
|
| 2329 |
<CodeIcon />
|
| 2330 |
View API
|
| 2331 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2332 |
{#if saveIndicator}
|
| 2333 |
<span
|
| 2334 |
class="save-indicator"
|
|
|
|
| 2828 |
/>
|
| 2829 |
{/if}
|
| 2830 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2831 |
{#if fullscreenImage}
|
| 2832 |
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
|
| 2833 |
<div
|
6.25.0/workflowcanvas/workflow/hf-auth.svelte.ts
CHANGED
|
@@ -106,6 +106,7 @@ export function createHFAuth(getServer: () => Record<string, any>) {
|
|
| 106 |
// Defaults to false so a broken "Sign in" button never flashes before the
|
| 107 |
// server confirms it — only shown once known to work.
|
| 108 |
let oauthAvailable = $state(false);
|
|
|
|
| 109 |
|
| 110 |
function clearIdentity(): void {
|
| 111 |
user = "";
|
|
@@ -144,14 +145,13 @@ export function createHFAuth(getServer: () => Record<string, any>) {
|
|
| 144 |
|
| 145 |
async function refreshOAuthAvailable(): Promise<void> {
|
| 146 |
const s = getServer();
|
| 147 |
-
if (!s?.get_oauth_available)
|
| 148 |
-
oauthAvailable = false;
|
| 149 |
-
return;
|
| 150 |
-
}
|
| 151 |
try {
|
| 152 |
oauthAvailable = (await s.get_oauth_available()) === "true";
|
|
|
|
| 153 |
} catch {
|
| 154 |
oauthAvailable = false;
|
|
|
|
| 155 |
}
|
| 156 |
}
|
| 157 |
|
|
@@ -301,6 +301,10 @@ export function createHFAuth(getServer: () => Record<string, any>) {
|
|
| 301 |
get oauthAvailable() {
|
| 302 |
return oauthAvailable;
|
| 303 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
init,
|
| 305 |
setPAT,
|
| 306 |
signIn,
|
|
|
|
| 106 |
// Defaults to false so a broken "Sign in" button never flashes before the
|
| 107 |
// server confirms it — only shown once known to work.
|
| 108 |
let oauthAvailable = $state(false);
|
| 109 |
+
let oauthAvailableKnown = $state(false);
|
| 110 |
|
| 111 |
function clearIdentity(): void {
|
| 112 |
user = "";
|
|
|
|
| 145 |
|
| 146 |
async function refreshOAuthAvailable(): Promise<void> {
|
| 147 |
const s = getServer();
|
| 148 |
+
if (!s?.get_oauth_available) return;
|
|
|
|
|
|
|
|
|
|
| 149 |
try {
|
| 150 |
oauthAvailable = (await s.get_oauth_available()) === "true";
|
| 151 |
+
oauthAvailableKnown = true;
|
| 152 |
} catch {
|
| 153 |
oauthAvailable = false;
|
| 154 |
+
oauthAvailableKnown = true;
|
| 155 |
}
|
| 156 |
}
|
| 157 |
|
|
|
|
| 301 |
get oauthAvailable() {
|
| 302 |
return oauthAvailable;
|
| 303 |
},
|
| 304 |
+
get oauthAvailableKnown() {
|
| 305 |
+
return oauthAvailableKnown;
|
| 306 |
+
},
|
| 307 |
+
refreshOAuthAvailable,
|
| 308 |
init,
|
| 309 |
setPAT,
|
| 310 |
signIn,
|