Download app/tests/space-diagnose.mjs from Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP: direct link, hf CLI and curl.
- Browser
- Download file 2.74 kB
-
https://huggingface.co/spaces/Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP/resolve/main/app/tests/space-diagnose.mjs
- Command line
-
hf download hf://spaces/Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP/app/tests/space-diagnose.mjs
-
curl -L -o space-diagnose.mjs https://huggingface.co/spaces/Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP/resolve/main/app/tests/space-diagnose.mjs
2.74 kB
| import {chromium} from 'playwright'; | |
| import fs from 'node:fs/promises'; | |
| const context=await chromium.launchPersistentContext('../validation/agent-browser-profile/space',{executablePath:'/usr/bin/chromium',headless:true,args:['--enable-unsafe-webgpu','--use-angle=vulkan','--enable-features=Vulkan','--disable-vulkan-surface']}); | |
| try { | |
| const page=await context.newPage(); | |
| page.on('console',m=>{if(m.type()==='error')console.log(m.text().slice(0,1000));}); | |
| await page.goto('https://huggingface.co/spaces/Mike0021/MiniCPM5-2B-WebGPU-Pi'); | |
| await page.waitForTimeout(2000); | |
| console.log('IFRAMES',await page.locator('iframe').evaluateAll(es=>es.map(e=>({src:e.src,allow:e.allow,sandbox:e.sandbox.value})))); | |
| const app=page.frames().find(f=>f.url().includes('minicpm5-2b-webgpu-pi.')&&f.url().includes('hf.space')); | |
| await app.waitForFunction(()=>window.browserPi);await app.evaluate(()=>window.browserPi.ready); | |
| console.log('NOTICE',await app.locator('#notice').textContent()); | |
| const probes=await app.evaluate(async()=>{ | |
| const probe=async()=>{ | |
| const checks={}; | |
| const check=async(name,fn)=>{try{checks[name]=await fn();}catch(e){checks[name]={name:e.name,message:e.message,stack:e.stack};}}; | |
| await check('opfs',async()=>{const root=await navigator.storage.getDirectory();const h=await root.getFileHandle('probe',{create:true});const w=await h.createWritable();await w.write('probe');await w.close();return (await h.getFile()).size;}); | |
| await check('estimate',()=>navigator.storage.estimate()); | |
| await check('locks',()=>navigator.locks.request('probe',()=>true)); | |
| await check('gpu',async()=>{const a=await navigator.gpu.requestAdapter();return a?{features:[...a.features]}:null;}); | |
| return checks; | |
| }; | |
| const main=await probe(); | |
| const body='('+probe.toString()+')().then(r=>postMessage(r))'; | |
| const worker=await new Promise((resolve,reject)=>{const w=new Worker(URL.createObjectURL(new Blob([body],{type:'text/javascript'})));w.onmessage=e=>{w.terminate();resolve(e.data)};w.onerror=reject;}); | |
| let access;try{access=await document.hasStorageAccess();}catch(e){access=e.message;} | |
| return {main,worker,access,policy:document.permissionsPolicy?.allowedFeatures?.()}; | |
| }); | |
| console.log('PROBES',JSON.stringify(probes,null,2)); | |
| try{await app.evaluate(()=>window.browserPi.load());}catch(e){console.log('LOAD',e.message);} | |
| console.log('DIAGNOSTICS',await app.evaluate(()=>({notice:document.querySelector('#notice').textContent,load:document.querySelector('#load-status').textContent,progress:document.querySelector('#load-detail').textContent,device:window.browserPi.diagnostics.device}))); | |
| await fs.writeFile('../validation/agent-space-diagnose.json',JSON.stringify(probes,null,2)); | |
| }finally{await context.close();} | |