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
18 changes: 2 additions & 16 deletions cmd/cli/commands/df.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/docker/go-units"
"github.com/docker/model-runner/cmd/cli/commands/completion"
"github.com/docker/model-runner/cmd/cli/desktop"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
)

Expand All @@ -29,21 +28,8 @@ func newDFCmd() *cobra.Command {

func diskUsageTable(df desktop.DiskUsage) string {
var buf bytes.Buffer
table := tablewriter.NewWriter(&buf)

table.SetHeader([]string{"TYPE", "SIZE"})

table.SetBorder(false)
table.SetColumnSeparator("")
table.SetHeaderLine(false)
table.SetTablePadding(" ")
table.SetNoWhiteSpace(true)

table.SetColumnAlignment([]int{
tablewriter.ALIGN_LEFT, // TYPE
tablewriter.ALIGN_LEFT, // SIZE
})
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
table := newTable(&buf)
table.Header([]string{"TYPE", "SIZE"})

table.Append([]string{"Models", units.CustomSize("%.2f%s", float64(df.ModelsDiskUsage), 1000.0, []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"})})
if df.DefaultBackendDiskUsage != 0 {
Expand Down
23 changes: 2 additions & 21 deletions cmd/cli/commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,27 +197,8 @@ func prettyPrintModels(models []dmrm.Model) string {
})

var buf bytes.Buffer
table := tablewriter.NewWriter(&buf)

table.SetHeader([]string{"MODEL NAME", "PARAMETERS", "QUANTIZATION", "ARCHITECTURE", "MODEL ID", "CREATED", "CONTEXT", "SIZE"})

table.SetBorder(false)
table.SetColumnSeparator("")
table.SetHeaderLine(false)
table.SetTablePadding(" ")
table.SetNoWhiteSpace(true)

table.SetColumnAlignment([]int{
tablewriter.ALIGN_LEFT, // MODEL
tablewriter.ALIGN_LEFT, // PARAMETERS
tablewriter.ALIGN_LEFT, // QUANTIZATION
tablewriter.ALIGN_LEFT, // ARCHITECTURE
tablewriter.ALIGN_LEFT, // MODEL ID
tablewriter.ALIGN_LEFT, // CREATED
tablewriter.ALIGN_RIGHT, // CONTEXT
tablewriter.ALIGN_LEFT, // SIZE
})
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
table := newTable(&buf)
table.Header([]string{"MODEL NAME", "PARAMETERS", "QUANTIZATION", "ARCHITECTURE", "MODEL ID", "CREATED", "CONTEXT", "SIZE"})

for _, row := range rows {
appendRow(table, row.tag, row.model)
Expand Down
20 changes: 2 additions & 18 deletions cmd/cli/commands/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/docker/go-units"
"github.com/docker/model-runner/cmd/cli/commands/completion"
"github.com/docker/model-runner/cmd/cli/desktop"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
)

Expand All @@ -31,23 +30,8 @@ func newPSCmd() *cobra.Command {

func psTable(ps []desktop.BackendStatus) string {
var buf bytes.Buffer
table := tablewriter.NewWriter(&buf)

table.SetHeader([]string{"MODEL NAME", "BACKEND", "MODE", "LAST USED"})

table.SetBorder(false)
table.SetColumnSeparator("")
table.SetHeaderLine(false)
table.SetTablePadding(" ")
table.SetNoWhiteSpace(true)

table.SetColumnAlignment([]int{
tablewriter.ALIGN_LEFT, // MODEL
tablewriter.ALIGN_LEFT, // BACKEND
tablewriter.ALIGN_LEFT, // MODE
tablewriter.ALIGN_LEFT, // LAST USED
})
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
table := newTable(&buf)
table.Header([]string{"MODEL NAME", "BACKEND", "MODE", "LAST USED"})

for _, status := range ps {
modelName := status.ModelName
Expand Down
35 changes: 35 additions & 0 deletions cmd/cli/commands/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"io"
"os"
"strings"

Expand All @@ -13,6 +14,9 @@ import (
"github.com/docker/model-runner/pkg/go-containerregistry/pkg/name"
"github.com/docker/model-runner/pkg/inference/backends/vllm"
"github.com/moby/term"
"github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/renderer"
"github.com/olekukonko/tablewriter/tw"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -218,3 +222,34 @@ func addRunnerFlags(cmd *cobra.Command, opts runnerFlagOptions) {
cmd.Flags().StringVar(opts.ProxyCert, "proxy-cert", "", "Path to a CA certificate file for proxy SSL inspection")
}
}

// newTable creates a new table with Docker CLI-style formatting:
// no borders, no column separators, no header line, left-aligned, and 2-space padding.
func newTable(w io.Writer) *tablewriter.Table {
return tablewriter.NewTable(w,
tablewriter.WithRenderer(renderer.NewBlueprint(tw.Rendition{
Borders: tw.BorderNone,
Settings: tw.Settings{
Separators: tw.Separators{
BetweenColumns: tw.Off,
},
Lines: tw.Lines{
ShowHeaderLine: tw.Off,
},
},
})),
tablewriter.WithConfig(tablewriter.Config{
Header: tw.CellConfig{
Formatting: tw.CellFormatting{
AutoFormat: tw.Off,
},
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
Padding: tw.CellPadding{Global: tw.Padding{Left: "", Right: " "}},
},
Row: tw.CellConfig{
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
Padding: tw.CellPadding{Global: tw.Padding{Left: "", Right: " "}},
},
}),
)
}
19 changes: 10 additions & 9 deletions cmd/cli/desktop/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import (
"github.com/docker/model-runner/cmd/cli/pkg/standalone"
"github.com/docker/model-runner/cmd/cli/pkg/types"
"github.com/docker/model-runner/pkg/inference"
"github.com/moby/moby/client"
)

// isDesktopContext returns true if the CLI instance points to a Docker Desktop
// context and false otherwise.
func isDesktopContext(ctx context.Context, cli *command.DockerCli) bool {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
serverInfo, _ := cli.Client().Info(ctx)
serverInfo, _ := cli.Client().Info(ctx, client.InfoOptions{})

// We don't currently support Docker Model Runner in Docker Desktop for
// Linux, so we won't treat that as a Docker Desktop case (though it will
Expand All @@ -44,16 +45,16 @@ func isDesktopContext(ctx context.Context, cli *command.DockerCli) bool {
}

// docker run -it --rm --privileged --pid=host justincormack/nsenter1 /bin/sh -c 'cat /etc/os-release'
return serverInfo.OperatingSystem == "Docker Desktop"
return serverInfo.Info.OperatingSystem == "Docker Desktop"
}

func IsDesktopWSLContext(ctx context.Context, cli *command.DockerCli) bool {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
serverInfo, _ := cli.Client().Info(ctx)
serverInfo, _ := cli.Client().Info(ctx, client.InfoOptions{})

return strings.Contains(serverInfo.KernelVersion, "-microsoft-standard-WSL2") &&
serverInfo.OperatingSystem == "Docker Desktop"
return strings.Contains(serverInfo.Info.KernelVersion, "-microsoft-standard-WSL2") &&
serverInfo.Info.OperatingSystem == "Docker Desktop"
}

// isCloudContext returns true if the CLI instance points to a Docker Cloud
Expand Down Expand Up @@ -138,14 +139,14 @@ func wakeUpCloudIfIdle(ctx context.Context, cli *command.DockerCli) error {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

info, err := cli.Client().Info(ctx)
info, err := cli.Client().Info(ctx, client.InfoOptions{})
if err != nil {
return fmt.Errorf("failed to get Docker info: %w", err)
}

// Check if the cloud.docker.run.engine label is set to "idle".
isIdle := false
for _, label := range info.Labels {
for _, label := range info.Info.Labels {
if label == "cloud.docker.run.engine=idle" {
isIdle = true
break
Expand All @@ -170,12 +171,12 @@ func wakeUpCloudIfIdle(ctx context.Context, cli *command.DockerCli) error {
}

// Verify Docker Cloud is no longer idle.
info, err = cli.Client().Info(ctx)
info, err = cli.Client().Info(ctx, client.InfoOptions{})
if err != nil {
return fmt.Errorf("failed to verify Docker Cloud wake-up: %w", err)
}

for _, label := range info.Labels {
for _, label := range info.Info.Labels {
if label == "cloud.docker.run.engine=idle" {
return fmt.Errorf("failed to wake up Docker Cloud from idle state")
}
Expand Down
48 changes: 26 additions & 22 deletions cmd/cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,29 @@ go 1.24.0
require (
github.com/charmbracelet/glamour v0.10.0
github.com/containerd/errdefs v1.0.0
github.com/docker/cli v28.3.0+incompatible
github.com/docker/cli-docs-tool v0.10.0
github.com/docker/docker v28.3.3+incompatible
github.com/docker/cli v29.1.3+incompatible
github.com/docker/cli-docs-tool v0.11.0
github.com/docker/docker v28.5.2+incompatible
github.com/docker/go-connections v0.6.0
github.com/docker/go-units v0.5.0
github.com/docker/model-runner v1.0.3
github.com/docker/model-runner v1.0.10
github.com/docker/model-runner/pkg/go-containerregistry v0.0.0-20251121150728-6951a2a36575
github.com/emirpasic/gods/v2 v2.0.0-alpha
github.com/fatih/color v1.18.0
github.com/mattn/go-runewidth v0.0.16
github.com/mattn/go-runewidth v0.0.19
github.com/moby/moby/client v0.2.1
github.com/moby/term v0.5.2
github.com/muesli/termenv v0.16.0
github.com/nxadm/tail v1.4.8
github.com/olekukonko/tablewriter v0.0.5
github.com/nxadm/tail v1.4.11
github.com/olekukonko/tablewriter v1.1.2
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.10.1
github.com/spf13/pflag v1.0.9
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/stretchr/testify v1.11.1
github.com/testcontainers/testcontainers-go v0.39.0
github.com/testcontainers/testcontainers-go/modules/registry v0.39.0
go.opentelemetry.io/otel v1.37.0
go.uber.org/mock v0.5.0
github.com/testcontainers/testcontainers-go v0.40.0
github.com/testcontainers/testcontainers-go/modules/registry v0.40.0
go.opentelemetry.io/otel v1.39.0
go.uber.org/mock v0.6.0
golang.org/x/sync v0.19.0
golang.org/x/sys v0.39.0
golang.org/x/term v0.38.0
Expand All @@ -40,12 +41,16 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 // indirect
github.com/charmbracelet/x/ansi v0.8.0 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/clipperhouse/displaywidth v0.6.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
github.com/containerd/containerd/v2 v2.1.5 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
Expand All @@ -54,23 +59,19 @@ require (
github.com/containerd/typeurl/v2 v2.2.3 // indirect
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/creack/pty v1.1.24 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.9.3 // indirect
github.com/ebitengine/purego v0.8.4 // indirect
github.com/elastic/go-sysinfo v1.15.4 // indirect
github.com/elastic/go-windows v1.0.2 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fvbommel/sortorder v1.1.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-containerregistry v0.20.6 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/gorilla/mux v1.8.1 // indirect
Expand All @@ -94,6 +95,7 @@ require (
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/go-archive v0.1.0 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/moby/api v1.52.0 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/atomicwriter v0.1.0 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
Expand All @@ -104,37 +106,39 @@ require (
github.com/morikuni/aec v1.0.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
github.com/olekukonko/errors v1.1.0 // indirect
github.com/olekukonko/ll v0.1.3 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.4 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil/v4 v4.25.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/smallnest/ringbuffer v0.0.0-20241116012123-461381446e3d // indirect
github.com/theupdateframework/notary v0.7.1-0.20210315103452-bf96a202a09a // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/vbatts/tar-split v0.12.1 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yuin/goldmark v1.7.8 // indirect
github.com/yuin/goldmark-emoji v1.0.5 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.34.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0 // indirect
go.opentelemetry.io/otel/metric v1.37.0 // indirect
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.37.0 // indirect
go.opentelemetry.io/otel/trace v1.37.0 // indirect
go.opentelemetry.io/otel/trace v1.39.0 // indirect
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.43.0 // indirect
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
golang.org/x/mod v0.28.0 // indirect
Expand Down
Loading
Loading