Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.
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
13 changes: 11 additions & 2 deletions desktop/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/docker/model-cli/pkg/standalone"
"github.com/docker/model-cli/pkg/types"
"github.com/docker/model-runner/pkg/inference"
"github.com/pkg/errors"
)

// isDesktopContext returns true if the CLI instance points to a Docker Desktop
Expand Down Expand Up @@ -115,8 +116,12 @@ func DetectContext(ctx context.Context, cli *command.DockerCli) (*ModelRunnerCon
treatDesktopAsMoby := os.Getenv("_MODEL_RUNNER_TREAT_DESKTOP_AS_MOBY") == "1"

// Detect the associated engine type.
kind := types.ModelRunnerEngineKindMoby
if modelRunnerHost != "" {
kind := types.ModelRunnerEngineKindUnknown
if runtime.GOOS == "linux" {
kind = types.ModelRunnerEngineKindMoby
}

if modelRunnerHost != "" && kind == types.ModelRunnerEngineKindMoby {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes MODEL_RUNNER_HOST unusable on macOS and Windows.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I'll have to have another look into this.

kind = types.ModelRunnerEngineKindMobyManual
} else if isDesktopContext(ctx, cli) {
kind = types.ModelRunnerEngineKindDesktop
Expand All @@ -127,6 +132,10 @@ func DetectContext(ctx context.Context, cli *command.DockerCli) (*ModelRunnerCon
kind = types.ModelRunnerEngineKindCloud
}

if kind == types.ModelRunnerEngineKindUnknown {
return nil, errors.New("unable to determine docker engine type")
}

// Compute the URL prefix based on the associated engine kind.
var rawURLPrefix string
if kind == types.ModelRunnerEngineKindMoby {
Expand Down
5 changes: 4 additions & 1 deletion pkg/types/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ package types
type ModelRunnerEngineKind uint8

const (
// ModelRunnerEngineKindUnknown represents an engine whose type can not be
// determined.
ModelRunnerEngineKindUnknown ModelRunnerEngineKind = iota
// ModelRunnerEngineKindMoby represents a non-Desktop/Cloud engine on which
// the Model CLI command is responsible for managing a Model Runner.
ModelRunnerEngineKindMoby ModelRunnerEngineKind = iota
ModelRunnerEngineKindMoby
// ModelRunnerEngineKindMobyManual represents a non-Desktop/Cloud engine
// that's explicitly targeted by a MODEL_RUNNER_HOST environment variable on
// which the user is responsible for managing a Model Runner.
Expand Down