MCPcopy
hub / github.com/mudler/LocalAI / StopJob

Method StopJob

core/services/quantization/service.go:285–315  ·  view source on GitHub ↗

StopJob stops a running quantization job.

(ctx context.Context, userID, jobID string)

Source from the content-addressed store, hash-verified

283
284// StopJob stops a running quantization job.
285func (s *QuantizationService) StopJob(ctx context.Context, userID, jobID string) error {
286 s.mu.Lock()
287 job, ok := s.jobs.Get(jobID)
288 if !ok {
289 s.mu.Unlock()
290 return fmt.Errorf("job not found: %s", jobID)
291 }
292 if userID != "" && job.UserID != userID {
293 s.mu.Unlock()
294 return fmt.Errorf("job not found: %s", jobID)
295 }
296 s.mu.Unlock()
297
298 // Kill the backend process directly
299 stopModelID := job.ModelID
300 if stopModelID == "" {
301 stopModelID = job.Backend + "-quantize"
302 }
303 s.modelLoader.ShutdownModel(stopModelID)
304
305 s.mu.Lock()
306 job.Status = "stopped"
307 job.Message = "Quantization stopped by user"
308 if err := s.jobs.Set(ctx, job); err != nil {
309 xlog.Warn("Failed to persist stopped job", "job_id", jobID, "error", err)
310 }
311 s.saveJobState(job)
312 s.mu.Unlock()
313
314 return nil
315}
316
317// DeleteJob removes a quantization job and its associated data from disk.
318func (s *QuantizationService) DeleteJob(userID, jobID string) error {

Callers

nothing calls this directly

Calls 6

saveJobStateMethod · 0.95
LockMethod · 0.65
GetMethod · 0.65
UnlockMethod · 0.65
ShutdownModelMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected