Migrate comparison bundles to v2
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
const (
|
||||
// SchemaVersion identifies the supported comparison manifest schema.
|
||||
SchemaVersion = "weatherreporter.comparison.v1"
|
||||
SchemaVersion = "weatherreporter.comparison.v2"
|
||||
|
||||
// ManifestFilename is the canonical name of a comparison manifest.
|
||||
ManifestFilename = "comparison.json"
|
||||
@@ -71,6 +71,7 @@ type Result struct {
|
||||
ModelName string `json:"modelName"`
|
||||
Status string `json:"status"`
|
||||
ValidationStatus string `json:"validationStatus,omitempty"`
|
||||
RepairAttempts *int `json:"repairAttempts,omitempty"`
|
||||
ReportPath string `json:"reportPath,omitempty"`
|
||||
Error *SafeError `json:"error,omitempty"`
|
||||
}
|
||||
@@ -276,11 +277,14 @@ func (manifest Manifest) Validate() error {
|
||||
if strings.TrimSpace(result.ModelName) == "" {
|
||||
return fmt.Errorf("result %d has a blank model name", result.Position)
|
||||
}
|
||||
if result.RepairAttempts != nil && *result.RepairAttempts < 0 {
|
||||
return fmt.Errorf("result %d has negative repair attempts", result.Position)
|
||||
}
|
||||
|
||||
switch result.Status {
|
||||
case StatusSucceeded:
|
||||
succeeded++
|
||||
if result.ValidationStatus != "passed" {
|
||||
if result.ValidationStatus != "passed" || result.RepairAttempts == nil {
|
||||
return fmt.Errorf("successful result %d did not pass validation", result.Position)
|
||||
}
|
||||
expectedPath, err := ReportFilename(result.Position, manifest.Total, result.ProfileID)
|
||||
@@ -302,6 +306,9 @@ func (manifest Manifest) Validate() error {
|
||||
if err := result.Error.validate(); err != nil {
|
||||
return fmt.Errorf("failed result %d: %w", result.Position, err)
|
||||
}
|
||||
if result.ValidationStatus != "" && result.RepairAttempts == nil {
|
||||
return fmt.Errorf("failed result %d has validation without repair provenance", result.Position)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("result %d has unsupported status %q", result.Position, result.Status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user