GitHub Actions commited on
Commit
4aa88a2
·
1 Parent(s): 1d19cea

sync from abhijitramesh/webgpu-bench@35f91a3bac

Browse files
Files changed (4) hide show
  1. README.md +1 -2
  2. js/run/config.js +6 -1
  3. js/run/controller.js +3 -3
  4. js/run/hub.js +11 -5
README.md CHANGED
@@ -9,8 +9,7 @@ pinned: false
9
  short_description: One-click browser benchmark for GGUF models on WebGPU + WASM
10
  hf_oauth: true
11
  hf_oauth_scopes:
12
- - read-repos
13
- - write-repos
14
  ---
15
 
16
  # WebGPU Benchmark — One Click
 
9
  short_description: One-click browser benchmark for GGUF models on WebGPU + WASM
10
  hf_oauth: true
11
  hf_oauth_scopes:
12
+ - write-discussions
 
13
  ---
14
 
15
  # WebGPU Benchmark — One Click
js/run/config.js CHANGED
@@ -14,7 +14,12 @@ export const CONSISTENCY_PROMPT = 'Explain quantum computing in simple terms.';
14
  export const HF_DATASET_REPO = 'abhijitramesh/webgpu-bench-leaderboard';
15
 
16
  // Scopes must match the ones declared in spaces/README.md frontmatter.
17
- export const HF_OAUTH_SCOPES = ['read-repos', 'write-repos'];
 
 
 
 
 
18
 
19
  export function isHubConfigured() {
20
  // Space-OAuth works whenever the dataset is set. The OAuth client ID is
 
14
  export const HF_DATASET_REPO = 'abhijitramesh/webgpu-bench-leaderboard';
15
 
16
  // Scopes must match the ones declared in spaces/README.md frontmatter.
17
+ // `write-discussions` is the minimum needed to open a community PR against
18
+ // the leaderboard dataset on behalf of the signed-in user. `openid` and
19
+ // `profile` are auto-included for Space OAuth, so we don't need to ask for
20
+ // `read-repos`/`write-repos` (which would grant write to ALL the user's
21
+ // repos — far more than needed for a single PR).
22
+ export const HF_OAUTH_SCOPES = ['write-discussions'];
23
 
24
  export function isHubConfigured() {
25
  // Space-OAuth works whenever the dataset is set. The OAuth client ID is
js/run/controller.js CHANGED
@@ -2015,9 +2015,9 @@ function wireHubHandlers() {
2015
  avatarUrl: state.hfSession.avatarUrl || null,
2016
  } : null,
2017
  });
2018
- const link = res.commitUrl
2019
- || `https://huggingface.co/datasets/${HF_DATASET_REPO}/blob/main/${res.path}`;
2020
- logLine(`Submitted ${eligible.length} variant(s): ${link}`);
2021
  // Restore the real label before flashing so the post-flash revert
2022
  // doesn't snap back to "Submitting…".
2023
  submitBtn.textContent = original;
 
2015
  avatarUrl: state.hfSession.avatarUrl || null,
2016
  } : null,
2017
  });
2018
+ const link = res.pullRequestUrl
2019
+ || `https://huggingface.co/datasets/${HF_DATASET_REPO}/discussions`;
2020
+ logLine(`Opened PR with ${eligible.length} variant(s): ${link}`);
2021
  // Restore the real label before flashing so the post-flash revert
2022
  // doesn't snap back to "Submitting…".
2023
  submitBtn.textContent = original;
js/run/hub.js CHANGED
@@ -11,9 +11,11 @@
11
  // token in localStorage. The Run controller restores any previously
12
  // saved benchmark results from localStorage so they survive the
13
  // OAuth round-trip.
14
- // 3. Clicking [Submit] calls `submitResultsToDataset()` which commits a
15
- // JSON file (one per machine-slug / browser / session) as a PR to the
16
- // leaderboard dataset.
 
 
17
 
18
  import {
19
  oauthLoginUrl,
@@ -135,7 +137,7 @@ export async function fetchWhoAmI(token) {
135
  * @param {{name: string, hubId?: string, avatarUrl?: string}} [opts.submittedBy]
136
  * — captured from the OAuth session and stamped onto each record so the
137
  * dashboard can attribute submissions back to a HF user.
138
- * @returns {Promise<{ path: string, commit?: string, prUrl?: string }>}
139
  */
140
  export async function submitResultsToDataset(results, {
141
  token,
@@ -163,16 +165,20 @@ export async function submitResultsToDataset(results, {
163
  const body = JSON.stringify(stamped, null, 2);
164
  const blob = new Blob([body], { type: 'application/json' });
165
 
 
 
 
166
  const res = await uploadFile({
167
  repo: { type: 'dataset', name: datasetRepo },
168
  credentials: { accessToken: token },
169
  file: { path, content: blob },
170
  commitTitle: `bench: ${machineSlug} / ${browser} / ${results.length} variants`,
 
171
  });
172
 
173
  return {
174
  path,
175
  commit: res?.commit?.oid || null,
176
- commitUrl: `https://huggingface.co/datasets/${datasetRepo}/blob/main/${path}`,
177
  };
178
  }
 
11
  // token in localStorage. The Run controller restores any previously
12
  // saved benchmark results from localStorage so they survive the
13
  // OAuth round-trip.
14
+ // 3. Clicking [Submit] calls `submitResultsToDataset()` which opens a
15
+ // community Pull Request adding a JSON file (one per machine-slug /
16
+ // browser / session) against the leaderboard dataset. We open a PR
17
+ // (not a direct commit) so any signed-in user can submit — they only
18
+ // need the `write-discussions` scope, not write access to the dataset.
19
 
20
  import {
21
  oauthLoginUrl,
 
137
  * @param {{name: string, hubId?: string, avatarUrl?: string}} [opts.submittedBy]
138
  * — captured from the OAuth session and stamped onto each record so the
139
  * dashboard can attribute submissions back to a HF user.
140
+ * @returns {Promise<{ path: string, commit?: string, pullRequestUrl?: string }>}
141
  */
142
  export async function submitResultsToDataset(results, {
143
  token,
 
165
  const body = JSON.stringify(stamped, null, 2);
166
  const blob = new Blob([body], { type: 'application/json' });
167
 
168
+ // isPullRequest: true so any signed-in user can submit — the upload becomes
169
+ // a community PR against the dataset rather than a direct commit (which
170
+ // would 403 for everyone except the dataset owner).
171
  const res = await uploadFile({
172
  repo: { type: 'dataset', name: datasetRepo },
173
  credentials: { accessToken: token },
174
  file: { path, content: blob },
175
  commitTitle: `bench: ${machineSlug} / ${browser} / ${results.length} variants`,
176
+ isPullRequest: true,
177
  });
178
 
179
  return {
180
  path,
181
  commit: res?.commit?.oid || null,
182
+ pullRequestUrl: res?.pullRequestUrl || null,
183
  };
184
  }