Skip to content

Commit

Permalink
logic to deal with quantized file download
Browse files Browse the repository at this point in the history
  • Loading branch information
samlhuillier committed Feb 25, 2024
1 parent ced86f9 commit 0e322d4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions electron/main/download/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,32 @@ import * as path from "path";

export const DownloadModelFilesFromHFRepo = async (
repo: string,
// path: string,
saveDirectory: string
saveDirectory: string,
quantized = true
) => {
// List the files:
const fileList = await listFiles({
repo: repo,
// path: path,
recursive: true,
fetch: customFetch,
});

const files = [];
for await (const file of fileList) {
if (file.type === "file") {
files.push(file);
if (file.path.endsWith("onnx")) {
const isQuantizedFile = file.path.includes("quantized");
if (quantized === isQuantizedFile) {
files.push(file);
}
} else {
files.push(file);
}
}
}

console.log("files: ", files);

// Create an array of promises for each file download:
const downloadPromises = files.map((file) =>
downloadAndSaveFile(repo, file.path, path.join(saveDirectory, repo))
Expand Down

0 comments on commit 0e322d4

Please sign in to comment.