AI: Make error messages lower case in ai/tensorflow/info.go #127 #5011

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-08-04 10:00:09 +02:00
parent 75785ff2f3
commit 10fe7d2b40
5 changed files with 26 additions and 26 deletions

View File

@@ -205,7 +205,7 @@ func downloadRemoteModel(t *testing.T, url, tmpPath string) (model string) {
} }
if err != nil { if err != nil {
t.Fatalf("Could not extract the file: %v", err) t.Fatalf("could not extract the file: %v", err)
} }
target := filepath.Join(tmpPath, header.Name) target := filepath.Join(tmpPath, header.Name)
@@ -216,15 +216,15 @@ func downloadRemoteModel(t *testing.T, url, tmpPath string) (model string) {
switch header.Typeflag { switch header.Typeflag {
case tar.TypeDir: case tar.TypeDir:
if err := os.Mkdir(target, 0755); err != nil { if err := os.Mkdir(target, 0755); err != nil {
t.Fatalf("Could not make the dir %s: %v", header.Name, err) t.Fatalf("could not make the dir %s: %v", header.Name, err)
} }
case tar.TypeReg: case tar.TypeReg:
outFile, err := os.Create(target) outFile, err := os.Create(target)
if err != nil { if err != nil {
t.Fatalf("Could not create file %s: %v", header.Name, err) t.Fatalf("could not create file %s: %v", header.Name, err)
} }
if _, err := io.Copy(outFile, tarReader); err != nil { if _, err := io.Copy(outFile, tarReader); err != nil {
t.Fatalf("Could not copy file %s: %v", header.Name, err) t.Fatalf("could not copy file %s: %v", header.Name, err)
} }
rootPath, fileName := filepath.Split(header.Name) rootPath, fileName := filepath.Split(header.Name)
@@ -233,7 +233,7 @@ func downloadRemoteModel(t *testing.T, url, tmpPath string) (model string) {
} }
outFile.Close() outFile.Close()
default: default:
t.Fatalf("Could not extract file. Unknown type %v in %s", t.Fatalf("could not extract file. Unknown type %v in %s",
header.Typeflag, header.Typeflag,
header.Name) header.Name)
} }

View File

@@ -281,7 +281,7 @@ func TestModel_LoadModel(t *testing.T) {
err := tensorFlow.loadModel() err := tensorFlow.loadModel()
if err != nil { if err != nil {
assert.Contains(t, err.Error(), "Could not find SavedModel") assert.Contains(t, err.Error(), "could not find SavedModel")
} }
assert.Error(t, err) assert.Error(t, err)

View File

@@ -440,7 +440,7 @@ func GetInputAndOutputFromMetaSignature(meta *pb.MetaGraphDef) (*PhotoInput, *Mo
inputIdx, err = strconv.Atoi(inputIndex) inputIdx, err = strconv.Atoi(inputIndex)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("Could not parse index %s: %w", inputIndex, err) return nil, nil, fmt.Errorf("could not parse index %s: %w", inputIndex, err)
} }
} }
@@ -449,7 +449,7 @@ func GetInputAndOutputFromMetaSignature(meta *pb.MetaGraphDef) (*PhotoInput, *Mo
outputIdx, err = strconv.Atoi(outputIndex) outputIdx, err = strconv.Atoi(outputIndex)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("Could not parse index: %s: %w", outputIndex, err) return nil, nil, fmt.Errorf("could not parse index: %s: %w", outputIndex, err)
} }
} }
@@ -481,14 +481,14 @@ func GetModelInfo(path string) ([]ModelInfo, error) {
data, err := os.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return nil, fmt.Errorf("Could not read the file %s: %w", path, err) return nil, fmt.Errorf("could not read the file %s: %w", path, err)
} }
model := new(pb.SavedModel) model := new(pb.SavedModel)
err = proto.Unmarshal(data, model) err = proto.Unmarshal(data, model)
if err != nil { if err != nil {
return nil, fmt.Errorf("Could not unmarshal the file %s: %w", path, err) return nil, fmt.Errorf("could not unmarshal the file %s: %w", path, err)
} }
models := make([]ModelInfo, 0) models := make([]ModelInfo, 0)
@@ -504,7 +504,7 @@ func GetModelInfo(path string) ([]ModelInfo, error) {
} }
if err != nil { if err != nil {
log.Errorf("Could not get the inputs and outputs from signatures. (TF Version %s): %w", newModel.TFVersion, err) log.Errorf("could not get the inputs and outputs from signatures. (TF Version %s): %w", newModel.TFVersion, err)
} }
models = append(models, newModel) models = append(models, newModel)

View File

@@ -38,19 +38,19 @@ func TestResizeOperationJSON(t *testing.T) {
[]byte(exampleOperationJSON), &op) []byte(exampleOperationJSON), &op)
if err != nil { if err != nil {
t.Fatal("Could not unmarshal the example operation") t.Fatal("could not unmarshal the example operation")
} }
for i := range allOperations { for i := range allOperations {
serialized, err := json.Marshal(allOperations[i]) serialized, err := json.Marshal(allOperations[i])
if err != nil { if err != nil {
t.Fatalf("Could not marshal %v: %v", t.Fatalf("could not marshal %v: %v",
allOperations[i], err) allOperations[i], err)
} }
err = json.Unmarshal(serialized, &op) err = json.Unmarshal(serialized, &op)
if err != nil { if err != nil {
t.Fatalf("Could not unmarshal %s: %v", t.Fatalf("could not unmarshal %s: %v",
string(serialized), err) string(serialized), err)
} }
@@ -67,19 +67,19 @@ func TestResizeOperationYAML(t *testing.T) {
[]byte(exampleOperationYAML), &op) []byte(exampleOperationYAML), &op)
if err != nil { if err != nil {
t.Fatal("Could not unmarshal the example operation") t.Fatal("could not unmarshal the example operation")
} }
for i := range allOperations { for i := range allOperations {
serialized, err := yaml.Marshal(allOperations[i]) serialized, err := yaml.Marshal(allOperations[i])
if err != nil { if err != nil {
t.Fatalf("Could not marshal %v: %v", t.Fatalf("could not marshal %v: %v",
allOperations[i], err) allOperations[i], err)
} }
err = yaml.Unmarshal(serialized, &op) err = yaml.Unmarshal(serialized, &op)
if err != nil { if err != nil {
t.Fatalf("Could not unmarshal %s: %v", t.Fatalf("could not unmarshal %s: %v",
string(serialized), err) string(serialized), err)
} }
@@ -119,19 +119,19 @@ func TestColorChannelOrderJSON(t *testing.T) {
[]byte(exampleOrderJSON), &order) []byte(exampleOrderJSON), &order)
if err != nil { if err != nil {
t.Fatal("Could not unmarshal the example operation") t.Fatal("could not unmarshal the example operation")
} }
for i := range allColorChannelOrders { for i := range allColorChannelOrders {
serialized, err := json.Marshal(allColorChannelOrders[i]) serialized, err := json.Marshal(allColorChannelOrders[i])
if err != nil { if err != nil {
t.Fatalf("Could not marshal %v: %v", t.Fatalf("could not marshal %v: %v",
allColorChannelOrders[i], err) allColorChannelOrders[i], err)
} }
err = json.Unmarshal(serialized, &order) err = json.Unmarshal(serialized, &order)
if err != nil { if err != nil {
t.Fatalf("Could not unmarshal %s: %v", t.Fatalf("could not unmarshal %s: %v",
string(serialized), err) string(serialized), err)
} }
@@ -148,19 +148,19 @@ func TestColorChannelOrderYAML(t *testing.T) {
[]byte(exampleOrderYAML), &order) []byte(exampleOrderYAML), &order)
if err != nil { if err != nil {
t.Fatal("Could not unmarshal the example operation") t.Fatal("could not unmarshal the example operation")
} }
for i := range allColorChannelOrders { for i := range allColorChannelOrders {
serialized, err := yaml.Marshal(allColorChannelOrders[i]) serialized, err := yaml.Marshal(allColorChannelOrders[i])
if err != nil { if err != nil {
t.Fatalf("Could not marshal %v: %v", t.Fatalf("could not marshal %v: %v",
allColorChannelOrders[i], err) allColorChannelOrders[i], err)
} }
err = yaml.Unmarshal(serialized, &order) err = yaml.Unmarshal(serialized, &order)
if err != nil { if err != nil {
t.Fatalf("Could not unmarshal %s: %v", t.Fatalf("could not unmarshal %s: %v",
string(serialized), err) string(serialized), err)
} }

View File

@@ -51,7 +51,7 @@ func GuessInputAndOutput(model *tf.SavedModel) (input *PhotoInput, output *Model
} }
} }
return nil, nil, fmt.Errorf("Could not guess the inputs and outputs") return nil, nil, fmt.Errorf("could not guess the inputs and outputs")
} }
func GetInputAndOutputFromSavedModel(model *tf.SavedModel) (*PhotoInput, *ModelOutput, error) { func GetInputAndOutputFromSavedModel(model *tf.SavedModel) (*PhotoInput, *ModelOutput, error) {
@@ -83,7 +83,7 @@ func GetInputAndOutputFromSavedModel(model *tf.SavedModel) (*PhotoInput, *ModelO
if found { if found {
inputIdx, err = strconv.Atoi(inputIndex) inputIdx, err = strconv.Atoi(inputIndex)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("Could not parse index %s: %w", inputIndex, err) return nil, nil, fmt.Errorf("could not parse index %s: %w", inputIndex, err)
} }
} }
@@ -91,7 +91,7 @@ func GetInputAndOutputFromSavedModel(model *tf.SavedModel) (*PhotoInput, *ModelO
if found { if found {
outputIdx, err = strconv.Atoi(outputIndex) outputIdx, err = strconv.Atoi(outputIndex)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("Could not parse index: %s: %w", outputIndex, err) return nil, nil, fmt.Errorf("could not parse index: %s: %w", outputIndex, err)
} }
} }