Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/winml/modelkit/commands/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,13 @@ def inspect(
# Print a banner BEFORE the heavy import chain / network calls so users
# see immediate feedback instead of ~14 s of silence and assume the
# command hung (see #543). Banner + spinner go to stderr so `--format
# json` consumers still get clean stdout. Suppressed in --quiet mode.
# json` consumers still get clean stdout. Suppressed in --quiet mode
# and in JSON mode (Click 8.4 mixes stderr into CliRunner.result.output,
# and JSON consumers expect clean stdout regardless).
quiet = bool(ctx.obj and ctx.obj.get("quiet"))
json_mode = output_format.lower() == "json"
target = model_id or model_type or model_class
if not quiet:
if not quiet and not json_mode:
_stderr_console.print(f"[dim]Inspecting [bold]{target}[/bold] …[/dim]")

from ..inspect import InspectError, ModelNotFoundError, NetworkError
Expand All @@ -204,7 +207,7 @@ def inspect(
logging.getLogger("winml.modelkit").setLevel(logging.DEBUG)

try:
if quiet:
if quiet or json_mode:
result = _inspect_model_v2(
model_id=model_id,
task_override=task,
Expand Down Expand Up @@ -479,9 +482,20 @@ def _inspect_model_v2(
task=task,
)

# Use the top-level model_type for the user-facing result. For multimodal
# models (CLIP, etc.) `loader_config.model_type` is the narrowed sub-config
# type (e.g. "clip_text_model"), but users expect the top-level type ("clip").
#
# Precedence:
# 1. model_type_override — user explicitly passed --model-type
# 2. parent_hf_config — pre-narrowing config (only when model_id was
# provided and AutoConfig succeeded in step 1)
# 3. model_type — narrowed loader_config.model_type (fallback)
display_model_type = model_type_override or getattr(parent_hf_config, "model_type", model_type)

return InspectResult(
model_id=model_id or model_type or model_class_override or "unknown",
model_type=model_type,
model_id=model_id or display_model_type or model_class_override or "unknown",
model_type=display_model_type,
architectures=architectures,
task=task,
task_source=task_source,
Expand Down
Loading