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

Add GetLatestTabularData endpoint #593

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

gloriacai01
Copy link
Member

@gloriacai01 gloriacai01 commented Nov 15, 2024

Adds GetLatestTabularData rpc + associated request/response messages

@gloriacai01 gloriacai01 changed the title Add GetLatestTabularDataEndpoing Add GetLatestTabularDataEndpoint Nov 15, 2024
@github-actions github-actions bot added the safe to test committer is a member of this org label Nov 15, 2024
@gloriacai01 gloriacai01 added the ready-for-protos add this when you want protos to compile on every commit label Nov 15, 2024
@gloriacai01 gloriacai01 marked this pull request as ready for review November 15, 2024 19:34
@gloriacai01 gloriacai01 requested a review from kaywux November 15, 2024 19:40
Copy link
Contributor

@kaywux kaywux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this Gloria!

message GetLatestTabularDataResponse {
google.protobuf.Timestamp time_captured = 1;
google.protobuf.Timestamp time_synced = 2;
google.protobuf.Struct payload = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about the type we return here... perhaps we can return a byte array (so repeated bytes) instead of a Struct, similar to what we've done with the ByMQL/BySQL response type. This would allow for more expressive data types in the payload (for example, users would be able to interact with a returned date directly instead of first having to parse it from a string).

@dmhilly I know there was some discussion recently around the raw_data vs data return type for the ByQuery endpoints, what was the resolution on that? Okay to return a byte array here instead of a struct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I was thinking about this when I reviewed the scope too... my thought is that it's okay and preferred to return it as a protobuf.Struct, the reasoning being that to get it into Viam Cloud, it would have to have been uploaded as a protobuf.Struct. DataCaptureUpload takes 1+ SensorDatas, which each contains some metadata + either raw bytes or a protobuf.Struct, see here. If the mime_type in the request is tabular but the SensorData data does not contain a struct, we get an error here.

For TabularDataByMQL, the query is across both the data and the metadata, and since there are datetimes in the metadata (the timestamps), these fields (or any fields constructed by the query that aggregates/modifies/defines new fields) had the wrong data type. The query could also theoretically define other fields with BSON data types that are not expressible in proto.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks for that explanation - with all that in mind keeping this as a protobuf.Struct makes sense to me as well :)

string method_name = 3;
}

// GetLatestTabularDataResponse provides the data, time synced, and time captured of most recent tabular data captured from the requested data source.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a line in the comment here about how this will only return the latest data point if it was synced within the last year?

Copy link
Contributor

@kaywux kaywux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! One small request to rename the PR title to "Add GetLatestTabularData endpoint" instead :) and then good to go!

@gloriacai01 gloriacai01 changed the title Add GetLatestTabularDataEndpoint Add GetLatestTabularData endpoint Nov 19, 2024
@gloriacai01 gloriacai01 removed the ready-for-protos add this when you want protos to compile on every commit label Nov 19, 2024
@gloriacai01 gloriacai01 merged commit 35afbec into viamrobotics:main Nov 19, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
protos-compiled safe to test committer is a member of this org
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants