Skip to content

Conversation

stuqdog
Copy link
Member

@stuqdog stuqdog commented Aug 7, 2023

Major changes

Create BinaryData and TabularData types to encompass all meaningful data/metadata from associated calls

Minor changes

Some small refactors to tests

@stuqdog stuqdog requested review from njooma and a user August 7, 2023 16:58
@stuqdog stuqdog requested a review from a team as a code owner August 7, 2023 16:58
@stuqdog stuqdog requested a review from jckras August 7, 2023 16:58
await stream.send_message(TabularDataByFilterResponse(data=[TabularData(data=struct) for struct in tabular_structs]))
tabular_structs = []
tabular_metadata = [data.metadata for data in self.tabular_response]
for idx, tabular_data in enumerate(self.tabular_response):
Copy link
Member Author

Choose a reason for hiding this comment

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

I opted against a list comprehension here because I thought it was a bit cluttered and awkward to read. Not a strong preference; happy to revert to a list comprehension if others prefer it.

`ViamClient`.
"""

class TabularData:
Copy link
Member Author

Choose a reason for hiding this comment

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

Returning the actual proto type for tabular data requests seemed like a bad idea because it's awkward to navigate and has a struct (which we wanted to get rid of. But, time_requested and time_received are their own fields, and I thought returning a 4ple would be super ugly. So, I created a class to represent meaningful tabular data, and created an analogous class for binary data for consistency's sake.

Happy to revisit the type question if there's pushback against creating these shadow classes.

await stream.send_message(TabularDataByFilterResponse(data=[TabularData(data=struct) for struct in tabular_response_structs]))
tabular_response_structs = []
tabular_metadata = [data.metadata for data in self.tabular_response]
for idx, tabular_data in enumerate(self.tabular_response):
Copy link
Member Author

Choose a reason for hiding this comment

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

see above comment re: use of list comprehension here.

NANOS_END = 0
START_TS = Timestamp(seconds=SECONDS_START, nanos=NANOS_START)
END_TS = Timestamp(seconds=SECONDS_END, nanos=NANOS_END)
START_DATETIME = START_TS.ToDatetime()
Copy link
Member Author

Choose a reason for hiding this comment

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

(flyby) I liked the idea of programmatically showing that START_DATETIME and START_TS are equivalent.

TAGS = ["tag"]
BBOX_LABELS = ["bbox_label"]
FILTER = Filter(
FILTER = DataClient.create_filter(
Copy link
Member Author

Choose a reason for hiding this comment

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

(flyby) we both had a hardcoded filter here and - in one method below - a filter created via create_filter. this seemed redundant so I moved to a default of only using a single filter that is created via our helper method.

self.tabular_data_requested = False
self.tabular_response = [{"PowerPct": 0, "IsPowered": False}, {"PowerPct": 0, "IsPowered": False}, {"Position": 0}]
self.tabular_response = [
DataClient.TabularData(
Copy link
Member

Choose a reason for hiding this comment

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

(q) In general, what is the "data" being collected? Any data the robot is giving? And what is binary data vs tabular data?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great question! The data is currently just all data being collected/stored by the robot in app. I don't think I could give a very good answer on the differences between binary and tabular data. I think tabular is going to be mapped data in a lot of ways (e.g., a mapping of function call to output), while binary data is data that's just stored as bytes (e.g., raw files, or a photo). The data team could definitely give a better answer though!

time_received=datetime_to_timestamp(tabular_data.time_received)
)
)
await stream.send_message(TabularDataByFilterResponse(
Copy link
Member

Choose a reason for hiding this comment

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

(q) Where is this message being sent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question! The message is being sent back along the channel where the request was sent, so basically back to the calling client.

Copy link
Member

@jckras jckras left a comment

Choose a reason for hiding this comment

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

Added questions for my own understanding but lgtm

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Thank you for your help on this!

@stuqdog stuqdog requested a review from a user August 7, 2023 19:12
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

lgtm!

@stuqdog stuqdog merged commit 73f91d4 into viamrobotics:main Aug 8, 2023
@stuqdog stuqdog deleted the include-data-request-metadata branch August 8, 2023 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants