Add dev/: training and export scripts, GPAI rule tests, browser tests, workspace map
28e3615 verified Download dev/browser-tests/net.mjs from Devseis/Caveat: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/spaces/Devseis/Caveat/resolve/main/dev/browser-tests/net.mjs
- Command line
-
hf download hf://spaces/Devseis/Caveat/dev/browser-tests/net.mjs
-
curl -L -o net.mjs https://huggingface.co/spaces/Devseis/Caveat/resolve/main/dev/browser-tests/net.mjs
1.83 kB
| import puppeteer from "puppeteer-core"; | |
| const URL_ = process.argv[2] || "https://devseis-caveat.static.hf.space/"; | |
| const S = "/Users/umer/Documents/hf/tools/browser-tests/out"; | |
| const b = await puppeteer.launch({ executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", headless: true, userDataDir: S + "/prof_net", protocolTimeout: 180000 }); | |
| const p = await b.newPage(); await p.setCacheEnabled(false); | |
| const reqs = new Map(); const errs = []; | |
| p.on("pageerror", (e) => errs.push(e.message)); | |
| p.on("response", async (r) => { const u = r.url(); const host = new URL(u).host; if (!u.startsWith("data:")) { let len = Number(r.headers()["content-length"] || 0); reqs.set(u, { host, status: r.status(), len }); } }); | |
| await p.setRequestInterception(true); | |
| p.on("request", (r) => /clarity\.ms/.test(r.url()) ? r.abort() : r.continue()); | |
| await p.goto(URL_, { waitUntil: "domcontentloaded" }); | |
| await p.waitForFunction(() => !document.getElementById("runBtn").disabled && document.getElementById("runBtn").textContent === "Check", { timeout: 150000 }); | |
| if (await p.evaluate(() => !document.getElementById("consent").hidden)) await p.click("#consentDecline"); | |
| await p.click('.chip[data-ex="2"]'); await p.click("#runBtn"); | |
| await p.waitForFunction(() => !document.getElementById("p1result").hidden, { timeout: 60000 }); | |
| const p1 = await p.$eval("#p1pill", (e) => e.textContent); | |
| const hosts = {}; | |
| for (const [u, v] of reqs) { (hosts[v.host] ||= []).push(`${v.status} ${(v.len / 1e6).toFixed(2)}MB ${u.replace(/^https?:\/\/[^/]+/, "")}`); } | |
| for (const [h, list] of Object.entries(hosts)) { console.log(`== ${h} (${list.length})`); if (h !== new URL(URL_).host) list.forEach((l) => console.log(" " + l)); } | |
| console.log("trained model answer:", p1, "| errors:", errs.length ? errs.join(" | ") : "none"); | |
| await b.close(); | |