Spaces:
Running
Running
GitHub Actions commited on
Commit Β·
48fe3e6
1
Parent(s): aa61dca
sync from abhijitramesh/webgpu-bench@83901f51e3
Browse files- js/run/controller.js +14 -3
- js/run/hub.js +11 -0
js/run/controller.js
CHANGED
|
@@ -7,6 +7,7 @@ import { localSource, hostedSource, inventoryOpfs, purgeOpfs } from './source.js
|
|
| 7 |
import { getDeviceBudgetMB, variantFits, describeDevice } from './device.js';
|
| 8 |
import {
|
| 9 |
resumeHFSession, beginHFSignIn, signOutHF, submitResultsToDataset,
|
|
|
|
| 10 |
} from './hub.js';
|
| 11 |
import { isHubConfigured, HF_DATASET_REPO } from './config.js';
|
| 12 |
|
|
@@ -1731,11 +1732,21 @@ function restoreSavedResults() {
|
|
| 1731 |
// canonical location is now sessionStorage.
|
| 1732 |
try { localStorage.removeItem(RESULTS_STORAGE_KEY); } catch { /* noop */ }
|
| 1733 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1734 |
let saved;
|
| 1735 |
try {
|
| 1736 |
-
// sessionStorage matches the per-variant write path: results live for
|
| 1737 |
-
// the tab session (so the OAuth redirect round-trip is covered) and
|
| 1738 |
-
// are gone after the user closes the tab.
|
| 1739 |
const raw = sessionStorage.getItem(RESULTS_STORAGE_KEY);
|
| 1740 |
if (!raw) return;
|
| 1741 |
saved = JSON.parse(raw);
|
|
|
|
| 7 |
import { getDeviceBudgetMB, variantFits, describeDevice } from './device.js';
|
| 8 |
import {
|
| 9 |
resumeHFSession, beginHFSignIn, signOutHF, submitResultsToDataset,
|
| 10 |
+
HF_OAUTH_PENDING_KEY,
|
| 11 |
} from './hub.js';
|
| 12 |
import { isHubConfigured, HF_DATASET_REPO } from './config.js';
|
| 13 |
|
|
|
|
| 1732 |
// canonical location is now sessionStorage.
|
| 1733 |
try { localStorage.removeItem(RESULTS_STORAGE_KEY); } catch { /* noop */ }
|
| 1734 |
|
| 1735 |
+
// Only restore when we just round-tripped through HF for sign-in
|
| 1736 |
+
// (beginHFSignIn() sets HF_OAUTH_PENDING_KEY immediately before the
|
| 1737 |
+
// redirect). A plain refresh has no such marker and should land on a
|
| 1738 |
+
// clean progress table β old runs sticking around was the bug.
|
| 1739 |
+
let oauthPending = false;
|
| 1740 |
+
try { oauthPending = !!sessionStorage.getItem(HF_OAUTH_PENDING_KEY); } catch { /* noop */ }
|
| 1741 |
+
if (!oauthPending) {
|
| 1742 |
+
try { sessionStorage.removeItem(RESULTS_STORAGE_KEY); } catch { /* noop */ }
|
| 1743 |
+
return;
|
| 1744 |
+
}
|
| 1745 |
+
// Consume the marker now so the next plain refresh doesn't restore again.
|
| 1746 |
+
try { sessionStorage.removeItem(HF_OAUTH_PENDING_KEY); } catch { /* noop */ }
|
| 1747 |
+
|
| 1748 |
let saved;
|
| 1749 |
try {
|
|
|
|
|
|
|
|
|
|
| 1750 |
const raw = sessionStorage.getItem(RESULTS_STORAGE_KEY);
|
| 1751 |
if (!raw) return;
|
| 1752 |
saved = JSON.parse(raw);
|
js/run/hub.js
CHANGED
|
@@ -32,6 +32,12 @@ import {
|
|
| 32 |
// (different document load) and is shared across tabs on the same origin.
|
| 33 |
const TOKEN_STORAGE_KEY = 'webgpu-bench:hfOauth';
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
// ββββββββββββββββ session ββββββββββββββββ
|
| 36 |
|
| 37 |
export async function resumeHFSession() {
|
|
@@ -100,6 +106,11 @@ export async function beginHFSignIn() {
|
|
| 100 |
scopes,
|
| 101 |
redirectUrl: location.origin + location.pathname,
|
| 102 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
location.assign(url);
|
| 104 |
}
|
| 105 |
|
|
|
|
| 32 |
// (different document load) and is shared across tabs on the same origin.
|
| 33 |
const TOKEN_STORAGE_KEY = 'webgpu-bench:hfOauth';
|
| 34 |
|
| 35 |
+
// sessionStorage flag set by beginHFSignIn() right before the redirect.
|
| 36 |
+
// The Run controller checks this on mount to decide whether to restore
|
| 37 |
+
// in-flight benchmark results β set means "we're round-tripping through HF,
|
| 38 |
+
// keep the data"; missing means a regular refresh, drop it.
|
| 39 |
+
export const HF_OAUTH_PENDING_KEY = 'webgpu-bench:oauthPending';
|
| 40 |
+
|
| 41 |
// ββββββββββββββββ session ββββββββββββββββ
|
| 42 |
|
| 43 |
export async function resumeHFSession() {
|
|
|
|
| 106 |
scopes,
|
| 107 |
redirectUrl: location.origin + location.pathname,
|
| 108 |
});
|
| 109 |
+
// Mark that we're intentionally leaving the page for the HF OAuth round
|
| 110 |
+
// trip so the controller knows to restore benchmark results when we land
|
| 111 |
+
// back here. A plain refresh (no marker) skips restoration so old runs
|
| 112 |
+
// don't ghost-stick to the progress table.
|
| 113 |
+
try { sessionStorage.setItem(HF_OAUTH_PENDING_KEY, String(Date.now())); } catch { /* quota / disabled */ }
|
| 114 |
location.assign(url);
|
| 115 |
}
|
| 116 |
|