From 038b9529420666cc73e494117ed2e4d2d483eb82 Mon Sep 17 00:00:00 2001 From: aaroncasas Date: Mon, 10 Oct 2022 16:37:22 -0400 Subject: [PATCH 1/6] Next -> ReadImage. --- services/datamanager/datacapture/data_capture_file.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/datamanager/datacapture/data_capture_file.go b/services/datamanager/datacapture/data_capture_file.go index 46d51af8981..18aee728eb3 100644 --- a/services/datamanager/datacapture/data_capture_file.go +++ b/services/datamanager/datacapture/data_capture_file.go @@ -21,7 +21,7 @@ import ( // FileExt defines the file extension for Viam data capture files. const ( FileExt = ".capture" - next = "Next" + readImage = "ReadImage" nextPointCloud = "NextPointCloud" ) @@ -56,7 +56,7 @@ func BuildCaptureMetadata(compType resource.SubtypeName, compName, compModel, me return nil, err } - dataType := getDataType(string(compType), method) + dataType := getDataType(method) return &v1.DataCaptureMetadata{ ComponentType: string(compType), ComponentName: compName, @@ -112,9 +112,9 @@ func getFileTimestampName() string { // TODO DATA-246: Implement this in some more robust, programmatic way. // TODO: support GetImage. This is why image stuff isn't working. -func getDataType(_, methodName string) v1.DataType { +func getDataType(methodName string) v1.DataType { switch methodName { - case nextPointCloud, next: + case nextPointCloud, readImage: return v1.DataType_DATA_TYPE_BINARY_SENSOR default: return v1.DataType_DATA_TYPE_TABULAR_SENSOR @@ -133,7 +133,7 @@ func GetFileExt(dataType v1.DataType, methodName string, parameters map[string]s if methodName == nextPointCloud { return ".pcd" } - if methodName == next { + if methodName == ReadImage { // TODO: Add explicit file extensions for all mime types. switch parameters["mime_type"] { case utils.MimeTypeJPEG: From a8d741922b240a7a68df8dc1149325c5565a2d97 Mon Sep 17 00:00:00 2001 From: aaroncasas Date: Mon, 10 Oct 2022 16:48:03 -0400 Subject: [PATCH 2/6] oof --- services/datamanager/datacapture/data_capture_file.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/datamanager/datacapture/data_capture_file.go b/services/datamanager/datacapture/data_capture_file.go index 18aee728eb3..931fd20112e 100644 --- a/services/datamanager/datacapture/data_capture_file.go +++ b/services/datamanager/datacapture/data_capture_file.go @@ -133,7 +133,7 @@ func GetFileExt(dataType v1.DataType, methodName string, parameters map[string]s if methodName == nextPointCloud { return ".pcd" } - if methodName == ReadImage { + if methodName == readImage { // TODO: Add explicit file extensions for all mime types. switch parameters["mime_type"] { case utils.MimeTypeJPEG: From 7759a326e92a86dff17f8fd1ad5c36bc88e04650 Mon Sep 17 00:00:00 2001 From: aaroncasas Date: Mon, 10 Oct 2022 16:59:18 -0400 Subject: [PATCH 3/6] oof, x2 --- services/datamanager/datacapture/data_capture_file_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/datamanager/datacapture/data_capture_file_test.go b/services/datamanager/datacapture/data_capture_file_test.go index a346c114f6e..1840226dc0d 100644 --- a/services/datamanager/datacapture/data_capture_file_test.go +++ b/services/datamanager/datacapture/data_capture_file_test.go @@ -39,7 +39,7 @@ func TestBuildCaptureMetadata(t *testing.T) { componentType: "camera", componentName: "cam1", componentModel: "webcam", - method: "Next", + method: readImage, additionalParams: map[string]string{"mime_type": utils.MimeTypeJPEG}, dataType: v1.DataType_DATA_TYPE_BINARY_SENSOR, fileExtension: ".jpeg", @@ -50,7 +50,7 @@ func TestBuildCaptureMetadata(t *testing.T) { componentType: "camera", componentName: "cam1", componentModel: "velodyne", - method: "Next", + method: readImage, additionalParams: map[string]string{"mime_type": utils.MimeTypePCD}, dataType: v1.DataType_DATA_TYPE_BINARY_SENSOR, fileExtension: ".pcd", @@ -61,7 +61,7 @@ func TestBuildCaptureMetadata(t *testing.T) { componentType: "camera", componentName: "cam1", componentModel: "velodyne", - method: "NextPointCloud", + method: nextPointCloud, additionalParams: make(map[string]string), dataType: v1.DataType_DATA_TYPE_BINARY_SENSOR, fileExtension: ".pcd", From d3499bd4775b651a084250304e81e5eeeb98fc65 Mon Sep 17 00:00:00 2001 From: aaroncasas Date: Mon, 10 Oct 2022 17:00:12 -0400 Subject: [PATCH 4/6] MMight as well change to use t.Run while I'm here. --- .../datacapture/data_capture_file_test.go | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/services/datamanager/datacapture/data_capture_file_test.go b/services/datamanager/datacapture/data_capture_file_test.go index 1840226dc0d..d5d8ca4b52c 100644 --- a/services/datamanager/datacapture/data_capture_file_test.go +++ b/services/datamanager/datacapture/data_capture_file_test.go @@ -1,12 +1,11 @@ package datacapture import ( + "go.viam.com/rdk/protoutils" + "go.viam.com/test" "testing" v1 "go.viam.com/api/app/datasync/v1" - "go.viam.com/test" - - "go.viam.com/rdk/protoutils" "go.viam.com/rdk/resource" "go.viam.com/rdk/utils" ) @@ -70,24 +69,25 @@ func TestBuildCaptureMetadata(t *testing.T) { } for _, tc := range tests { - t.Log(tc.name) - actualMetadata, err := BuildCaptureMetadata( - tc.componentType, tc.componentName, tc.componentModel, tc.method, tc.additionalParams, tc.tags) - test.That(t, err, test.ShouldEqual, nil) + t.Run(tc.name, func(t *testing.T) { + actualMetadata, err := BuildCaptureMetadata( + tc.componentType, tc.componentName, tc.componentModel, tc.method, tc.additionalParams, tc.tags) + test.That(t, err, test.ShouldEqual, nil) - methodParams, err := protoutils.ConvertStringMapToAnyPBMap(tc.additionalParams) - test.That(t, err, test.ShouldEqual, nil) + methodParams, err := protoutils.ConvertStringMapToAnyPBMap(tc.additionalParams) + test.That(t, err, test.ShouldEqual, nil) - expectedMetadata := v1.DataCaptureMetadata{ - ComponentType: string(tc.componentType), - ComponentName: tc.componentName, - ComponentModel: tc.componentModel, - MethodName: tc.method, - Type: tc.dataType, - MethodParameters: methodParams, - FileExtension: tc.fileExtension, - Tags: tc.tags, - } - test.That(t, actualMetadata.String(), test.ShouldEqual, expectedMetadata.String()) + expectedMetadata := v1.DataCaptureMetadata{ + ComponentType: string(tc.componentType), + ComponentName: tc.componentName, + ComponentModel: tc.componentModel, + MethodName: tc.method, + Type: tc.dataType, + MethodParameters: methodParams, + FileExtension: tc.fileExtension, + Tags: tc.tags, + } + test.That(t, actualMetadata.String(), test.ShouldEqual, expectedMetadata.String()) + }) } } From f8567bb31cee91dbd7984af24f3db8882c8f834a Mon Sep 17 00:00:00 2001 From: aaroncasas Date: Mon, 10 Oct 2022 17:19:29 -0400 Subject: [PATCH 5/6] Imports? --- services/datamanager/datacapture/data_capture_file_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/datamanager/datacapture/data_capture_file_test.go b/services/datamanager/datacapture/data_capture_file_test.go index d5d8ca4b52c..05e606215dc 100644 --- a/services/datamanager/datacapture/data_capture_file_test.go +++ b/services/datamanager/datacapture/data_capture_file_test.go @@ -1,13 +1,13 @@ package datacapture import ( - "go.viam.com/rdk/protoutils" - "go.viam.com/test" "testing" v1 "go.viam.com/api/app/datasync/v1" + "go.viam.com/rdk/protoutils" "go.viam.com/rdk/resource" "go.viam.com/rdk/utils" + "go.viam.com/test" ) func TestBuildCaptureMetadata(t *testing.T) { From e8965b06df19b2c4bd9872859051e0b39ed43349 Mon Sep 17 00:00:00 2001 From: aaroncasas Date: Mon, 10 Oct 2022 17:20:37 -0400 Subject: [PATCH 6/6] ok i guess --- services/datamanager/datacapture/data_capture_file_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/datamanager/datacapture/data_capture_file_test.go b/services/datamanager/datacapture/data_capture_file_test.go index 05e606215dc..7353af30de9 100644 --- a/services/datamanager/datacapture/data_capture_file_test.go +++ b/services/datamanager/datacapture/data_capture_file_test.go @@ -4,10 +4,11 @@ import ( "testing" v1 "go.viam.com/api/app/datasync/v1" + "go.viam.com/test" + "go.viam.com/rdk/protoutils" "go.viam.com/rdk/resource" "go.viam.com/rdk/utils" - "go.viam.com/test" ) func TestBuildCaptureMetadata(t *testing.T) {