Skip to content

Support inspect command#29

Merged
InftyAI-Agent merged 8 commits intoInftyAI:mainfrom
kerthcet:feat/add-inspect
Apr 23, 2026
Merged

Support inspect command#29
InftyAI-Agent merged 8 commits intoInftyAI:mainfrom
kerthcet:feat/add-inspect

Conversation

@kerthcet
Copy link
Copy Markdown
Member

@kerthcet kerthcet commented Apr 23, 2026

What this PR does / why we need it

Which issue(s) this PR fixes

xref: #6

puma inspect looks like:

Name: InftyAI/tiny-random-gpt2
Kind: Model
Spec:
  Model Type:     gpt2
  Parameters:     109.82K
  Context Window: 512
Registry:
  Provider:       huggingface
  Revision:       f938eb87a724ff5014e829c45c14a0248e4b3a22
  Size:           12.51 MB
  Modified:       5 minutes ago
  Cache Path:     /Users/kerthcet/.puma/cache/huggingface/models--InftyAI--tiny-random-gpt2

Special notes for your reviewer

Does this PR introduce a user-facing change?


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>
Copilot AI review requested due to automatic review settings April 23, 2026 23:07
@InftyAI-Agent InftyAI-Agent added needs-triage Indicates an issue or PR lacks a label and requires one. needs-priority Indicates a PR lacks a label and requires one. do-not-merge/needs-kind Indicates a PR lacks a label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 23, 2026
@kerthcet
Copy link
Copy Markdown
Member Author

/lgtm
/kind feature

@InftyAI-Agent InftyAI-Agent added lgtm Looks good to me, indicates that a PR is ready to be merged. feature Categorizes issue or PR as related to a new feature. and removed do-not-merge/needs-kind Indicates a PR lacks a label and requires one. labels Apr 23, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ModelInfo with optional spec metadata (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.

Comment on lines 186 to +196
// 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);
Comment on lines +87 to +89
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;
Comment on lines 66 to 91
@@ -81,6 +90,10 @@ impl Downloader for HuggingFaceDownloader {
}
})?;
Comment on lines +176 to +184
// 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
};
Comment on lines +203 to 230
// 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)))?;
}
Comment thread README.md
| `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>
@InftyAI-Agent InftyAI-Agent removed the lgtm Looks good to me, indicates that a PR is ready to be merged. label Apr 23, 2026
Signed-off-by: kerthcet <kerthcet@gmail.com>
Copilot AI review requested due to automatic review settings April 23, 2026 23:50
Signed-off-by: kerthcet <kerthcet@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 inspect CLI subcommand argument parsing and output rendering from the local model registry.
  • Persist optional model architecture metadata (model_type, classes, context window, estimated parameters) in models.json, extracted from Hugging Face config.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.

Comment on lines +203 to +205
// Register the model only if not totally cached
if !model_totally_cached {
// Extract architecture info from config.json
Comment on lines +176 to +177
// Give tasks a moment to start and create their progress bars
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
Comment thread src/cli/commands.rs
Comment on lines +190 to +194
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 {
Comment thread README.md
| `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` |
@kerthcet
Copy link
Copy Markdown
Member Author

/lgtm

@InftyAI-Agent InftyAI-Agent added the lgtm Looks good to me, indicates that a PR is ready to be merged. label Apr 23, 2026
@InftyAI-Agent InftyAI-Agent merged commit a0ebe7e into InftyAI:main Apr 23, 2026
12 checks passed
InftyAI-Agent pushed a commit that referenced this pull request Apr 24, 2026
* 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>
@kerthcet kerthcet deleted the feat/add-inspect branch April 24, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. feature Categorizes issue or PR as related to a new feature. lgtm Looks good to me, indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a label and requires one. needs-triage Indicates an issue or PR lacks a label and requires one.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants