(ctx context.Context, model types.ModelConfig, quietPull bool, events api.EventProcessor)
| 109 | } |
| 110 | |
| 111 | func (m *modelAPI) PullModel(ctx context.Context, model types.ModelConfig, quietPull bool, events api.EventProcessor) error { |
| 112 | events.On(api.Resource{ |
| 113 | ID: model.Name, |
| 114 | Status: api.Working, |
| 115 | Text: api.StatusPulling, |
| 116 | }) |
| 117 | |
| 118 | cmd := exec.CommandContext(ctx, m.path, "pull", model.Model) |
| 119 | err := m.prepare(ctx, cmd) |
| 120 | if err != nil { |
| 121 | return err |
| 122 | } |
| 123 | stream, err := cmd.StdoutPipe() |
| 124 | if err != nil { |
| 125 | return err |
| 126 | } |
| 127 | |
| 128 | err = cmd.Start() |
| 129 | if err != nil { |
| 130 | return err |
| 131 | } |
| 132 | |
| 133 | scanner := bufio.NewScanner(stream) |
| 134 | for scanner.Scan() { |
| 135 | msg := scanner.Text() |
| 136 | if msg == "" { |
| 137 | continue |
| 138 | } |
| 139 | |
| 140 | if !quietPull { |
| 141 | events.On(api.Resource{ |
| 142 | ID: model.Name, |
| 143 | Status: api.Working, |
| 144 | Text: api.StatusPulling, |
| 145 | }) |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | err = cmd.Wait() |
| 150 | if err != nil { |
| 151 | events.On(errorEvent(model.Name, err.Error())) |
| 152 | } |
| 153 | events.On(api.Resource{ |
| 154 | ID: model.Name, |
| 155 | Status: api.Working, |
| 156 | Text: api.StatusPulled, |
| 157 | }) |
| 158 | return err |
| 159 | } |
| 160 | |
| 161 | func (m *modelAPI) ConfigureModel(ctx context.Context, config types.ModelConfig, events api.EventProcessor) error { |
| 162 | events.On(api.Resource{ |
no test coverage detected