Skip to content

Commit

Permalink
update api dependency and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
benjirewis committed Dec 11, 2024
1 parent 822c102 commit a88c3fa
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 15 deletions.
2 changes: 2 additions & 0 deletions app/data_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ func (d *DataClient) TabularDataByFilter(ctx context.Context, opts *DataByFilter
countOnly = opts.CountOnly
includeInternalData = opts.IncludeInternalData
}
//nolint:deprecated,staticcheck
resp, err := d.dataClient.TabularDataByFilter(ctx, &pb.TabularDataByFilterRequest{
DataRequest: &dataReq,
CountOnly: countOnly,
Expand Down Expand Up @@ -1266,6 +1267,7 @@ func binaryMetadataFromProto(proto *pb.BinaryMetadata) (*BinaryMetadata, error)
}, nil
}

//nolint:deprecated,staticcheck
func tabularDataFromProto(proto *pb.TabularData, metadata *pb.CaptureMetadata) (*TabularData, error) {
if proto == nil {
return nil, nil
Expand Down
5 changes: 5 additions & 0 deletions app/data_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,23 @@ func TestDataClient(t *testing.T) {

t.Run("TabularDataByFilter", func(t *testing.T) {
dataStruct, _ := utils.StructToStructPb(data)
//nolint:deprecated,staticcheck
tabularDataPb := &pb.TabularData{
Data: dataStruct,
MetadataIndex: 0,
TimeRequested: timestamppb.New(start),
TimeReceived: timestamppb.New(end),
}
//nolint:deprecated,staticcheck
grpcClient.TabularDataByFilterFunc = func(ctx context.Context, in *pb.TabularDataByFilterRequest,
opts ...grpc.CallOption,
) (*pb.TabularDataByFilterResponse, error) {
test.That(t, in.DataRequest, test.ShouldResemble, dataRequestToProto(dataRequest))
test.That(t, in.CountOnly, test.ShouldBeTrue)
test.That(t, in.IncludeInternalData, test.ShouldBeTrue)
//nolint:deprecated,staticcheck
return &pb.TabularDataByFilterResponse{
//nolint:deprecated,staticcheck
Data: []*pb.TabularData{tabularDataPb},
Count: pbCount,
Last: last,
Expand Down Expand Up @@ -722,6 +726,7 @@ func TestDataSyncClient(t *testing.T) {
t.Run("TabularDataCaptureUpload", func(t *testing.T) {
uploadMetadata.Type = DataTypeTabularSensor
dataStruct, _ := utils.StructToStructPb(data)
//nolint:deprecated,staticcheck
tabularDataPb := &pb.TabularData{
Data: dataStruct,
MetadataIndex: 0,
Expand Down
5 changes: 5 additions & 0 deletions cli/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,18 @@ func TestTabularDataByFilterAction(t *testing.T) {
// so we need a way of telling our injected method when data has already been sent so we
// can send an empty response
var dataRequested bool
//nolint:deprecated,staticcheck
tabularDataByFilterFunc := func(ctx context.Context, in *datapb.TabularDataByFilterRequest, opts ...grpc.CallOption,
//nolint:deprecated,staticcheck
) (*datapb.TabularDataByFilterResponse, error) {
if dataRequested {
//nolint:deprecated,staticcheck
return &datapb.TabularDataByFilterResponse{}, nil
}
dataRequested = true
//nolint:deprecated,staticcheck
return &datapb.TabularDataByFilterResponse{
//nolint:deprecated,staticcheck
Data: []*datapb.TabularData{{Data: pbStruct}},
Metadata: []*datapb.CaptureMetadata{{LocationId: "loc-id"}},
}, nil
Expand Down
2 changes: 2 additions & 0 deletions cli/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ func (c *viamClient) tabularData(dst string, filter *datapb.Filter, limit uint)
}

var err error
//nolint:deprecated,staticcheck
var resp *datapb.TabularDataByFilterResponse
// TODO(DATA-640): Support export in additional formats.
//nolint:gosec
Expand All @@ -627,6 +628,7 @@ func (c *viamClient) tabularData(dst string, filter *datapb.Filter, limit uint)
mdIndex := 0
for {
for count := 0; count < maxRetryCount; count++ {
//nolint:deprecated,staticcheck
resp, err = c.dataClient.TabularDataByFilter(context.Background(), &datapb.TabularDataByFilterRequest{
DataRequest: &datapb.DataRequest{
Filter: filter,
Expand Down
1 change: 1 addition & 0 deletions components/movementsensor/replay/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ func (replay *replayMovementSensor) updateCache(ctx context.Context, method meth
filter.Method = string(method)

// Retrieve data from the cloud
//nolint:deprecated,staticcheck
resp, err := replay.dataClient.TabularDataByFilter(ctx, &datapb.TabularDataByFilterRequest{
DataRequest: &datapb.DataRequest{
Filter: filter,
Expand Down
7 changes: 6 additions & 1 deletion components/movementsensor/replay/replay_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ type mockDataServiceServer struct {

// TabularDataByFilter is a mocked version of the Data Service function of a similar name. It returns a response with
// data corresponding to the stored data associated with that function and index.
//
//nolint:deprecated,staticcheck
func (mDServer *mockDataServiceServer) TabularDataByFilter(ctx context.Context, req *datapb.TabularDataByFilterRequest,
) (*datapb.TabularDataByFilterResponse, error) {
) (*datapb.TabularDataByFilterResponse, error) { //nolint:deprecated,staticcheck
filter := req.DataRequest.GetFilter()
last := req.DataRequest.GetLast()
limit := req.DataRequest.GetLimit()

//nolint:deprecated,staticcheck
var dataset []*datapb.TabularData
var dataIndex int
var err error
Expand All @@ -75,6 +78,7 @@ func (mDServer *mockDataServiceServer) TabularDataByFilter(ctx context.Context,

last = fmt.Sprint(dataIndex)

//nolint:deprecated,staticcheck
tabularData := &datapb.TabularData{
Data: data,
TimeRequested: timeReq,
Expand All @@ -84,6 +88,7 @@ func (mDServer *mockDataServiceServer) TabularDataByFilter(ctx context.Context,
}

// Construct response
//nolint:deprecated,staticcheck
resp := &datapb.TabularDataByFilterResponse{
Data: dataset,
Last: last,
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ require (
go.uber.org/atomic v1.11.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
go.viam.com/api v0.1.366
go.viam.com/api v0.1.371
go.viam.com/test v1.2.4
go.viam.com/utils v0.1.116
goji.io v2.0.2+incompatible
Expand Down Expand Up @@ -431,5 +431,3 @@ require (
github.com/ziutek/mymysql v1.5.4 // indirect
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
)

replace go.viam.com/api => ./api
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,8 @@ go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.viam.com/api v0.1.371 h1:RkiCPubgWFFKa/gdYBsAtzqQwKBd1d68Us/yp1wPGds=
go.viam.com/api v0.1.371/go.mod h1:g5eipXHNm0rQmW7DWya6avKcmzoypLmxnMlAaIsE5Ls=
go.viam.com/test v1.2.4 h1:JYgZhsuGAQ8sL9jWkziAXN9VJJiKbjoi9BsO33TW3ug=
go.viam.com/test v1.2.4/go.mod h1:zI2xzosHdqXAJ/kFqcN+OIF78kQuTV2nIhGZ8EzvaJI=
go.viam.com/utils v0.1.116 h1:hoCj3SsV8LZAOEP75TjMeX57axhravS8rNUYmhpTWtM=
Expand Down
20 changes: 10 additions & 10 deletions robot/impl/local_robot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4015,15 +4015,15 @@ func TestRemovingOfflineRemotes(t *testing.T) {
}

// Tests that machine state properly reports initializing and running.
//func TestMachineState(t *testing.T) {

//logger := logging.NewTestLogger(t)
//ctx := context.Background()

//completeComponentConstruction := make(chan struct{}, 1)
// completeComponentConstruction := make(chan struct{}, 1)

//// Register a `foo` component whose construction completion can be delayed,
//// and defer its deregistration.
//resource.RegisterComponent(generic.API, fooModel, resource.Registration[resource.Resource,
// resource.RegisterComponent(generic.API, fooModel, resource.Registration[resource.Resource,
//resource.NoNativeConfig]{
//Constructor: func(
//ctx context.Context,
Expand All @@ -4034,7 +4034,7 @@ func TestRemovingOfflineRemotes(t *testing.T) {
//// Delay completion of constructor until `completeComponentConstruction` is closed.
//<-completeComponentConstruction

//return &fooComponent{
// return &fooComponent{
//Named: conf.ResourceName().AsNamed(),
//logger: logger,
//}, nil
Expand All @@ -4044,7 +4044,7 @@ func TestRemovingOfflineRemotes(t *testing.T) {
//resource.Deregister(generic.API, fooModel)
//}()

//cfg := &config.Config{
// cfg := &config.Config{
//Components: []resource.Config{
//{
//Name: "foo",
Expand All @@ -4056,28 +4056,28 @@ func TestRemovingOfflineRemotes(t *testing.T) {
//r := setupLocalRobot(t, ctx, cfg, logger)

//// Assert that robot reports a state of "initializing" until `foo` completes construction.
//machineStatus, err := r.MachineStatus(ctx)
// machineStatus, err := r.MachineStatus(ctx)
//test.That(t, err, test.ShouldBeNil)
//test.That(t, machineStatus, test.ShouldNotBeNil)
//test.That(t, machineStatus.State, test.ShouldEqual, robot.StateInitializing)

//close(completeComponentConstruction)
// close(completeComponentConstruction)

//// Assert that robot reports a state of "running" after `foo` completes
//// construction.
//machineStatus, err = r.MachineStatus(ctx)
// machineStatus, err = r.MachineStatus(ctx)
//test.That(t, err, test.ShouldBeNil)
//test.That(t, machineStatus, test.ShouldNotBeNil)
//test.That(t, machineStatus.State, test.ShouldEqual, robot.StateRunning)

//// Reconfigure robot to replace `foo` with idential `bar` component (should build
//// immediately, as `completeComponentConstruction` has already been closed.)
//cfg.Components[0].Name = "bar"
// cfg.Components[0].Name = "bar"
//r.Reconfigure(ctx, cfg)

//// Assert that robot continues to report a state of "running" even after further
//// reconfiguration.
//machineStatus, err = r.MachineStatus(ctx)
// machineStatus, err = r.MachineStatus(ctx)
//test.That(t, err, test.ShouldBeNil)
//test.That(t, machineStatus, test.ShouldNotBeNil)
//test.That(t, machineStatus.State, test.ShouldEqual, robot.StateRunning)
Expand Down
1 change: 1 addition & 0 deletions robot/robot.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ func (rmr *RestartModuleRequest) MatchesModule(mod config.Module) bool {
return mod.Name == rmr.ModuleName
}

// MachineState captures the state of a machine.
type MachineState uint8

const (
Expand Down
7 changes: 6 additions & 1 deletion testutils/inject/data_service_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
// DataServiceClient represents a fake instance of a data service client.
type DataServiceClient struct {
datapb.DataServiceClient
//nolint:deprecated,staticcheck
TabularDataByFilterFunc func(ctx context.Context, in *datapb.TabularDataByFilterRequest,
//nolint:deprecated,staticcheck
opts ...grpc.CallOption) (*datapb.TabularDataByFilterResponse, error)
TabularDataBySQLFunc func(ctx context.Context, in *datapb.TabularDataBySQLRequest,
opts ...grpc.CallOption) (*datapb.TabularDataBySQLResponse, error)
Expand Down Expand Up @@ -57,10 +59,13 @@ type DataServiceClient struct {
}

// TabularDataByFilter calls the injected TabularDataByFilter or the real version.
//
//nolint:deprecated,staticcheck
func (client *DataServiceClient) TabularDataByFilter(ctx context.Context, in *datapb.TabularDataByFilterRequest,
opts ...grpc.CallOption,
) (*datapb.TabularDataByFilterResponse, error) {
) (*datapb.TabularDataByFilterResponse, error) { //nolint:deprecated,staticcheck
if client.TabularDataByFilterFunc == nil {
//nolint:deprecated,staticcheck
return client.DataServiceClient.TabularDataByFilter(ctx, in, opts...)
}
return client.TabularDataByFilterFunc(ctx, in, opts...)
Expand Down

0 comments on commit a88c3fa

Please sign in to comment.