-
Notifications
You must be signed in to change notification settings - Fork 296
Add missing match
on onnx/model.onnx
download
#472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Narsil
merged 4 commits into
huggingface:main
from
alvarobartt:add-missing-onnx-handling
Mar 26, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cf19a02
Add missing `match` on `onnx/model.onnx` download
alvarobartt bc17257
Merge branch 'main' into add-missing-onnx-handling
alvarobartt 855dc50
Fix handling of `download_onnx` function output
alvarobartt 297944a
Capture `model_files` and check if empty
alvarobartt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -338,10 +338,17 @@ async fn init_backend( | |
{ | ||
if let Some(api_repo) = api_repo.as_ref() { | ||
let start = std::time::Instant::now(); | ||
download_onnx(api_repo) | ||
let model_files = download_onnx(api_repo) | ||
.await | ||
.map_err(|err| BackendError::WeightsNotFound(err.to_string())); | ||
tracing::info!("Model ONNX weights downloaded in {:?}", start.elapsed()); | ||
.map_err(|err| BackendError::WeightsNotFound(err.to_string()))?; | ||
match model_files.is_empty() { | ||
true => { | ||
tracing::error!("Model ONNX files not found in the repository") | ||
} | ||
false => { | ||
tracing::info!("Model ONNX weights downloaded in {:?}", start.elapsed()) | ||
} | ||
} | ||
} | ||
|
||
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> { | |
Err(err) => { | ||
tracing::warn!("Could not download `model.onnx`: {err}"); | ||
tracing::info!("Downloading `onnx/model.onnx`"); | ||
let p = api.get("onnx/model.onnx").await?; | ||
model_files.push(p.parent().unwrap().to_path_buf()) | ||
|
||
match api.get("onnx/model.onnx").await { | ||
Ok(p) => model_files.push(p.parent().unwrap().to_path_buf()), | ||
Err(err) => tracing::warn!("Could not download `onnx/model.onnx`: {err}"), | ||
alvarobartt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
Comment on lines
-533
to
+544
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this virtually the same? How is the error handled in this fn? |
||
} | ||
}; | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't you only need to add a
?
after themap_err
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because it still succeeds as far as I remember the
download_onnx
function was not producing errors but just warnings so empty ONNX files was not considered an error and so on it was printing that the files where there while those really weren't + this doesn't need to fail as it needs to fallback to the Safetensors backend if the ONNX files are not there.Anyway I could've missed something, so please let me know!