Skip to content

feat: support inspect the model artifact from remote registry#189

Merged
chlins merged 1 commit into
mainfrom
feat/inspect-remote
May 28, 2025
Merged

feat: support inspect the model artifact from remote registry#189
chlins merged 1 commit into
mainfrom
feat/inspect-remote

Conversation

@chlins

@chlins chlins commented May 27, 2025

Copy link
Copy Markdown
Member

This pull request introduces enhancements to the inspect command and refactors related backend methods to improve configurability and maintainability. Key changes include adding a new Inspect configuration struct, updating the inspect command to support additional flags, and refactoring backend methods to use explicit parameters instead of configuration structs.

Enhancements to the inspect command:

  • Added a new Inspect configuration struct in pkg/config/inspect.go to handle options like Remote, PlainHTTP, and Insecure. A helper function NewInspect initializes this struct with default values.
  • Updated cmd/inspect.go to include new flags (--remote, --plain-http, --insecure) for the inspect command, binding them to the Inspect configuration struct. [1] [2]

Refactoring backend methods:

  • Modified the Inspect method in pkg/backend/backend.go to accept the new Inspect configuration struct as a parameter. Updated its implementation in pkg/backend/inspect.go to utilize the new configuration struct for handling remote and secure connections. [1] [2]
  • Refactored getManifest and getModelConfig methods in pkg/backend/attach.go to replace the Attach configuration struct with explicit parameters for Remote, PlainHTTP, and Insecure. This improves clarity and reduces dependency on configuration structs. [1] [2]

Updates to tests:

  • Updated test cases in pkg/backend/attach_test.go and pkg/backend/inspect_test.go to reflect the new method signatures and configuration struct usage. [1] [2]

Summary by CodeRabbit

  • New Features
    • Added new options to the inspect command: inspect artifacts from a remote registry, use plain HTTP, and allow insecure connections.
  • Bug Fixes
    • Corrected flag registration for the inspect command to ensure proper behavior.
  • Refactor
    • Updated internal handling of configuration options for inspecting and attaching model artifacts to improve clarity and flexibility.
  • Tests
    • Adjusted tests to align with updated configuration handling.

@coderabbitai

coderabbitai Bot commented May 27, 2025

Copy link
Copy Markdown

Walkthrough

The changes introduce a new Inspect configuration struct to manage inspection-related flags and refactor the backend inspection logic to accept this configuration. Boolean flags for remote inspection, HTTP usage, and insecure connections are now managed through this struct. Related backend methods and tests are updated to pass explicit configuration parameters, and a new config file is added.

Changes

File(s) Change Summary
cmd/inspect.go, pkg/config/inspect.go Added Inspect config struct, initialized and integrated new flags for inspection options.
pkg/backend/backend.go, pkg/backend/inspect.go Refactored Inspect method signatures to accept *config.Inspect; updated logic to use new config.
pkg/backend/attach.go Refactored helper method signatures to accept explicit boolean flags instead of config struct.
pkg/backend/attach_test.go, pkg/backend/inspect_test.go Updated tests to pass new config parameters or struct to backend methods.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Backend
    participant Config

    User->>CLI: Run inspect command with flags
    CLI->>Config: Parse flags into Inspect config
    CLI->>Backend: Call Inspect(ctx, target, inspectConfig)
    Backend->>Backend: Use config to determine remote/local/secure fetch
    Backend->>Backend: Fetch manifest and model config accordingly
    Backend-->>CLI: Return InspectedModelArtifact
    CLI-->>User: Output inspection result
Loading

Poem

In the warren of code, a new path we select,
With config in paw, inspect we perfect.
Remote or secure, now flags guide the way,
Through fields and through tunnels, the backend will say:
“Hop forth with your options, inspect what you seek—
The carrots of knowledge are never so bleak!”
🥕

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18e3736 and a8ef9c9.

📒 Files selected for processing (7)
  • cmd/inspect.go (3 hunks)
  • pkg/backend/attach.go (7 hunks)
  • pkg/backend/attach_test.go (1 hunks)
  • pkg/backend/backend.go (1 hunks)
  • pkg/backend/inspect.go (2 hunks)
  • pkg/backend/inspect_test.go (2 hunks)
  • pkg/config/inspect.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • pkg/backend/backend.go
  • pkg/config/inspect.go
  • cmd/inspect.go
  • pkg/backend/inspect.go
  • pkg/backend/attach_test.go
  • pkg/backend/inspect_test.go
  • pkg/backend/attach.go
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Lint
  • GitHub Check: Analyze (go)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@chlins chlins added the enhancement New feature or request label May 27, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
pkg/config/inspect.go (1)

25-31: Simplify the constructor function.

The constructor function works correctly, but it can be simplified since Go's zero values for booleans are already false.

 func NewInspect() *Inspect {
-	return &Inspect{
-		Remote:    false,
-		PlainHTTP: false,
-		Insecure:  false,
-	}
+	return &Inspect{}
 }

Alternatively, you could consider whether the constructor function is needed at all, since &config.Inspect{} provides the same result and is more idiomatic in Go.

cmd/inspect.go (1)

54-54: Fix error message to match command context.

The error message mentions "cache inspect flags" which appears to be a copy-paste error from another command.

-		panic(fmt.Errorf("bind cache inspect flags to viper: %w", err))
+		panic(fmt.Errorf("bind inspect flags to viper: %w", err))
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb286b8 and 18e3736.

📒 Files selected for processing (7)
  • cmd/inspect.go (3 hunks)
  • pkg/backend/attach.go (7 hunks)
  • pkg/backend/attach_test.go (1 hunks)
  • pkg/backend/backend.go (1 hunks)
  • pkg/backend/inspect.go (2 hunks)
  • pkg/backend/inspect_test.go (2 hunks)
  • pkg/config/inspect.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
pkg/backend/inspect.go (2)
pkg/config/inspect.go (1)
  • Inspect (19-23)
pkg/backend/referencer.go (1)
  • ParseReference (36-43)
pkg/backend/inspect_test.go (1)
pkg/config/inspect.go (1)
  • Inspect (19-23)
pkg/backend/attach_test.go (1)
pkg/config/attach.go (1)
  • Attach (21-29)
pkg/backend/backend.go (2)
pkg/config/inspect.go (1)
  • Inspect (19-23)
pkg/backend/inspect.go (1)
  • InspectedModelArtifact (32-55)
cmd/inspect.go (1)
pkg/config/inspect.go (2)
  • NewInspect (25-31)
  • Inspect (19-23)
🪛 GitHub Actions: CI
pkg/backend/inspect_test.go

[error] 137-137: TestInspect failed: expected digest 'sha256:2bc8836f5910ec63a01109e20db67c2ad7706cb19bef5a303bc86fa5572ec9a2' but got 'sha256:9ca701e8784e5656e2c36f10f82410a0af4c44f859590a28a3d1519ee1eea89d'.

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Lint
  • GitHub Check: Analyze (go)
🔇 Additional comments (21)
pkg/backend/inspect_test.go (1)

26-27: LGTM - Import changes align with new interface.

The import reordering and addition of the pkgconfig import correctly supports the new Inspect configuration struct usage.

pkg/backend/backend.go (1)

59-59: LGTM - Interface signature correctly updated for new functionality.

The addition of the cfg *config.Inspect parameter properly extends the interface to support the new remote inspection capabilities. The signature change is consistent with other methods in the interface that accept configuration structs.

pkg/backend/attach_test.go (2)

47-47: LGTM - Test correctly adapted to refactored method signature.

The change from passing the entire config struct to individual boolean parameters improves clarity and aligns with the refactoring mentioned in the PR objectives.


55-55: LGTM - Consistent parameter passing for error case.

The error test case is correctly updated to use the same individual parameter approach, maintaining consistency with the successful test case.

pkg/config/inspect.go (1)

19-23: LGTM - Well-designed configuration struct.

The Inspect struct clearly defines the three configuration options for remote inspection functionality. The field names are descriptive and follow Go naming conventions.

pkg/backend/inspect.go (5)

68-68: LGTM: Method signature updated correctly.

The addition of the cfg *config.Inspect parameter aligns with the PR objective to support configurable inspection behavior for remote registries.


74-77: LGTM: Configuration parameters passed correctly.

The call to getManifest now correctly passes the configuration flags (cfg.Remote, cfg.PlainHTTP, cfg.Insecure) as explicit boolean parameters, which is consistent with the refactored method signature in attach.go.


79-82: LGTM: Manifest marshaling for digest calculation.

The addition of manifest marshaling is necessary for the new digest calculation approach. The error handling is appropriate.


84-87: LGTM: Configuration parameters passed correctly.

The call to getModelConfig correctly passes the configuration flags as explicit boolean parameters, maintaining consistency with the refactored method signatures.


91-91: LGTM: Improved digest calculation for remote inspection.

The change from store-based digest retrieval to computing the digest from marshaled manifest bytes is more appropriate for remote inspection scenarios where local storage may not be available. This ensures consistent digest calculation regardless of the inspection source.

cmd/inspect.go (3)

31-31: LGTM: Configuration initialization.

The inspectConfig variable is properly initialized using the constructor function from the config package.


48-52: LGTM: Flag definitions are correct.

The new flags are properly defined and bound to the correct configuration fields. The flag names and descriptions clearly convey their purpose for remote inspection capabilities.


69-69: LGTM: Configuration passed to backend method.

The inspectConfig is correctly passed to the backend's Inspect method, enabling the new remote inspection functionality.

pkg/backend/attach.go (8)

61-64: LGTM: Updated method call with explicit parameters.

The call to getManifest correctly passes the explicit boolean parameters from the Attach configuration, maintaining the same functionality with improved clarity.


66-69: LGTM: Updated method call with explicit parameters.

The call to getModelConfig correctly passes the explicit boolean parameters from the Attach configuration, consistent with the refactoring approach.


172-172: LGTM: Method signature refactored for explicit parameters.

The getManifest method signature now accepts explicit boolean parameters (fromRemote, plainHTTP, insecure) instead of a config struct, improving API clarity and reducing coupling.


184-184: LGTM: Conditional logic using explicit parameter.

The conditional check now uses the explicit fromRemote parameter, maintaining the same logic with improved readability.


198-198: LGTM: Remote client creation with explicit parameters.

The remote client is created using the explicit plainHTTP and insecure parameters, maintaining consistency with the refactored method signature.


217-217: LGTM: Method signature refactored for explicit parameters.

The getModelConfig method signature now accepts explicit boolean parameters, consistent with the getManifest refactoring approach.


229-229: LGTM: Conditional logic using explicit parameter.

The conditional check correctly uses the explicit fromRemote parameter, maintaining consistent logic flow.


244-244: LGTM: Remote client creation with explicit parameters.

The remote client creation uses the explicit boolean parameters, maintaining consistency with the refactored approach throughout the file.

Comment thread pkg/backend/inspect_test.go
Signed-off-by: chlins <chlins.zhang@gmail.com>
@chlins chlins force-pushed the feat/inspect-remote branch from 18e3736 to a8ef9c9 Compare May 28, 2025 02:50

@gaius-qi gaius-qi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@chlins chlins merged commit 8534718 into main May 28, 2025
6 checks passed
@chlins chlins deleted the feat/inspect-remote branch May 28, 2025 05:56
SAY-5 added a commit to SAY-5/modctl that referenced this pull request May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants