Conversation
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
|
/lgtm |
There was a problem hiding this comment.
Pull request overview
Adds initial support for the inspect CLI command by extending the model registry to store/display additional model metadata extracted from Hugging Face config.json.
Changes:
- Add
format_parameters()utility + unit tests for human-readable parameter counts. - Extend
ModelInfowith optionalspecmetadata (ModelSpec) and add tests for spec extraction/registry roundtrips. - Implement
puma inspect <model>output and enhance Hugging Face pull UX with spinners/progress display tweaks.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/format.rs | Adds format_parameters() and tests. |
| src/system/system_info.rs | Removes an extra blank line in display output. |
| src/registry/model_registry.rs | Introduces ModelSpec, persists it under ModelInfo.spec, and adds related tests. |
| src/downloader/progress.rs | Adds a helper to create a spinner progress bar. |
| src/downloader/huggingface.rs | Adds manifest/download spinners, prefixes progress messages, and records ModelSpec during registration. |
| src/cli/commands.rs | Implements inspect args + output; adjusts table formatting. |
| README.md | Marks inspect as implemented in the command table. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Wait for all downloads to complete | ||
| for task in tasks { | ||
| task.await | ||
| .map_err(|e| DownloadError::ApiError(format!("Task join error: {}", e)))??; | ||
| } | ||
|
|
||
| // Finish spinner after downloads complete | ||
| if let Some(spinner) = &spinner { | ||
| spinner.finish_and_clear(); | ||
| } | ||
|
|
| .or_else(|| config.get("max_position_embeddings")) | ||
| .or_else(|| config.get("n_ctx")) | ||
| .and_then(|v| v.as_u64()) | ||
| .map(|v| v as u32); |
| let layer_params = 12 * n_layer * n_embd * n_embd; | ||
| let embedding_params = vocab_size * n_embd + n_positions * n_embd; | ||
| let total_params = layer_params + embedding_params; |
| @@ -81,6 +90,10 @@ impl Downloader for HuggingFaceDownloader { | |||
| } | |||
| })?; | |||
| // Give tasks a moment to start and create their progress bars | ||
| tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; | ||
|
|
||
| // Show spinner at the bottom after all progress bars are created (only if not fully cached) | ||
| let spinner = if !model_totally_cached { | ||
| Some(progress_manager.create_spinner()) | ||
| } else { | ||
| None | ||
| }; |
| // Register the model only if not totally cached | ||
| if !model_totally_cached { | ||
| // Extract architecture info from config.json | ||
| let config_path = snapshot_path.join("config.json"); | ||
| let spec = if config_path.exists() { | ||
| std::fs::read_to_string(&config_path) | ||
| .ok() | ||
| .and_then(|content| serde_json::from_str::<serde_json::Value>(&content).ok()) | ||
| .and_then(|config| ModelSpec::from_config(&config)) | ||
| } else { | ||
| None | ||
| }; | ||
|
|
||
| let model_info_record = ModelInfo { | ||
| name: name.to_string(), | ||
| provider: "huggingface".to_string(), | ||
| revision: sha, | ||
| size: downloaded_size, | ||
| modified_at: chrono::Local::now().to_rfc3339(), | ||
| cache_path: model_cache_path.to_string_lossy().to_string(), | ||
| spec, | ||
| }; | ||
|
|
||
| let registry = ModelRegistry::new(None); | ||
| registry | ||
| .register_model(model_info_record) | ||
| .map_err(|e| DownloadError::ApiError(format!("Failed to register model: {}", e)))?; | ||
| } |
| | `rm` | ✅ | Remove a model | `puma rm InftyAI/tiny-random-gpt2` | | ||
| | `info` | ✅ | Display system-wide information | `puma info` | | ||
| | `inspect` | 🚧 | Return detailed information about a model or service | `puma inspect InftyAI/tiny-random-gpt2` | | ||
| | `inspect` | ✅ | Return detailed information about a model or service | `puma inspect InftyAI/tiny-random-gpt2` | |
Signed-off-by: kerthcet <kerthcet@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds initial support for puma inspect <model> by persisting model “architecture/spec” metadata in the registry and printing it in the CLI, alongside some download-progress UX tweaks.
Changes:
- Add
inspectCLI subcommand argument parsing and output rendering from the local model registry. - Persist optional model architecture metadata (
model_type, classes, context window, estimated parameters) inmodels.json, extracted from Hugging Faceconfig.json. - Improve Hugging Face download progress output (manifest spinner, prefixed “pulling …”, optional spinner).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/utils/format.rs |
Adds format_parameters() + tests for human-readable parameter counts. |
src/system/system_info.rs |
Removes an extra blank line before “PUMA Information”. |
src/registry/model_registry.rs |
Adds ModelArchitecture, stores arch on ModelInfo, and adds tests for config extraction / inspection via registry. |
src/downloader/progress.rs |
Adds a create_spinner() helper on the progress manager. |
src/downloader/huggingface.rs |
Enhances progress UI and extracts/records model architecture from config.json on download. |
src/cli/commands.rs |
Implements puma inspect <model> and adjusts prettytable formatting for ps/ls. |
README.md |
Marks inspect as supported in the commands table. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Register the model only if not totally cached | ||
| if !model_totally_cached { | ||
| // Extract architecture info from config.json |
| // Give tasks a moment to start and create their progress bars | ||
| tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; |
| println!("Spec:"); | ||
| // Architecture section (only if info is available) | ||
| if let Some(arch) = &model.arch { | ||
| println!(" Architecture:"); | ||
| if let Some(model_type) = &arch.model_type { |
| | `rm` | ✅ | Remove a model | `puma rm InftyAI/tiny-random-gpt2` | | ||
| | `info` | ✅ | Display system-wide information | `puma info` | | ||
| | `inspect` | 🚧 | Return detailed information about a model or service | `puma inspect InftyAI/tiny-random-gpt2` | | ||
| | `inspect` | ✅ | Return detailed information about a model or service | `puma inspect InftyAI/tiny-random-gpt2` | |
|
/lgtm |
* Support HF downloading models (#16) * Add HF downloader support Signed-off-by: kerthcet <kerthcet@gmail.com> * add bars Signed-off-by: kerthcet <kerthcet@gmail.com> * fix color Signed-off-by: kerthcet <kerthcet@gmail.com> * fix color Signed-off-by: kerthcet <kerthcet@gmail.com> * add download successfully message Signed-off-by: kerthcet <kerthcet@gmail.com> * change the color Signed-off-by: kerthcet <kerthcet@gmail.com> * change the rending shape Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com> * Support `puma rm <model>` (#17) * support new cache structure Signed-off-by: kerthcet <kerthcet@gmail.com> * support puma rm Signed-off-by: kerthcet <kerthcet@gmail.com> * use readable format Signed-off-by: kerthcet <kerthcet@gmail.com> * remove requests.rs Signed-off-by: kerthcet <kerthcet@gmail.com> * fix lint Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com> * support puma info (#18) Signed-off-by: kerthcet <kerthcet@gmail.com> * Reuse the model cache to avoid duplicate download (#19) * polish the format of the ls command Signed-off-by: kerthcet <kerthcet@gmail.com> * Have a progress manager Signed-off-by: kerthcet <kerthcet@gmail.com> * Reuse caches Signed-off-by: kerthcet <kerthcet@gmail.com> * rename util to utils Signed-off-by: kerthcet <kerthcet@gmail.com> * polish the layout of the download progress Signed-off-by: kerthcet <kerthcet@gmail.com> * revert change Signed-off-by: kerthcet <kerthcet@gmail.com> * add make format Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com> * remove available mem (#22) Signed-off-by: kerthcet <kerthcet@gmail.com> * add speed at the end (#23) * add speed at the end Signed-off-by: kerthcet <kerthcet@gmail.com> * fix lint Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com> * fix: do no register model once cached (#26) Signed-off-by: kerthcet <kerthcet@gmail.com> * Support GPU detect (#27) * support GPU detect Signed-off-by: kerthcet <kerthcet@gmail.com> * fix lint Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com> * update readme.md (#28) Signed-off-by: kerthcet <kerthcet@gmail.com> * Support inspect command (#29) * add support for inspect Signed-off-by: kerthcet <kerthcet@gmail.com> * add support for inspect Signed-off-by: kerthcet <kerthcet@gmail.com> * add pull progress bar Signed-off-by: kerthcet <kerthcet@gmail.com> * polish the download progress Signed-off-by: kerthcet <kerthcet@gmail.com> * reorganize the structure Signed-off-by: kerthcet <kerthcet@gmail.com> * optimize the structure Signed-off-by: kerthcet <kerthcet@gmail.com> * fix test Signed-off-by: kerthcet <kerthcet@gmail.com> * fix lint Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com> * add metadata Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com>
What this PR does / why we need it
Which issue(s) this PR fixes
xref: #6
puma inspect looks like:
Special notes for your reviewer
Does this PR introduce a user-facing change?