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
11 changes: 10 additions & 1 deletion src/pkg/cli/compose/fixup.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func FixupServices(ctx context.Context, provider client.Provider, project *compo
term.Warnf("service %q: service name is longer than 16 characters, you may run into issues with resource name length", svccfg.Name)
}

// beta docker compose model runner syntax
if svccfg.Provider != nil && svccfg.Provider.Type == "model" && svccfg.Image == "" && svccfg.Build == nil {
fixupModelProvider(&svccfg, project, accountInfo)
}
Expand All @@ -99,6 +100,7 @@ func FixupServices(ctx context.Context, provider client.Provider, project *compo
project.Services[svccfg.Name] = svccfg
}

// modern docker compose model runner syntax
for name, model := range project.Models {
model.Name = name // ensure the model has a name
svccfg := fixupModel(model, project, accountInfo)
Expand Down Expand Up @@ -368,15 +370,22 @@ func fixupIngressPorts(svccfg *composeTypes.ServiceConfig) {
const modelProviderNetwork = "model_provider_private"

func fixupModel(model composeTypes.ModelConfig, project *composeTypes.Project, info *client.AccountInfo) *composeTypes.ServiceConfig {
if model.ContextSize != 0 {
term.Warnf("model %q: context_size is a Docker Model Runner parameter and is not supported for cloud deployments", model.Name)
}
if len(model.RuntimeFlags) > 0 {
term.Warnf("model %q: runtime_flags is a Docker Model Runner parameter and is not supported for cloud deployments", model.Name)
}
svccfg := &composeTypes.ServiceConfig{
Name: model.Name,
Extensions: model.Extensions,
}
makeAccessGatewayService(svccfg, project, model.Model, info) // TODO: pass other model options too
makeAccessGatewayService(svccfg, project, model.Model, info)
return svccfg
}

func fixupModelProvider(svccfg *composeTypes.ServiceConfig, project *composeTypes.Project, info *client.AccountInfo) {
term.Warnf("service %q: 'provider: type: model' is deprecated; use a top-level 'models:' entry instead", svccfg.Name)
var model string
if modelVals := svccfg.Provider.Options["model"]; len(modelVals) == 1 {
model = modelVals[0]
Expand Down
5 changes: 5 additions & 0 deletions src/testdata/models/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ services:
models:
my_model:
endpoint_var: MODEL_URL
withmodelvar:
image: app
models:
ai_model:
model_var: MY_MODEL_NAME

models:
ai_model:
Expand Down
24 changes: 24 additions & 0 deletions src/testdata/models/compose.yaml.fixup
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,29 @@
"default": null,
"model_provider_private": null
}
},
"withmodelvar": {
"command": null,
"depends_on": {
"ai_model": {
"condition": "service_started",
"required": true
}
},
"entrypoint": null,
"environment": {
"AI_MODEL_URL": "http://mock-ai-model:4000/v1/",
"MY_MODEL_NAME": "ai/model"
},
"image": "app",
"models": {
"ai_model": {
"model_var": "MY_MODEL_NAME"
}
},
"networks": {
"default": null,
"model_provider_private": null
}
}
}
7 changes: 7 additions & 0 deletions src/testdata/models/compose.yaml.golden
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ services:
endpoint_var: MODEL_URL
networks:
default: null
withmodelvar:
image: app
models:
ai_model:
model_var: MY_MODEL_NAME
networks:
default: null
networks:
default:
name: models_default
Expand Down
3 changes: 3 additions & 0 deletions src/testdata/models/compose.yaml.warnings
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
! model "my_model": context_size is a Docker Model Runner parameter and is not supported for cloud deployments
! model "my_model": runtime_flags is a Docker Model Runner parameter and is not supported for cloud deployments
! service "ai_model": environment "LITELLM_MASTER_KEY" may contain sensitive information; consider using 'defang config set LITELLM_MASTER_KEY' to securely store this value
! service "ai_model": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "modellist": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "modelmap": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "my_model": environment "LITELLM_MASTER_KEY" may contain sensitive information; consider using 'defang config set LITELLM_MASTER_KEY' to securely store this value
! service "my_model": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "withendpoint": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "withmodelvar": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
1 change: 1 addition & 0 deletions src/testdata/provider/compose.yaml.warnings
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
! service "ai_runner": 'provider: type: model' is deprecated; use a top-level 'models:' entry instead
! service "ai_runner": environment "LITELLM_MASTER_KEY" may contain sensitive information; consider using 'defang config set LITELLM_MASTER_KEY' to securely store this value
! service "ai_runner": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "chat": environment "OPENAI_API_KEY" may contain sensitive information; consider using 'defang config set OPENAI_API_KEY' to securely store this value
Expand Down
Loading