(ctx context.Context, project *types.Project, quietPull bool)
| 37 | ) |
| 38 | |
| 39 | func (s *composeService) ensureModels(ctx context.Context, project *types.Project, quietPull bool) error { |
| 40 | if len(project.Models) == 0 { |
| 41 | return nil |
| 42 | } |
| 43 | |
| 44 | mdlAPI, err := s.newModelAPI(project) |
| 45 | if err != nil { |
| 46 | return err |
| 47 | } |
| 48 | defer mdlAPI.Close() |
| 49 | availableModels, err := mdlAPI.ListModels(ctx) |
| 50 | |
| 51 | eg, ctx := errgroup.WithContext(ctx) |
| 52 | eg.Go(func() error { |
| 53 | return mdlAPI.SetModelVariables(ctx, project) |
| 54 | }) |
| 55 | |
| 56 | for name, config := range project.Models { |
| 57 | if config.Name == "" { |
| 58 | config.Name = name |
| 59 | } |
| 60 | eg.Go(func() error { |
| 61 | if !slices.Contains(availableModels, config.Model) { |
| 62 | err = mdlAPI.PullModel(ctx, config, quietPull, s.events) |
| 63 | if err != nil { |
| 64 | return err |
| 65 | } |
| 66 | } |
| 67 | return mdlAPI.ConfigureModel(ctx, config, s.events) |
| 68 | }) |
| 69 | } |
| 70 | return eg.Wait() |
| 71 | } |
| 72 | |
| 73 | type modelAPI struct { |
| 74 | path string |
no test coverage detected