Skip to content

feat: support raw format for attach command#209

Merged
chlins merged 1 commit intomainfrom
feat/attach-raw
Jun 19, 2025
Merged

feat: support raw format for attach command#209
chlins merged 1 commit intomainfrom
feat/attach-raw

Conversation

@chlins
Copy link
Member

@chlins chlins commented Jun 19, 2025

This pull request introduces a new feature to support attaching model artifact layers in raw format and includes several related updates across the codebase. Key changes include adding a Raw flag to the configuration, modifying the processor logic to handle the raw format, and updating tests and dependencies accordingly.

New Feature: Support for Raw Format

  • Added a Raw flag to the Attach struct in pkg/config/attach.go and initialized it in the NewAttach function. This flag enables attaching model artifact layers in raw format. [1] [2]
  • Updated the cmd/attach.go file to include the Raw flag in the CLI options.

Processor Logic Enhancements

  • Modified the getProcessor function in pkg/backend/attach.go to use the Raw flag to determine the appropriate media type for different file types. Added support for raw formats in model config, model weight, model code, and model doc processors.
  • Updated the Attach method to pass the cfg parameter to getProcessor and replaced manual slice manipulation with the slices.Delete function for improved readability and safety.

Dependency and Test Updates

  • Added the slices package to the imports in pkg/backend/attach.go to utilize the slices.Delete function.
  • Updated the test case in pkg/backend/attach_test.go to pass the cfg parameter to the getProcessor function.

Minor Adjustments

  • Increased the refresh rate of the progress bar in internal/pb/pb.go from 200ms to 300ms for smoother updates.

Signed-off-by: chlins <chlins.zhang@gmail.com>
@chlins chlins added the enhancement New feature or request label Jun 19, 2025
@chlins chlins requested a review from Copilot June 19, 2025 06:44
Copy link

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

This PR introduces a new Raw flag to the attach command, enabling the use of “raw” media types when attaching model artifact layers, and makes related updates across the codebase.

  • Add Raw boolean to Attach config and wire it through the CLI
  • Extend getProcessor to pick raw media types and replace manual slice removal with slices.Delete
  • Update tests and bump progress bar refresh rate for smoother updates

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/config/attach.go Added Raw field to Attach struct and initialized it in NewAttach
cmd/attach.go Exposed --raw flag in the attach command
pkg/backend/attach.go Updated getProcessor signature to accept Raw, select raw media types, and use slices.Delete
pkg/backend/attach_test.go Updated test call to getProcessor to include *config.Attach
internal/pb/pb.go Increased progress bar refresh rate from 200ms to 300ms
Comments suppressed due to low confidence (1)

pkg/backend/attach_test.go:76

  • Tests currently only cover the default (Raw=false) path. Add a test case where &config.Attach{Raw: true} is passed to verify that the processor uses the raw media types.
			proc := b.getProcessor(tt.filepath, &config.Attach{})

Copy link
Member

@gaius-qi gaius-qi left a comment

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 1bd9957 into main Jun 19, 2025
4 checks passed
@chlins chlins deleted the feat/attach-raw branch June 19, 2025 08:04
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.

3 participants