-
Notifications
You must be signed in to change notification settings - Fork 111
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
RSDK-7532 - Adding getProperties to vision service #3925
Conversation
Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The biggest change is to add an returned error to the properties, because if we are on purpose making the Properties struct something that could potentially grow in the future, you'll want to avoid the possibility of having to add an error return in the future
Also, add tests! Or rather, you can add GetProperties checks to our existing tests. You can check to see if some of our classifiers or detectors return the expected properties. Be sure to add tests to the client and server code as well
services/vision/client.go
Outdated
|
||
ext, err := protoutils.StructToStructPb(extra) | ||
if err != nil { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to return the error
services/vision/client.go
Outdated
Extra: ext, | ||
}) | ||
if err != nil { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return the error
services/vision/client.go
Outdated
@@ -242,6 +242,26 @@ func protoToObjects(pco []*commonpb.PointCloudObject) ([]*vision.Object, error) | |||
return objects, nil | |||
} | |||
|
|||
func (c *client) GetProperties(ctx context.Context, extra map[string]interface{}) *Properties { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method should also return an error
services/vision/vision.go
Outdated
@@ -128,6 +128,8 @@ type Service interface { | |||
|
|||
// GetObjectPointClouds returns a list of 3D point cloud objects and metadata from the latest 3D camera image using a specified segmenter. | |||
GetObjectPointClouds(ctx context.Context, cameraName string, extra map[string]interface{}) ([]*viz.Object, error) | |||
// properties | |||
GetProperties(ctx context.Context, extra map[string]interface{}) *Properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll want to return an error as well -- in the interest of future proofing, what if you add something to the properties that can easily return an error? You would then have to introduce a breaking change to add the error output
services/vision/vision.go
Outdated
func (vm *vizModel) GetProperties(ctx context.Context, extra map[string]interface{}) *Properties { | ||
_, span := trace.StartSpan(ctx, "service::vision::GetProperties::"+vm.Named.Name().String()) | ||
defer span.End() | ||
|
||
return &vm.properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to return an error
testutils/inject/vision_service.go
Outdated
@@ -28,6 +28,7 @@ type VisionService struct { | |||
n int, extra map[string]interface{}) (classification.Classifications, error) | |||
// segmentation functions | |||
GetObjectPointCloudsFunc func(ctx context.Context, cameraName string, extra map[string]interface{}) ([]*viz.Object, error) | |||
GetPropertiesFunc func(ctx context.Context, extra map[string]interface{}) *vision.Properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to return an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding error and some tests, but you'll still want to add tests for GetProperties to client_test.go and server_test.go. You'll want to see that the properties are transferred over GRPC successfully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! LGTM
No description provided.