saveJobState persists a job's state to disk as state.json.
(job *schema.QuantizationJob)
| 102 | |
| 103 | // saveJobState persists a job's state to disk as state.json. |
| 104 | func (s *QuantizationService) saveJobState(job *schema.QuantizationJob) { |
| 105 | dir := s.jobDir(job.ID) |
| 106 | if err := os.MkdirAll(dir, 0750); err != nil { |
| 107 | xlog.Error("Failed to create quantization job directory", "job_id", job.ID, "error", err) |
| 108 | return |
| 109 | } |
| 110 | |
| 111 | data, err := json.MarshalIndent(job, "", " ") |
| 112 | if err != nil { |
| 113 | xlog.Error("Failed to marshal quantization job state", "job_id", job.ID, "error", err) |
| 114 | return |
| 115 | } |
| 116 | |
| 117 | statePath := filepath.Join(dir, "state.json") |
| 118 | if err := os.WriteFile(statePath, data, 0640); err != nil { |
| 119 | xlog.Error("Failed to write quantization job state", "job_id", job.ID, "error", err) |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | // loadJobsFromDisk scans the quantization directory for persisted jobs and |
| 124 | // returns them. It is the SyncedMap Loader used in standalone mode (no DB); the |
no test coverage detected