Skip to content

Commit f42374b

Browse files
gloursndeloof
authored andcommitted
add a Done event to model progress display
Signed-off-by: Guillaume Lours <[email protected]>
1 parent b046a5e commit f42374b

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

pkg/compose/model.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,25 @@ func (s *composeService) ensureModels(ctx context.Context, project *types.Projec
8383
config.Name = name
8484
}
8585
eg.Go(func() error {
86+
w := progress.ContextWriter(gctx)
8687
if !slices.Contains(availableModels, config.Model) {
87-
err = s.pullModel(gctx, dockerModel, config, quietPull)
88+
err = s.pullModel(gctx, dockerModel, config, quietPull, w)
8889
if err != nil {
8990
return err
9091
}
9192
}
92-
return s.configureModel(gctx, dockerModel, config)
93+
err = s.configureModel(gctx, dockerModel, config, w)
94+
if err != nil {
95+
return err
96+
}
97+
w.Event(progress.CreatedEvent(config.Name))
98+
return nil
9399
})
94100
}
95101
return eg.Wait()
96102
}
97103

98-
func (s *composeService) pullModel(ctx context.Context, dockerModel *manager.Plugin, model types.ModelConfig, quietPull bool) error {
99-
w := progress.ContextWriter(ctx)
104+
func (s *composeService) pullModel(ctx context.Context, dockerModel *manager.Plugin, model types.ModelConfig, quietPull bool, w progress.Writer) error {
100105
w.Event(progress.Event{
101106
ID: model.Name,
102107
Status: progress.Working,
@@ -145,7 +150,12 @@ func (s *composeService) pullModel(ctx context.Context, dockerModel *manager.Plu
145150
return err
146151
}
147152

148-
func (s *composeService) configureModel(ctx context.Context, dockerModel *manager.Plugin, config types.ModelConfig) error {
153+
func (s *composeService) configureModel(ctx context.Context, dockerModel *manager.Plugin, config types.ModelConfig, w progress.Writer) error {
154+
w.Event(progress.Event{
155+
ID: config.Name,
156+
Status: progress.Working,
157+
Text: "Configuring",
158+
})
149159
// configure [--context-size=<n>] MODEL [-- <runtime-flags...>]
150160
args := []string{"configure"}
151161
if config.ContextSize > 0 {

0 commit comments

Comments
 (0)