Skip to content

Commit 2b6f854

Browse files
authored
Merge pull request #82 from devsapp/fix-model
fix: support syncStrategy
2 parents aaf320a + 85f1a83 commit 2b6f854

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

src/subCommands/model/index.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ mountPoints:
153153
role: modelConfig.role,
154154
nasMountPoint: nasMountDomain,
155155
vpcConfig,
156+
syncStrategy: process.env.MODEL_DOWNLOAD_STRATEGY || 'incremental_once',
156157
};
157158
try {
158159
const req = new devs.DownloadModelRequest(params);
@@ -178,11 +179,27 @@ mountPoints:
178179
const modelStatus = await this.getModelStatus(devClient, name);
179180

180181
if (modelStatus.finished) {
182+
if (!!modelStatus.total && modelStatus.currentBytes !== undefined && modelStatus.fileSize !== undefined) {
183+
const currentMB = (modelStatus.currentBytes / 1024 / 1024).toFixed(1);
184+
const totalMB = (modelStatus.fileSize / 1024 / 1024).toFixed(1);
185+
186+
const totalBars = 50;
187+
const progressBar = '='.repeat(totalBars);
188+
189+
process.stdout.write(
190+
`\r[Download-model] [${progressBar}] 100.00% (${currentMB}MB/${totalMB}MB)\n`
191+
);
192+
193+
} else {
194+
process.stdout.write('\n');
195+
}
181196
// 清除进度条并换行
182197
process.stdout.write('\n');
183-
const durationMs = modelStatus.finishedTime - modelStatus.startTime;
184-
const durationSeconds = Math.floor(durationMs / 1000);
185-
logger.info(`Time taken for model download: ${durationSeconds}s.`);
198+
if (!!modelStatus.total) {
199+
const durationMs = modelStatus.finishedTime - modelStatus.startTime;
200+
const durationSeconds = Math.floor(durationMs / 1000);
201+
logger.info(`Time taken for model download: ${durationSeconds}s.`);
202+
}
186203
logger.info(`[Download-model] Download model finished.`);
187204
return true;
188205
}
@@ -194,7 +211,7 @@ mountPoints:
194211

195212
// 每个等号代表2%,向下取整计算等号数量
196213
const totalBars = 50; // 总共50个字符位置
197-
const filledBars = Math.round(percentage / 2); // 每个等号代表2%
214+
const filledBars = Math.min(totalBars, Math.floor(percentage / 2)); // 每个等号代表2%
198215
const emptyBars = totalBars - filledBars;
199216

200217
const progressBar = '='.repeat(filledBars) + '.'.repeat(emptyBars);

0 commit comments

Comments
 (0)