File size: 1,661 Bytes
21dd449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { assert, it, describe } from "vitest";
import { fileDownloadInfo } from "./file-download-info";

describe("fileDownloadInfo", () => {
	it("should fetch LFS file info", async () => {
		const info = await fileDownloadInfo({
			repo: {
				name: "bert-base-uncased",
				type: "model",
			},
			path: "tf_model.h5",
			revision: "dd4bc8b21efa05ec961e3efc4ee5e3832a3679c7",
		});

		assert.strictEqual(info?.size, 536063208);
		assert.strictEqual(info?.etag, '"a7a17d6d844b5de815ccab5f42cad6d24496db3850a2a43d8258221018ce87d2"');
	});

	it("should fetch raw LFS pointer info", async () => {
		const info = await fileDownloadInfo({
			repo: {
				name: "bert-base-uncased",
				type: "model",
			},
			path: "tf_model.h5",
			revision: "dd4bc8b21efa05ec961e3efc4ee5e3832a3679c7",
			raw: true,
		});

		assert.strictEqual(info?.size, 134);
		assert.strictEqual(info?.etag, '"9eb98c817f04b051b3bcca591bcd4e03cec88018"');
	});

	it("should fetch non-LFS file info", async () => {
		const info = await fileDownloadInfo({
			repo: {
				name: "bert-base-uncased",
				type: "model",
			},
			path: "tokenizer_config.json",
			revision: "1a7dd4986e3dab699c24ca19b2afd0f5e1a80f37",
		});

		assert.strictEqual(info?.size, 28);
		assert.strictEqual(info?.etag, '"a661b1a138dac6dc5590367402d100765010ffd6"');
	});

	it("should fetch xet file info", async () => {
		const info = await fileDownloadInfo({
			repo: {
				type: "model",
				name: "celinah/xet-experiments",
			},
			path: "large_text.txt",
		});
		assert.strictEqual(info?.size, 62914580);
		assert.strictEqual(info?.etag, '"c27f98578d9363b27db0bc1cbd9c692f8e6e90ae98c38cee7bc0a88829debd17"');
	});
});