Skip to content

Commit a24e06e

Browse files
authored
fix: Update the deprecated functions in Go feature server. (#5632)
Signed-off-by: Shuchu Han <[email protected]>
1 parent eb51f00 commit a24e06e

File tree

8 files changed

+20
-24
lines changed

8 files changed

+20
-24
lines changed

go/infra/docker/feature-server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22.5
1+
FROM golang:1.23.12
22

33
# Update the package list and install the ca-certificates package
44
RUN apt-get update && apt-get install -y ca-certificates

go/internal/feast/model/featureview.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package model
22

33
import (
4+
"slices"
5+
46
durationpb "google.golang.org/protobuf/types/known/durationpb"
57

68
"github.com/feast-dev/feast/go/protos/feast/core"
@@ -66,10 +68,5 @@ func (fv *FeatureView) NewFeatureViewFromBase(base *BaseFeatureView) *FeatureVie
6668
}
6769

6870
func (fv *FeatureView) HasEntity(name string) bool {
69-
for _, entityName := range fv.EntityNames {
70-
if entityName == name {
71-
return true
72-
}
73-
}
74-
return false
71+
return slices.Contains(fv.EntityNames, name)
7572
}

go/internal/feast/registry/local.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package registry
22

33
import (
44
"github.com/google/uuid"
5-
"io/ioutil"
65
"os"
76
"path/filepath"
87

@@ -33,7 +32,7 @@ func NewFileRegistryStore(config *RegistryConfig, repoPath string) *FileRegistry
3332
// GetRegistryProto reads and parses the registry proto from the file path.
3433
func (r *FileRegistryStore) GetRegistryProto() (*core.Registry, error) {
3534
registry := &core.Registry{}
36-
in, err := ioutil.ReadFile(r.filePath)
35+
in, err := os.ReadFile(r.filePath)
3736
if err != nil {
3837
return nil, err
3938
}
@@ -58,7 +57,7 @@ func (r *FileRegistryStore) writeRegistry(rp *core.Registry) error {
5857
if err != nil {
5958
return err
6059
}
61-
err = ioutil.WriteFile(r.filePath, bytes, 0644)
60+
err = os.WriteFile(r.filePath, bytes, 0644)
6261
if err != nil {
6362
return err
6463
}

go/internal/feast/registry/registry_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package registry
33
import (
44
"context"
55
"errors"
6-
"io/ioutil"
6+
"io"
77
"net/url"
88
"strings"
99
"testing"
@@ -16,7 +16,7 @@ func TestGetOnlineFeaturesS3Registry(t *testing.T) {
1616
mockS3Client := &MockS3Client{
1717
GetObjectFn: func(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error) {
1818
return &s3.GetObjectOutput{
19-
Body: ioutil.NopCloser(strings.NewReader("mock data")),
19+
Body: io.NopCloser(strings.NewReader("mock data")),
2020
}, nil
2121
},
2222
DeleteObjectFn: func(ctx context.Context, params *s3.DeleteObjectInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectOutput, error) {

go/internal/feast/registry/s3.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package registry
33
import (
44
"context"
55
"errors"
6-
"io/ioutil"
6+
"io"
77
"strings"
88
"time"
99

@@ -65,7 +65,7 @@ func (r *S3RegistryStore) GetRegistryProto() (*core.Registry, error) {
6565
}
6666
defer output.Body.Close()
6767

68-
data, err := ioutil.ReadAll(output.Body)
68+
data, err := io.ReadAll(output.Body)
6969
if err != nil {
7070
return nil, err
7171
}

go/internal/feast/server/grpc_server_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package server
22

33
import (
44
"context"
5-
"io/ioutil"
65
"net"
76
"os"
87
"path/filepath"
@@ -21,6 +20,7 @@ import (
2120
"github.com/apache/arrow/go/v17/parquet/pqarrow"
2221
"github.com/stretchr/testify/assert"
2322
"google.golang.org/grpc"
23+
"google.golang.org/grpc/credentials/insecure"
2424
"google.golang.org/grpc/test/bufconn"
2525

2626
"github.com/feast-dev/feast/go/internal/feast"
@@ -84,9 +84,9 @@ func getClient(ctx context.Context, offlineStoreType string, basePath string, lo
8484
}
8585
}()
8686

87-
conn, _ := grpc.DialContext(ctx, "", grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) {
87+
conn, _ := grpc.NewClient("passthrough:///bufnet", grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) {
8888
return listener.Dial()
89-
}), grpc.WithInsecure())
89+
}), grpc.WithTransportCredentials(insecure.NewCredentials()))
9090

9191
closer := func() {
9292
listener.Close()
@@ -216,15 +216,16 @@ func TestGetOnlineFeaturesSqliteWithLogging(t *testing.T) {
216216

217217
// Wait for logger to flush.
218218
require.Eventually(t, func() bool {
219-
files, err := ioutil.ReadDir(logPath)
219+
files, err := os.ReadDir(logPath)
220220
if err != nil || len(files) == 0 {
221221
return false
222222
}
223223
stat, err := os.Stat(filepath.Join(logPath, files[0].Name()))
224224
return err == nil && stat.Size() > 0
225225
}, 1*time.Second, 100*time.Millisecond)
226226

227-
files, err := ioutil.ReadDir(logPath)
227+
files, err := os.ReadDir(logPath)
228+
assert.Nil(t, err)
228229
logFile := filepath.Join(logPath, files[0].Name())
229230
pf, err := file.OpenParquetFile(logFile, false)
230231
assert.Nil(t, err)

go/internal/feast/server/logging/logger_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package logging
22

33
import (
44
"context"
5-
"io/ioutil"
5+
"os"
66
"path/filepath"
77
"testing"
88
"time"
@@ -114,11 +114,11 @@ func TestLogAndFlushToFile(t *testing.T) {
114114
))
115115

116116
require.Eventually(t, func() bool {
117-
files, _ := ioutil.ReadDir(sink.path)
117+
files, _ := os.ReadDir(sink.path)
118118
return len(files) > 0
119119
}, 60*time.Second, 100*time.Millisecond)
120120

121-
files, _ := ioutil.ReadDir(sink.path)
121+
files, _ := os.ReadDir(sink.path)
122122

123123
pf, err := file.OpenParquetFile(filepath.Join(sink.path, files[0].Name()), false)
124124
assert.Nil(t, err)

go/internal/feast/server/logging/offlinestoresink.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package logging
33
import (
44
"fmt"
55
"io"
6-
"io/ioutil"
76
"log"
87
"os"
98
"path/filepath"
@@ -33,7 +32,7 @@ func (s *OfflineStoreSink) getOrCreateDatasetDir() (string, error) {
3332
if s.datasetDir != "" {
3433
return s.datasetDir, nil
3534
}
36-
dir, err := ioutil.TempDir("", "*")
35+
dir, err := os.MkdirTemp("", "*")
3736
if err != nil {
3837
return "", err
3938
}

0 commit comments

Comments
 (0)