Skip to content

Commit

Permalink
Fix file not found when evaluating weights
Browse files Browse the repository at this point in the history
  • Loading branch information
8W9aG committed Jan 15, 2025
1 parent 9dbbe5a commit e006655
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/dockerfile/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ func checkWeights(folder string, weightFile string) ([]Weight, error) {
for _, weight := range weights {
info, err := os.Stat(weight.Path)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
continue
}
return nil, err
}

Expand Down
25 changes: 25 additions & 0 deletions pkg/dockerfile/weights_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package dockerfile

import (
"encoding/json"
"os"
"path/filepath"
"testing"
"time"

"github.com/stretchr/testify/require"
)
Expand All @@ -13,3 +17,24 @@ func TestFindWeights(t *testing.T) {
require.NoError(t, err)
require.Empty(t, weights)
}

func TestFindWeightsWithRemovedWeight(t *testing.T) {
folder := t.TempDir()
tmpDir := t.TempDir()
weightFile := filepath.Join(tmpDir, WEIGHT_FILE)
weights := []Weight{
{
Path: "nonexistant_weight.h5",
Digest: "1",
Timestamp: time.Now(),
Size: 10,
},
}
jsonData, err := json.MarshalIndent(weights, "", " ")
require.NoError(t, err)
err = os.WriteFile(weightFile, jsonData, 0o644)
require.NoError(t, err)
weights, err = FindWeights(folder, tmpDir)
require.NoError(t, err)
require.Empty(t, weights)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ build:
system_packages:
- "git"
predict: "predict.py:Predictor"
image: "test"

0 comments on commit e006655

Please sign in to comment.