Skip to content

Commit 01eadbd

Browse files
committed
Debug browser tests
1 parent 9ca4999 commit 01eadbd

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

packages/hub/src/utils/XetBlob.spec.ts

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ describe("XetBlob", () => {
7373
}
7474
).then((res) => res.arrayBuffer());
7575

76-
expect(new Uint8Array(xetDownload)).toEqual(new Uint8Array(bridgeDownload));
7776
expect(xetDownload.byteLength).toBe(29929);
77+
expect(new Uint8Array(xetDownload)).toEqual(new Uint8Array(bridgeDownload));
7878
expect(xorbCount).toBe(2);
7979
});
8080

@@ -112,32 +112,29 @@ describe("XetBlob", () => {
112112

113113
// In github actions, this test doesn't work inside the browser, but it works locally
114114
// inside both chrome and chromium browsers
115-
// TODO: figure out why
116-
if (typeof window === "undefined" && Math.random() === 10) {
117-
it("should load correctly when loading far into a chunk range", async () => {
118-
const blob = new XetBlob({
119-
repo: {
120-
type: "model",
121-
name: "celinah/xet-experiments",
115+
it("should load correctly when loading far into a chunk range", async () => {
116+
const blob = new XetBlob({
117+
repo: {
118+
type: "model",
119+
name: "celinah/xet-experiments",
120+
},
121+
hash: "7b3b6d07673a88cf467e67c1f7edef1a8c268cbf66e9dd9b0366322d4ab56d9b",
122+
size: 5_234_139_343,
123+
});
124+
125+
const xetDownload = await blob.slice(10_000_000, 10_100_000).arrayBuffer();
126+
const bridgeDownload = await fetch(
127+
"https://huggingface.co/celinah/xet-experiments/resolve/main/model5GB.safetensors",
128+
{
129+
headers: {
130+
Range: "bytes=10000000-10099999",
122131
},
123-
hash: "7b3b6d07673a88cf467e67c1f7edef1a8c268cbf66e9dd9b0366322d4ab56d9b",
124-
size: 5_234_139_343,
125-
});
126-
127-
const xetDownload = await blob.slice(10_000_000, 10_100_000).arrayBuffer();
128-
const bridgeDownload = await fetch(
129-
"https://huggingface.co/celinah/xet-experiments/resolve/main/model5GB.safetensors",
130-
{
131-
headers: {
132-
Range: "bytes=10000000-10099999",
133-
},
134-
}
135-
).then((res) => res.arrayBuffer());
132+
}
133+
).then((res) => res.arrayBuffer());
136134

137-
console.log("xet", xetDownload.byteLength, "bridge", bridgeDownload.byteLength);
138-
expect(new Uint8Array(xetDownload)).toEqual(new Uint8Array(bridgeDownload));
139-
}, 30_000);
140-
}
135+
console.log("xet", xetDownload.byteLength, "bridge", bridgeDownload.byteLength);
136+
expect(new Uint8Array(xetDownload)).toEqual(100_000);
137+
}, 30_000);
141138

142139
it("should load text correctly when offset_into_range starts in a chunk further than the first", async () => {
143140
const blob = new XetBlob({

packages/hub/src/utils/XetBlob.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ export class XetBlob extends Blob {
279279
const result = await reader.read();
280280
done = result.done;
281281

282+
console.log("read", result.value?.length, "bytes");
283+
282284
if (!result.value) {
283285
continue;
284286
}
@@ -362,8 +364,10 @@ export class XetBlob extends Blob {
362364
}
363365

364366
if (uncompressed.length) {
367+
console.log("yield", uncompressed.length, "bytes", result.value.length, "total read", totalBytesRead);
365368
totalBytesRead += uncompressed.length;
366369
yield stored ? uncompressed.slice() : uncompressed;
370+
console.log("yielded", uncompressed.length, "bytes", result.value.length, "total read", totalBytesRead);
367371
}
368372
}
369373

0 commit comments

Comments
 (0)