Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions cmd/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ var attachConfig = config.NewAttach()

// attachCmd represents the modctl command for attach.
var attachCmd = &cobra.Command{
Use: "attach [flags] <file>",
Short: "Attach the file to an existing model artifact.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "attach [flags] <file>",
Short: "Attach the file to an existing model artifact.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if err := attachConfig.Validate(); err != nil {
return err
Expand Down
11 changes: 5 additions & 6 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ var buildConfig = config.NewBuild()

// buildCmd represents the modctl command for build.
var buildCmd = &cobra.Command{
Use: "build [flags] <path>",
Short: "Build the model artifact with the context by specified path.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "build [flags] <path>",
Short: "Build the model artifact with the context by specified path.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if err := buildConfig.Validate(); err != nil {
return err
Expand Down
11 changes: 5 additions & 6 deletions cmd/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ var extractConfig = config.NewExtract()

// extractCmd represents the modctl command for extract.
var extractCmd = &cobra.Command{
Use: "extract <target> --output <output>",
Short: "Extract the model artifact to the output path, which can restore the initial state of the model files.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "extract <target> --output <output>",
Short: "Extract the model artifact to the output path, which can restore the initial state of the model files.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if err := extractConfig.Validate(); err != nil {
return err
Expand Down
11 changes: 5 additions & 6 deletions cmd/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ var fetchConfig = config.NewFetch()

// fetchCmd represents the modctl command for fetch.
var fetchCmd = &cobra.Command{
Use: "fetch [flags] <target>",
Short: "Fetch can retrieve files from the remote model repository, enabling selective download of partial model files by filtering based on file path patterns.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "fetch [flags] <target>",
Short: "Fetch can retrieve files from the remote model repository, enabling selective download of partial model files by filtering based on file path patterns.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if err := fetchConfig.Validate(); err != nil {
return err
Expand Down
11 changes: 5 additions & 6 deletions cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ var inspectConfig = config.NewInspect()

// inspectCmd represents the modctl command for inspect.
var inspectCmd = &cobra.Command{
Use: "inspect [flags] <target>",
Short: "Inspect can help to analyze the composition of model artifact.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "inspect [flags] <target>",
Short: "Inspect can help to analyze the composition of model artifact.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runInspect(context.Background(), args[0])
},
Expand Down
11 changes: 5 additions & 6 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ import (

// listCmd represents the modctl command for list.
var listCmd = &cobra.Command{
Use: "ls",
Short: "List will lists the current built model artifacts from local storage.",
Args: cobra.NoArgs,
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "ls",
Short: "List will lists the current built model artifacts from local storage.",
Args: cobra.NoArgs,
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runList(context.Background())
},
Expand Down
7 changes: 3 additions & 4 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ modctl login -u foo registry-1.docker.io
# login to registry served over http:
modctl login -u foo --plain-http registry-insecure.io
`,
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if err := loginConfig.Validate(); err != nil {
return err
Expand Down
11 changes: 5 additions & 6 deletions cmd/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ import (

// logoutCmd represents the modctl command for logout.
var logoutCmd = &cobra.Command{
Use: "logout [flags]",
Short: "Logout from a registry.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "logout [flags]",
Short: "Logout from a registry.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runLogout(context.Background(), args[0])
},
Expand Down
7 changes: 3 additions & 4 deletions cmd/modelfile/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ Full URLs with domain names will auto-detect the provider.`,

# Generate with metadata overrides
modctl modelfile generate ./my-model-dir --name my-custom-model --family llama3`,
Args: cobra.MaximumNArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Args: cobra.MaximumNArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
// If model-url is provided, path is optional
workspace := "."
Expand Down
11 changes: 5 additions & 6 deletions cmd/modelfile/modelfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ import (

// RootCmd represents the modelfile tools command for modelfile operation.
var RootCmd = &cobra.Command{
Use: "modelfile",
Short: "A command line tool for modelfile operation",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "modelfile",
Short: "A command line tool for modelfile operation",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
Comment on lines +28 to 33

Choose a reason for hiding this comment

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

medium

The modelfile command acts as a command group for subcommands like generate. As such, it shouldn't have its own execution logic or argument requirements that could lead to confusing behavior. Currently, modctl modelfile foo is a valid command that does nothing, which is likely not the intended behavior.

To make this behave like a standard command group, I suggest removing the Args and RunE fields. This way, if modctl modelfile is run without a subcommand, cobra will automatically print the help message, which is more user-friendly.

Suggested change
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
DisableAutoGenTag: true,
SilenceUsage: true

Expand Down
11 changes: 5 additions & 6 deletions cmd/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ var pruneConfig = config.NewPrune()

// pruneCmd represents the modctl command for prune.
var pruneCmd = &cobra.Command{
Use: "prune [flags]",
Short: "Prune can help to cleanup useless manifests and blobs in the local storage.",
Args: cobra.NoArgs,
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "prune [flags]",
Short: "Prune can help to cleanup useless manifests and blobs in the local storage.",
Args: cobra.NoArgs,
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runPrune(context.Background())
},
Expand Down
11 changes: 5 additions & 6 deletions cmd/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ var pullConfig = config.NewPull()

// pullCmd represents the modctl command for pull.
var pullCmd = &cobra.Command{
Use: "pull [flags] <target>",
Short: "Pull a model artifact from the remote registry.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "pull [flags] <target>",
Short: "Pull a model artifact from the remote registry.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if err := pullConfig.Validate(); err != nil {
return err
Expand Down
11 changes: 5 additions & 6 deletions cmd/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ var pushConfig = config.NewPush()

// pushCmd represents the modctl command for push.
var pushCmd = &cobra.Command{
Use: "push [flags] <target>",
Short: "Push a model artifact to the remote registry.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "push [flags] <target>",
Short: "Push a model artifact to the remote registry.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if err := pushConfig.Validate(); err != nil {
return err
Expand Down
11 changes: 5 additions & 6 deletions cmd/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ import (

// rmCmd represents the modctl command for rm.
var rmCmd = &cobra.Command{
Use: "rm [flags] <target>",
Short: "Remove a model artifact from the local storage.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "rm [flags] <target>",
Short: "Remove a model artifact from the local storage.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runRm(context.Background(), args[0])
},
Expand Down
11 changes: 5 additions & 6 deletions cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ import (

// tagCmd represents the modctl command for tag.
var tagCmd = &cobra.Command{
Use: "tag [flags] <source> <target>",
Short: "Tag can tag one model artifact to another one without rebuilding.",
Args: cobra.ExactArgs(2),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "tag [flags] <source> <target>",
Short: "Tag can tag one model artifact to another one without rebuilding.",
Args: cobra.ExactArgs(2),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runTag(context.Background(), args[0], args[1])
},
Expand Down
11 changes: 5 additions & 6 deletions cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ var uploadConfig = config.NewUpload()

// uploadCmd represents the modctl command for upload.
var uploadCmd = &cobra.Command{
Use: "upload [flags] <file>",
Short: "Upload a file to the remote end in advance to save time in the later build, applicable to the scenario of uploading while downloading, this function needs to be used together with build.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "upload [flags] <file>",
Short: "Upload a file to the remote end in advance to save time in the later build, applicable to the scenario of uploading while downloading, this function needs to be used together with build.",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if err := uploadConfig.Validate(); err != nil {
return err
Expand Down
9 changes: 4 additions & 5 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ import (

// versionCmd represents the modctl command for version.
var versionCmd = &cobra.Command{
Use: "version",
Short: "A command line tool for modctl version",
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
Use: "version",
Short: "A command line tool for modctl version",

Choose a reason for hiding this comment

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

medium

The version command does not use any arguments. To prevent users from providing arguments that are silently ignored, it's a good practice to explicitly disallow them by setting Args: cobra.NoArgs.

Suggested change
Short: "A command line tool for modctl version",
Short: "A command line tool for modctl version",
Args: cobra.NoArgs,

DisableAutoGenTag: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runVersion()
},
Expand Down
Loading