Spaces:
Running
Running
Download tests/release.test.cjs from alphabell/Model-Observatory: direct link, hf CLI and curl.
- Browser
- Download file 2.14 kB
-
https://huggingface.co/spaces/alphabell/Model-Observatory/resolve/main/tests/release.test.cjs
- Command line
-
hf download hf://spaces/alphabell/Model-Observatory/tests/release.test.cjs
-
curl -L -o release.test.cjs https://huggingface.co/spaces/alphabell/Model-Observatory/resolve/main/tests/release.test.cjs
2.14 kB
| ; | |
| const test=require('node:test'); | |
| const assert=require('node:assert/strict'); | |
| const fs=require('node:fs'); | |
| const path=require('node:path'); | |
| const zlib=require('node:zlib'); | |
| const crypto=require('node:crypto'); | |
| const root=path.resolve(__dirname,'..'); | |
| const digest=b=>crypto.createHash('sha256').update(b).digest('hex'); | |
| const rows=JSON.parse(fs.readFileSync(path.join(root,'traces/index.json'))); | |
| for(const row of rows){ | |
| test(row.model+' capture matches both published checksums and exact frame count',()=>{ | |
| const compressed=fs.readFileSync(path.join(root,row.file)),plain=zlib.gunzipSync(compressed),trace=JSON.parse(plain); | |
| assert.equal(digest(compressed),row.gzip_sha256);assert.equal(digest(plain),row.sha256); | |
| assert.equal(plain.length,row.bytes);assert.equal(compressed.length,row.compressed_bytes); | |
| assert.equal(trace.id,row.id);assert.equal(trace.model.id,row.model);assert.equal(trace.frames.length,row.tokens); | |
| assert.equal(trace.prompt,row.prompt);assert.equal(trace.result.reason,'eos'); | |
| }); | |
| } | |
| test('the examples share the same original prompt and sampling settings',()=>{ | |
| const traces=rows.map(row=>JSON.parse(zlib.gunzipSync(fs.readFileSync(path.join(root,row.file))))); | |
| assert.equal(traces[0].prompt,traces[1].prompt);assert.deepEqual(traces[0].settings,traces[1].settings); | |
| assert.equal(traces.reduce((n,t)=>n+t.frames.length,0),103); | |
| }); | |
| test('the static entry point references files included in the release',()=>{ | |
| const html=fs.readFileSync(path.join(root,'index.html'),'utf8'); | |
| for(const [,file]of html.matchAll(/(?:src|href)="([^"?#]+\.(?:js|css|svg))"/g))assert.ok(fs.statSync(path.join(root,file)).isFile(),file); | |
| for(const name of ['README.md','TRACE-FORMAT.md','NOTICE','LICENSE','cover.png','preview.png','sources.json'])assert.ok(fs.statSync(path.join(root,name)).size>0,name); | |
| }); | |
| test('the viewer has no inference or third-party font dependency',()=>{ | |
| const app=fs.readFileSync(path.join(root,'app.js'),'utf8'),css=fs.readFileSync(path.join(root,'style.css'),'utf8'); | |
| assert.doesNotMatch(app,/new EventSource|fetch\(['"]api\//);assert.doesNotMatch(css,/@import|https?:\/\//); | |
| }); | |