MCPcopy Create free account
hub / github.com/docker/model-test / groupFilesByModelWithSource

Function groupFilesByModelWithSource

cmd/analyze-batch/main.go:211–259  ·  view source on GitHub ↗

groupFilesByModelWithSource groups result files by model name and determines batch source

(files []string, batchDirs []string)

Source from the content-addressed store, hash-verified

209
210// groupFilesByModelWithSource groups result files by model name and determines batch source
211func groupFilesByModelWithSource(files []string, batchDirs []string) map[string]ModelFileInfo {
212 modelFiles := make(map[string]ModelFileInfo)
213
214 // Pattern to extract model name from filename
215 pattern := regexp.MustCompile(`^(.+?)_agent_test_results_`)
216
217 for _, file := range files {
218 basename := filepath.Base(file)
219 matches := pattern.FindStringSubmatch(basename)
220
221 var modelName string
222 if len(matches) > 1 {
223 modelName = matches[1]
224 } else {
225 // Fallback: try to extract model name from the middle part
226 parts := strings.Split(basename, "_")
227 if len(parts) >= 4 {
228 modelName = parts[0]
229 } else {
230 modelName = "unknown"
231 }
232 }
233
234 // Determine which batch directory this file came from
235 var batchSource string
236 for _, batchDir := range batchDirs {
237 if strings.HasPrefix(file, batchDir) {
238 batchSource = batchDir
239 break
240 }
241 }
242 if batchSource == "" {
243 batchSource = "unknown"
244 }
245
246 // Get existing info or create new
247 info := modelFiles[modelName]
248 info.files = append(info.files, file)
249 if info.batchSource == "" {
250 info.batchSource = batchSource
251 } else if info.batchSource != batchSource {
252 // Model appears in multiple batches, combine the sources
253 info.batchSource = info.batchSource + "," + batchSource
254 }
255 modelFiles[modelName] = info
256 }
257
258 return modelFiles
259}
260
261// analyzeModel analyzes all result files for a single model
262func analyzeModel(modelName string, files []string) (*ModelAnalysis, error) {

Callers 1

analyzeBatchesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected