diff --git a/desktop/context.go b/desktop/context.go index aa70d837..adfacc25 100644 --- a/desktop/context.go +++ b/desktop/context.go @@ -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 @@ -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 { kind = types.ModelRunnerEngineKindMobyManual } else if isDesktopContext(ctx, cli) { kind = types.ModelRunnerEngineKindDesktop @@ -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 { diff --git a/pkg/types/engine.go b/pkg/types/engine.go index b16e5299..7e24b7b2 100644 --- a/pkg/types/engine.go +++ b/pkg/types/engine.go @@ -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.