Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksanford committed Nov 11, 2024
1 parent 3641547 commit 90109b1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
2 changes: 0 additions & 2 deletions data/capture_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
v1 "go.viam.com/api/app/datasync/v1"
)

const captureAllFromCamera = "CaptureAllFromCamera"

// CaptureBufferedWriter is a buffered, persistent queue of SensorData.
type CaptureBufferedWriter interface {
WriteBinary(items []*v1.SensorData) error
Expand Down
23 changes: 9 additions & 14 deletions data/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"go.opencensus.io/trace"
dataPB "go.viam.com/api/app/data/v1"
datasyncPB "go.viam.com/api/app/datasync/v1"
v1 "go.viam.com/api/app/datasync/v1"
camerapb "go.viam.com/api/component/camera/v1"
"go.viam.com/utils"
"go.viam.com/utils/protoutils"
Expand Down Expand Up @@ -562,8 +561,9 @@ func (c *collector) writeCaptureResults() {
}
}

// TabularData is a denormalized sensor reading.
type TabularData struct {
// TabularDataBson is a denormalized sensor reading that can be
// encoded into BSON.
type TabularDataBson struct {
TimeRequested time.Time `bson:"time_requested"`
TimeReceived time.Time `bson:"time_received"`
ComponentName string `bson:"component_name"`
Expand All @@ -575,21 +575,16 @@ type TabularData struct {
// maybeWriteToMongo will write to the mongoCollection
// if it is non-nil and the msg is tabular data
// logs errors on failure.
func (c *collector) maybeWriteToMongo(msg *v1.SensorData) {
func (c *collector) maybeWriteToMongo(msg CaptureResult) {
if c.mongoCollection == nil {
return
}

// DATA-3338:
// currently vision.CaptureAllFromCamera and camera.GetImages are stored in .capture files as VERY LARGE
// tabular sensor data
// That is a mistake which we are rectifying but in the meantime we don't want data captured from those methods to be synced
// to mongo
if getDataType(c.methodName) == v1.DataType_DATA_TYPE_BINARY_SENSOR || c.methodName == captureAllFromCamera {
if msg.Type != CaptureTypeTabular {
return
}

s := msg.GetStruct()
s := msg.TabularData.Payload
if s == nil {
return
}
Expand All @@ -600,9 +595,9 @@ func (c *collector) maybeWriteToMongo(msg *v1.SensorData) {
return
}

td := TabularData{
TimeRequested: msg.Metadata.TimeRequested.AsTime(),
TimeReceived: msg.Metadata.TimeReceived.AsTime(),
td := TabularDataBson{
TimeRequested: msg.TimeRequested,
TimeReceived: msg.TimeReceived,
ComponentName: c.componentName,
ComponentType: c.componentType,
MethodName: c.methodName,
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,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.357
go.viam.com/api v0.1.360
go.viam.com/test v1.2.3
go.viam.com/utils v0.1.112
goji.io v2.0.2+incompatible
Expand Down Expand Up @@ -450,5 +450,3 @@ require (
github.com/ziutek/mymysql v1.5.4 // indirect
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
)

replace go.viam.com/api => /Users/nicksanford/code/api
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,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.360 h1:jpcm7mxUy2RvmZGAjUpx6RP+/8341XdlRLSX/3mll0g=
go.viam.com/api v0.1.360/go.mod h1:g5eipXHNm0rQmW7DWya6avKcmzoypLmxnMlAaIsE5Ls=
go.viam.com/test v1.2.3 h1:tT2QqthC2BL2tiloUC2T1AIwuLILyMRx8mmxunN+cT4=
go.viam.com/test v1.2.3/go.mod h1:5pXMnEyvTygilOCaFtonnKNMqsCCBbe2ZXU8ZsJ2zjY=
go.viam.com/utils v0.1.112 h1:yuVkNITUijdP/CMI3BaDozUMZwP4Ari57BvRQfORFK0=
Expand Down

0 comments on commit 90109b1

Please sign in to comment.