Skip to content

Commit 35fac69

Browse files
authored
Add missing match on onnx/model.onnx download (#472)
1 parent d8771f8 commit 35fac69

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

backends/src/lib.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,17 @@ async fn init_backend(
338338
{
339339
if let Some(api_repo) = api_repo.as_ref() {
340340
let start = std::time::Instant::now();
341-
download_onnx(api_repo)
341+
let model_files = download_onnx(api_repo)
342342
.await
343-
.map_err(|err| BackendError::WeightsNotFound(err.to_string()));
344-
tracing::info!("Model ONNX weights downloaded in {:?}", start.elapsed());
343+
.map_err(|err| BackendError::WeightsNotFound(err.to_string()))?;
344+
match model_files.is_empty() {
345+
true => {
346+
tracing::error!("Model ONNX files not found in the repository")
347+
}
348+
false => {
349+
tracing::info!("Model ONNX weights downloaded in {:?}", start.elapsed())
350+
}
351+
}
345352
}
346353

347354
let backend = OrtBackend::new(&model_path, dtype.to_string(), model_type.clone());
@@ -530,8 +537,11 @@ async fn download_onnx(api: &ApiRepo) -> Result<Vec<PathBuf>, ApiError> {
530537
Err(err) => {
531538
tracing::warn!("Could not download `model.onnx`: {err}");
532539
tracing::info!("Downloading `onnx/model.onnx`");
533-
let p = api.get("onnx/model.onnx").await?;
534-
model_files.push(p.parent().unwrap().to_path_buf())
540+
541+
match api.get("onnx/model.onnx").await {
542+
Ok(p) => model_files.push(p.parent().unwrap().to_path_buf()),
543+
Err(err) => tracing::warn!("Could not download `onnx/model.onnx`: {err}"),
544+
};
535545
}
536546
};
537547

0 commit comments

Comments
 (0)