parseBatchIndex extracts the batch index from a checkpoint ID. Returns error if the ID format is invalid.
(checkPointID string)
| 52 | // parseBatchIndex extracts the batch index from a checkpoint ID. |
| 53 | // Returns error if the ID format is invalid. |
| 54 | func parseBatchIndex(checkPointID string) (int, error) { |
| 55 | if !strings.HasPrefix(checkPointID, "batch_") { |
| 56 | return 0, fmt.Errorf("invalid batch checkpoint ID: %s", checkPointID) |
| 57 | } |
| 58 | indexStr := strings.TrimPrefix(checkPointID, "batch_") |
| 59 | return strconv.Atoi(indexStr) |
| 60 | } |
| 61 | |
| 62 | // Get retrieves checkpoint data for a batch index. |
| 63 | // Implements compose.CheckPointStore interface. |