MCPcopy
hub / github.com/docker/compose / ConfigureModel

Method ConfigureModel

pkg/compose/model.go:161–194  ·  pkg/compose/model.go::modelAPI.ConfigureModel
(ctx context.Context, config types.ModelConfig, events api.EventProcessor)

Source from the content-addressed store, hash-verified

159}
160
161func (m *modelAPI) ConfigureModel(ctx context.Context, config types.ModelConfig, events api.EventProcessor) error {
162 events.On(api.Resource{
163 ID: config.Name,
164 Status: api.Working,
165 Text: api.StatusConfiguring,
166 })
167 // configure [--context-size=<n>] MODEL [-- <runtime-flags...>]
168 args := []string{"configure"}
169 if config.ContextSize > 0 {
170 args = append(args, "--context-size", strconv.Itoa(config.ContextSize))
171 }
172 args = append(args, config.Model)
173 // Only append RuntimeFlags if docker model CLI version is >= v1.0.6
174 if len(config.RuntimeFlags) != 0 && m.supportsRuntimeFlags() {
175 args = append(args, "--")
176 args = append(args, config.RuntimeFlags...)
177 }
178 cmd := exec.CommandContext(ctx, m.path, args...)
179 err := m.prepare(ctx, cmd)
180 if err != nil {
181 return err
182 }
183 err = cmd.Run()
184 if err != nil {
185 events.On(errorEvent(config.Name, err.Error()))
186 return err
187 }
188 events.On(api.Resource{
189 ID: config.Name,
190 Status: api.Done,
191 Text: api.StatusConfigured,
192 })
193 return nil
194}
195
196func (m *modelAPI) SetModelVariables(ctx context.Context, project *types.Project) error {
197 cmd := exec.CommandContext(ctx, m.path, "status", "--json")

Callers 1

ensureModelsMethod · 0.80

Calls 4

supportsRuntimeFlagsMethod · 0.95
errorEventFunction · 0.85
ErrorMethod · 0.80
OnMethod · 0.65

Tested by

no test coverage detected