-
Notifications
You must be signed in to change notification settings - Fork 1
Optimize the commands #31
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,7 @@ use indicatif::{ProgressBar, ProgressStyle}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use crate::downloader::downloader::{DownloadError, Downloader}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use crate::downloader::progress::{DownloadProgressManager, FileProgress}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use crate::registry::model_registry::{ModelArchitecture, ModelInfo, ModelRegistry}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use crate::registry::model_registry::{ModelInfo, ModelRegistry, ModelSpec}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use crate::utils::file::{self, format_model_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Adapter to bridge HuggingFace's Progress trait with our FileProgress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -35,6 +35,60 @@ impl HuggingFaceDownloader { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub fn new() -> Self { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async fn fetch_metadata_from_api( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model_name: &str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Option<u64>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Option<u64>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let url = format!("https://huggingface.co/api/models/{}", model_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let client = reqwest::Client::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| match client.get(&url).send().await { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+49
to
+52
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let url = format!("https://huggingface.co/api/models/{}", model_name); | |
| let client = reqwest::Client::new(); | |
| match client.get(&url).send().await { | |
| let mut url = match reqwest::Url::parse("https://huggingface.co/") { | |
| Ok(url) => url, | |
| Err(_) => return (None, None, None, None, None, None), | |
| }; | |
| if let Ok(mut path_segments) = url.path_segments_mut() { | |
| path_segments.push("api"); | |
| path_segments.push("models"); | |
| path_segments.push(model_name); | |
| } else { | |
| return (None, None, None, None, None, None); | |
| } | |
| let client = reqwest::Client::new(); | |
| match client.get(url).send().await { |
Copilot
AI
Apr 24, 2026
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.
fetch_metadata_from_api uses a default reqwest::Client with no timeout and it ignores non-success HTTP statuses. This can cause pull to hang indefinitely on network stalls and silently treat 4xx/5xx responses as “no metadata”. Consider using Client::builder().timeout(...) (or per-request timeout) and calling response.error_for_status() before attempting to parse JSON, returning/logging an error when the API call fails.
Copilot
AI
Apr 24, 2026
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.
spec is always set to Some(ModelSpec { ... }) even when all fields are None, which will serialize into "spec": {} (since the inner fields are skipped). If the intent is “no metadata”, consider setting spec to None when all extracted fields are missing to avoid storing an empty object and to keep the registry format cleaner.
| let spec = Some(ModelSpec { | |
| author: author_from_api, | |
| task: task_from_api, | |
| license: license_from_api, | |
| model_type: model_type_from_api, | |
| parameters: parameters_from_api, | |
| context_window, | |
| }); | |
| let model_spec = ModelSpec { | |
| author: author_from_api, | |
| task: task_from_api, | |
| license: license_from_api, | |
| model_type: model_type_from_api, | |
| parameters: parameters_from_api, | |
| context_window, | |
| }; | |
| let spec = if model_spec.author.is_some() | |
| || model_spec.task.is_some() | |
| || model_spec.license.is_some() | |
| || model_spec.model_type.is_some() | |
| || model_spec.parameters.is_some() | |
| || model_spec.context_window.is_some() | |
| { | |
| Some(model_spec) | |
| } else { | |
| None | |
| }; |
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.
Context Windowis formatted withformat_parameters, which produces abbreviated K/M/B output (e.g., 2048 -> "2.05K"). Context window is a token count and should generally be shown as an exact integer (or with a dedicated formatter) to avoid confusing output.