rafmacalaba commited on
Commit
77cea28
·
verified ·
1 Parent(s): 479efd4

ndjson hub commit format

Browse files
Files changed (1) hide show
  1. review.html +3 -4
review.html CHANGED
@@ -279,11 +279,10 @@ async function hubCommit(entry) {
279
  rows = rows.filter(x => !(x.queue === entry.queue && x.key === entry.key));
280
  rows.push({...entry, ts: new Date().toISOString()});
281
  const content = btoa(unescape(encodeURIComponent(rows.map(x => JSON.stringify(x)).join('\n') + '\n')));
282
- const fd = new FormData();
283
- fd.append('operations', JSON.stringify({key: 'headerFile', value: {path, content}}) + '\n');
284
- fd.append('summary', `ruling ${who}: ${entry.key}=${entry.ruling} (web)`);
285
  const res = await fetch(`https://huggingface.co/api/datasets/${repo}/commit/main`, {
286
- method: 'POST', headers: {Authorization: `Bearer ${tok}`}, body: fd});
287
  if (!res.ok) throw new Error('hub ' + res.status);
288
  return 'Hub';
289
  } catch (e) { return 'this browser only (Hub sync failed)'; }
 
279
  rows = rows.filter(x => !(x.queue === entry.queue && x.key === entry.key));
280
  rows.push({...entry, ts: new Date().toISOString()});
281
  const content = btoa(unescape(encodeURIComponent(rows.map(x => JSON.stringify(x)).join('\n') + '\n')));
282
+ const nd = [{key: 'header', value: {summary: `ruling ${who}: ${entry.key}=${entry.ruling} (web)`, description: ''}},
283
+ {key: 'file', value: {content, path, encoding: 'base64'}}].map(o => JSON.stringify(o)).join('\n');
 
284
  const res = await fetch(`https://huggingface.co/api/datasets/${repo}/commit/main`, {
285
+ method: 'POST', headers: {Authorization: `Bearer ${tok}`, 'Content-Type': 'application/x-ndjson'}, body: nd});
286
  if (!res.ok) throw new Error('hub ' + res.status);
287
  return 'Hub';
288
  } catch (e) { return 'this browser only (Hub sync failed)'; }