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

[RSDK-9314] Fully deprecate data.GetExtraFromContext #4601

Merged
merged 2 commits into from
Dec 4, 2024
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
8 changes: 6 additions & 2 deletions components/camera/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,19 @@ func (c *client) NextPointCloud(ctx context.Context) (pointcloud.PointCloud, err

ctx, getPcdSpan := trace.StartSpan(ctx, "camera::client::NextPointCloud::GetPointCloud")

ext, err := data.GetExtraFromContext(ctx)
extra := make(map[string]interface{})
if ctx.Value(data.FromDMContextKey{}) == true {
extra[data.FromDMString] = true
}
extraStructPb, err := goprotoutils.StructToStructPb(extra)
if err != nil {
return nil, err
}

resp, err := c.client.GetPointCloud(ctx, &pb.GetPointCloudRequest{
Name: c.name,
MimeType: utils.MimeTypePCD,
Extra: ext,
Extra: extraStructPb,
})
getPcdSpan.End()
if err != nil {
Expand Down
10 changes: 0 additions & 10 deletions data/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,3 @@ func InvalidInterfaceErr(api resource.API) error {
func FailedToReadErr(component, method string, err error) error {
return errors.Errorf("failed to get reading of method %s of component %s: %v", method, component, err)
}

// GetExtraFromContext sets the extra struct with "fromDataManagement": true if the flag is true in the context.
// Deprecated: Use camera.FromContext instead.
func GetExtraFromContext(ctx context.Context) (*structpb.Struct, error) {
extra := make(map[string]interface{})
if ctx.Value(FromDMContextKey{}) == true {
extra[FromDMString] = true
}
return protoutils.StructToStructPb(extra)
}
4 changes: 2 additions & 2 deletions module/modmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1223,13 +1223,13 @@ func (m *module) registerResources(mgr modmaninterface.ModuleManager, logger log
return mgr.AddResource(ctx, conf, DepsToNames(deps))
},
Discover: func(ctx context.Context, logger logging.Logger, extra map[string]interface{}) (interface{}, error) {
extraStruct, err := structpb.NewStruct(extra)
extraStructPb, err := structpb.NewStruct(extra)
if err != nil {
return nil, err
}
req := &robotpb.DiscoverComponentsRequest{
Queries: []*robotpb.DiscoveryQuery{
{Subtype: apiCopy.API.String(), Model: modelCopy.String(), Extra: extraStruct},
{Subtype: apiCopy.API.String(), Model: modelCopy.String(), Extra: extraStructPb},
},
}

Expand Down
Loading