Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename collectors to match current method names #1458

Merged
merged 5 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/arm/arm.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func init() {
}, newEndPositionCollector)
data.RegisterCollector(data.MethodMetadata{
Subtype: SubtypeName,
MethodName: getJointPositions.String(),
MethodName: jointPositions.String(),
}, newJointPositionsCollector)
}

Expand Down
10 changes: 5 additions & 5 deletions components/arm/collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ type method int64

const (
endPosition method = iota
getJointPositions
jointPositions
)

func (m method) String() string {
switch m {
case endPosition:
return "GetEndPosition"
case getJointPositions:
return "GetJointPositions"
return "EndPosition"
case jointPositions:
return "JointPositions"
}
return "Unknown"
}
Expand Down Expand Up @@ -50,7 +50,7 @@ func newJointPositionsCollector(resource interface{}, params data.CollectorParam
cFunc := data.CaptureFunc(func(ctx context.Context, _ map[string]*anypb.Any) (interface{}, error) {
v, err := arm.JointPositions(ctx, nil)
if err != nil {
return nil, data.FailedToReadErr(params.ComponentName, getJointPositions.String(), err)
return nil, data.FailedToReadErr(params.ComponentName, jointPositions.String(), err)
}
return v, nil
})
Expand Down
4 changes: 2 additions & 2 deletions components/camera/camera.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func init() {
}, newNextPointCloudCollector)
data.RegisterCollector(data.MethodMetadata{
Subtype: SubtypeName,
MethodName: next.String(),
}, newNextCollector)
MethodName: readImage.String(),
}, newReadImageCollector)
}

// SubtypeName is a constant that identifies the camera resource subtype string.
Expand Down
12 changes: 6 additions & 6 deletions components/camera/collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ type method int64

const (
nextPointCloud method = iota
next method = iota
readImage method = iota
)

func (m method) String() string {
switch m {
case nextPointCloud:
return "NextPointCloud"
case next:
return "Next"
case readImage:
return "ReadImage"
}
return "Unknown"
}
Expand Down Expand Up @@ -61,7 +61,7 @@ func newNextPointCloudCollector(resource interface{}, params data.CollectorParam
return data.NewCollector(cFunc, params)
}

func newNextCollector(resource interface{}, params data.CollectorParams) (data.Collector, error) {
func newReadImageCollector(resource interface{}, params data.CollectorParams) (data.Collector, error) {
camera, err := assertCamera(resource)
if err != nil {
return nil, err
Expand All @@ -78,12 +78,12 @@ func newNextCollector(resource interface{}, params data.CollectorParams) (data.C
}

cFunc := data.CaptureFunc(func(ctx context.Context, _ map[string]*anypb.Any) (interface{}, error) {
_, span := trace.StartSpan(ctx, "camera::data::collector::CaptureFunc::Next")
_, span := trace.StartSpan(ctx, "camera::data::collector::CaptureFunc::ReadImage")
defer span.End()

img, release, err := ReadImage(ctx, camera)
if err != nil {
return nil, data.FailedToReadErr(params.ComponentName, next.String(), err)
return nil, data.FailedToReadErr(params.ComponentName, readImage.String(), err)
}
defer func() {
if release != nil {
Expand Down
4 changes: 2 additions & 2 deletions components/gantry/collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const (
func (m method) String() string {
switch m {
case position:
return "GetPosition"
return "Position"
case lengths:
return "GetLengths"
return "Lengths"
}
return "Unknown"
}
Expand Down
2 changes: 1 addition & 1 deletion components/motor/collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
func (m method) String() string {
switch m {
case position:
return "GetPosition"
return "Position"
case isPowered:
return "IsPowered"
}
Expand Down
2 changes: 1 addition & 1 deletion data/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/matttproud/golang_protobuf_extensions/pbutil"
"github.com/pkg/errors"
"go.opencensus.io/trace"
"go.viam.com/api/app/datasync/v1"
v1 "go.viam.com/api/app/datasync/v1"
"go.viam.com/utils"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/timestamppb"
Expand Down
60 changes: 0 additions & 60 deletions etc/configs/fake_robot_with_remote_and_data_manager.json

This file was deleted.

16 changes: 8 additions & 8 deletions services/datamanager/builtin/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var (

syncIntervalMins = 0.0041 // 250ms
captureDir = "/tmp/capture"
armDir = captureDir + "/arm/arm1/GetEndPosition"
armDir = captureDir + "/arm/arm1/EndPosition"
emptyFileBytesSize = 30 // size of leading metadata message
)

Expand Down Expand Up @@ -166,7 +166,7 @@ func TestNewDataManager(t *testing.T) {
test.That(t, err, test.ShouldBeNil)

// Check that a collector wrote to file.
armDir := captureDir + "/arm/arm1/GetEndPosition"
armDir := captureDir + "/arm/arm1/EndPosition"
filesInArmDir, err := readDir(t, armDir)
test.That(t, err, test.ShouldBeNil)
test.That(t, len(filesInArmDir), test.ShouldEqual, 1)
Expand Down Expand Up @@ -216,7 +216,7 @@ func TestCaptureDisabled(t *testing.T) {
time.Sleep(captureWaitTime)

// Verify that the collector wrote to its file.
armDir := captureDir + "/arm/arm1/GetEndPosition"
armDir := captureDir + "/arm/arm1/EndPosition"
filesInArmDir, err := readDir(t, armDir)
test.That(t, err, test.ShouldBeNil)
test.That(t, len(filesInArmDir), test.ShouldEqual, 1)
Expand Down Expand Up @@ -263,15 +263,15 @@ func TestNewRemoteDataManager(t *testing.T) {
test.That(t, err, test.ShouldBeNil)

// Verify that the local and remote collectors wrote to their files.
localArmDir := captureDir + "/arm/localArm/GetEndPosition"
localArmDir := captureDir + "/arm/localArm/EndPosition"
filesInLocalArmDir, err := readDir(t, localArmDir)
test.That(t, err, test.ShouldBeNil)
test.That(t, len(filesInLocalArmDir), test.ShouldEqual, 1)
info, err := filesInLocalArmDir[0].Info()
test.That(t, err, test.ShouldBeNil)
test.That(t, info.Size(), test.ShouldBeGreaterThan, 0)

remoteArmDir := captureDir + "/arm/remoteArm/GetEndPosition"
remoteArmDir := captureDir + "/arm/remoteArm/EndPosition"
filesInRemoteArmDir, err := readDir(t, remoteArmDir)
test.That(t, err, test.ShouldBeNil)
test.That(t, len(filesInRemoteArmDir), test.ShouldEqual, 1)
Expand Down Expand Up @@ -623,7 +623,7 @@ func TestScheduledSync(t *testing.T) {

// Make the captureDir where we're logging data for our arm.
captureDir := "/tmp/capture"
armDir := captureDir + "/arm/arm1/GetEndPosition"
armDir := captureDir + "/arm/arm1/EndPosition"

// Clear the capture dir after we're done.
defer resetFolder(t, armDir)
Expand Down Expand Up @@ -674,7 +674,7 @@ func TestManualAndScheduledSync(t *testing.T) {

// Make the captureDir where we're logging data for our arm.
captureDir := "/tmp/capture"
armDir := captureDir + "/arm/arm1/GetEndPosition"
armDir := captureDir + "/arm/arm1/EndPosition"
defer resetFolder(t, armDir)

// Initialize the data manager and update it with our config.
Expand Down Expand Up @@ -783,7 +783,7 @@ func TestAdditionalParamsInConfig(t *testing.T) {
test.That(t, err, test.ShouldBeNil)
time.Sleep(captureWaitTime)

filesInCamDir, err := readDir(t, captureDir+"/camera/c1/Next")
filesInCamDir, err := readDir(t, captureDir+"/camera/c1/ReadImage")
test.That(t, err, test.ShouldBeNil)
test.That(t, len(filesInCamDir), test.ShouldEqual, 1)
info, err := filesInCamDir[0].Info()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"attributes": {
"capture_methods": [
{
"method": "GetEndPosition",
"method": "EndPosition",
"capture_frequency_hz": 100,
"tags": [
"a",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"attributes": {
"capture_methods": [
{
"method": "GetEndPosition",
"method": "EndPosition",
"capture_frequency_hz": 100,
"tags": [
"a",
Expand Down Expand Up @@ -49,7 +49,7 @@
"capture_methods": [
{
"name": "rdk:component:arm/remoteArm",
"method": "GetEndPosition",
"method": "EndPosition",
"capture_frequency_hz": 100
}
]
Expand Down
2 changes: 1 addition & 1 deletion services/datamanager/data/robot_with_cam_capture.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"attributes": {
"capture_methods": [
{
"method": "Next",
"method": "ReadImage",
"capture_frequency_hz": 100,
"additional_params": {
"mime_type": "image/jpeg"
Expand Down
2 changes: 1 addition & 1 deletion services/datamanager/datacapture/data_capture_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestBuildCaptureMetadata(t *testing.T) {
componentType: "arm",
componentName: "arm1",
componentModel: "eva",
method: "GetEndPosition",
method: "EndPosition",
additionalParams: make(map[string]string),
dataType: v1.DataType_DATA_TYPE_TABULAR_SENSOR,
fileExtension: ".dat",
Expand Down