Skip to content

Commit

Permalink
Apply suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed Mar 28, 2024
1 parent ab324d2 commit 9978225
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/tabby-common/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct ModelInfo {
#[serde(skip_serializing_if = "Option::is_none")]
pub urls: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub segmented_urls: Option<Vec<String>>,
pub partition_urls: Option<Vec<String>>,
pub sha256: String,
}

Expand Down
10 changes: 5 additions & 5 deletions crates/tabby-download/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn download_model_impl(
}
}

if !model_info.segmented_urls.is_none() {
if !model_info.partition_urls.is_none() {
return download_split_model(&model_info, &model_path).await;
}

Check warning on line 47 in crates/tabby-download/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/tabby-download/src/lib.rs#L44-L47

Added lines #L44 - L47 were not covered by tests
Expand All @@ -68,13 +68,13 @@ async fn download_model_impl(
async fn download_split_model(model_info: &ModelInfo, model_path: &Path) -> Result<()> {
if !model_info.urls.is_none() {
return Err(anyhow!(
"{}: Cannot specify both `urls` and `segmented_urls`",
"{}: Cannot specify both `urls` and `partition_urls`",
model_info.name
));
}
let mut paths = vec![];
let segmented_urls = model_info.segmented_urls.clone().unwrap_or_default();
for (index, url) in segmented_urls.iter().enumerate() {
let partition_urls = model_info.partition_urls.clone().unwrap_or_default();
for (index, url) in partition_urls.iter().enumerate() {
let ext = format!(
"{}.{}",
model_path.extension().unwrap_or_default().to_string_lossy(),
Expand All @@ -84,7 +84,7 @@ async fn download_split_model(model_info: &ModelInfo, model_path: &Path) -> Resu
info!(
"Downloading {path:?} ({index} / {total})",
index = index + 1,
total = segmented_urls.len()
total = partition_urls.len()
);
let strategy = ExponentialBackoff::from_millis(100).map(jitter).take(2);
let download_job = Retry::spawn(strategy, || download_file(url, &path));
Expand Down

0 comments on commit 9978225

Please sign in to comment.