Spaces:
Running
Running
File size: 933 Bytes
638568b 86bca38 8af3478 638568b 86bca38 638568b 86bca38 638568b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | // The commit of the dataset the page reads: asked of the Hub once and shared by the first screen (first.js) and the
// reader of the index (data.js), so both name the same commit.
import { datasetInfo } from 'https://cdn.jsdelivr.net/npm/@huggingface/hub@2.17.10/+esm';
export const REPO = 'Battam/training-data-foundation';
export const HF = 'https://huggingface.co';
const asked = new Map();
/** The commit to read: ?rev=<sha or branch>, else main. -> {sha, date, files}; sha is '' when the Hub gave none. */
export function loadRevision(rev) {
const key = rev || 'main';
if (!asked.has(key)) {
asked.set(key, datasetInfo({ name: REPO, revision: key, additionalFields: ['sha', 'siblings'] }).then((j) => {
const sha = /^[0-9a-f]{40}$/.test(j.sha || '') ? j.sha : '';
return { sha, date: j.updatedAt.toISOString(), files: (j.siblings || []).map((s) => s.rfilename) };
}));
}
return asked.get(key);
}
|