Просмотр исходного кода

add 'configured' event at the end of model configuration phase
Currently when using models, the final message is 'confugiring' which could let users think the DMR configuration is still pending

Signed-off-by: Guillaume Lours <[email protected]>

# Conflicts:
# pkg/api/event.go

Guillaume Lours 4 месяцев назад
Родитель
Сommit
6599f8ad84
2 измененных файлов с 15 добавлено и 3 удалено
  1. 2 0
      pkg/api/event.go
  2. 13 3
      pkg/compose/model.go

+ 2 - 0
pkg/api/event.go

@@ -67,6 +67,8 @@ const (
 	StatusExported         = "Exported"
 	StatusExported         = "Exported"
 	StatusDownloading      = "Downloading"
 	StatusDownloading      = "Downloading"
 	StatusDownloadComplete = "Download complete"
 	StatusDownloadComplete = "Download complete"
+	StatusConfiguring      = "Configuring"
+	StatusConfigured       = "Configured"
 )
 )
 
 
 // Resource represents status change and progress for a compose resource.
 // Resource represents status change and progress for a compose resource.

+ 13 - 3
pkg/compose/model.go

@@ -107,7 +107,7 @@ func (m *modelAPI) PullModel(ctx context.Context, model types.ModelConfig, quiet
 	events.On(api.Resource{
 	events.On(api.Resource{
 		ID:     model.Name,
 		ID:     model.Name,
 		Status: api.Working,
 		Status: api.Working,
-		Text:   "Pulling",
+		Text:   api.StatusPulling,
 	})
 	})
 
 
 	cmd := exec.CommandContext(ctx, m.path, "pull", model.Model)
 	cmd := exec.CommandContext(ctx, m.path, "pull", model.Model)
@@ -161,7 +161,7 @@ func (m *modelAPI) ConfigureModel(ctx context.Context, config types.ModelConfig,
 	events.On(api.Resource{
 	events.On(api.Resource{
 		ID:     config.Name,
 		ID:     config.Name,
 		Status: api.Working,
 		Status: api.Working,
-		Text:   "Configuring",
+		Text:   api.StatusConfiguring,
 	})
 	})
 	// configure [--context-size=<n>] MODEL
 	// configure [--context-size=<n>] MODEL
 	args := []string{"configure"}
 	args := []string{"configure"}
@@ -174,7 +174,17 @@ func (m *modelAPI) ConfigureModel(ctx context.Context, config types.ModelConfig,
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
-	return cmd.Run()
+	err = cmd.Run()
+	if err != nil {
+		events.On(errorEvent(config.Name, err.Error()))
+		return err
+	}
+	events.On(api.Resource{
+		ID:     config.Name,
+		Status: api.Done,
+		Text:   api.StatusConfigured,
+	})
+	return nil
 }
 }
 
 
 func (m *modelAPI) SetModelVariables(ctx context.Context, project *types.Project) error {
 func (m *modelAPI) SetModelVariables(ctx context.Context, project *types.Project) error {