Skip to content
Merged
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
4 changes: 3 additions & 1 deletion cmd/cli/commands/bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"sync"
"time"

"github.com/docker/model-runner/cmd/cli/commands/completion"
"github.com/docker/model-runner/cmd/cli/desktop"
"github.com/docker/model-runner/pkg/inference"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -63,7 +64,8 @@ func newBenchCmd() *cobra.Command {

This command runs a series of benchmarks with 1, 2, 4, and 8 concurrent requests by default,
measuring the tokens per second (TPS) that the model can generate.`,
Args: cobra.ExactArgs(1),
Args: requireExactArgs(1, "bench", "MODEL"),
ValidArgsFunction: completion.ModelNames(getDesktopClient, 1),
RunE: func(cmd *cobra.Command, args []string) error {
model = args[0]

Expand Down
8 changes: 6 additions & 2 deletions cmd/cli/commands/completion/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ func ModelNames(desktopClient func() *desktop.Client, limit int) cobra.Completio
// HACK: Invoke rootCmd's PersistentPreRunE, which is needed for context
// detection and client initialization. This function isn't invoked
// automatically on autocompletion paths.
cmd.Parent().PersistentPreRunE(cmd, args)
if err := cmd.Parent().PersistentPreRunE(cmd, args); err != nil {
return nil, cobra.ShellCompDirectiveError
}

if limit > 0 && len(args) >= limit {
return nil, cobra.ShellCompDirectiveNoFileComp
Expand All @@ -41,7 +43,9 @@ func ModelNamesAndTags(desktopClient func() *desktop.Client, limit int) cobra.Co
// HACK: Invoke rootCmd's PersistentPreRunE, which is needed for context
// detection and client initialization. This function isn't invoked
// automatically on autocompletion paths.
cmd.Parent().PersistentPreRunE(cmd, args)
if err := cmd.Parent().PersistentPreRunE(cmd, args); err != nil {
return nil, cobra.ShellCompDirectiveError
}

if limit > 0 && len(args) >= limit {
return nil, cobra.ShellCompDirectiveNoFileComp
Expand Down
Loading