-
Notifications
You must be signed in to change notification settings - Fork 56
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
Data-3395: Add GetLatestTabularData #793
Merged
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4ba4d82
add GetLatestTabularData endpoint to python sdk
gloriacai01 d6b1d80
add subtype
gloriacai01 edcb84e
Revert "add subtype"
gloriacai01 fb08219
add subtype fr
gloriacai01 2b0ebdc
please
gloriacai01 7381d18
make entire tuple optional
gloriacai01 fc11aa6
Merge remote-tracking branch 'upstream/main' into data-3395
gloriacai01 6112e35
update return comment
gloriacai01 488806e
lint
gloriacai01 9b57826
update return comment
gloriacai01 989d95c
what is going on
gloriacai01 9538838
fix
gloriacai01 314e617
pr comments
gloriacai01 db4e448
change order in comment
gloriacai01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,8 @@ | |
Filter, | ||
GetDatabaseConnectionRequest, | ||
GetDatabaseConnectionResponse, | ||
GetLatestTabularDataRequest, | ||
GetLatestTabularDataResponse, | ||
Order, | ||
RemoveBinaryDataFromDatasetByIDsRequest, | ||
RemoveBoundingBoxFromImageByIDRequest, | ||
|
@@ -306,6 +308,40 @@ async def tabular_data_by_mql(self, organization_id: str, mql_binary: List[bytes | |
response: TabularDataByMQLResponse = await self._data_client.TabularDataByMQL(request, metadata=self._metadata) | ||
return [bson.decode(bson_bytes) for bson_bytes in response.raw_data] | ||
|
||
async def get_latest_tabular_data(self, part_id: str, resource_name: str, resource_subtype: str, method_name: str) -> Optional[Tuple[datetime,datetime, Dict[str, ValueTypes]]]: | ||
"""Gets the most recent tabular data captured from the specified data source, as long as it was synced within the last year. | ||
|
||
:: | ||
|
||
time_captured, time_synced, payload = await data_client.get_latest_tabular_data( | ||
part_id="<PART-ID>", | ||
resource_name="<RESOURCE-NAME>", | ||
kaywux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
resource_subtype="<RESOURCE-SUBTYPE>", | ||
method_name="<METHOD-NAME>" | ||
) | ||
|
||
|
||
Args: | ||
part_id (str): The ID of the part that owns the data. | ||
resource_name (str): The name of the requested resource that captured the data. | ||
resource_subtype (str): The subtype of the requested resource that captured the data. | ||
method_name (str): The data capture method name. | ||
|
||
Returns: | ||
Optional[Tuple[Dict[str, ValueTypes], datetime, datetime]: A tuple which is None data hasn't been synced yet for the data source, otherwise the tuple contains the following: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reorder this tuple to be the actual return order |
||
datetime: The time captured, | ||
datetime: The time synced, | ||
Dict[str, ValueTypes]: The latest tabular data captured from the specified data source. | ||
For more information, see `Data Client API <https://docs.viam.com/appendix/apis/data-client/>`_. | ||
""" | ||
|
||
request = GetLatestTabularDataRequest(part_id=part_id, resource_name=resource_name, resource_subtype=resource_subtype, method_name=method_name) | ||
response: GetLatestTabularDataResponse = await self._data_client.GetLatestTabularData(request, metadata=self._metadata) | ||
if not response.payload: | ||
return None | ||
return response.time_captured.ToDatetime(), response.time_synced.ToDatetime(), struct_to_dict(response.payload) | ||
|
||
|
||
async def binary_data_by_filter( | ||
self, | ||
filter: Optional[Filter] = None, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = "0.34.0" | ||
|
||
API_VERSION = "v0.1.361" | ||
API_VERSION = "v0.1.366" | ||
SDK_VERSION = __version__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,6 +203,8 @@ | |
DeleteTabularDataResponse, | ||
GetDatabaseConnectionRequest, | ||
GetDatabaseConnectionResponse, | ||
GetLatestTabularDataRequest, | ||
GetLatestTabularDataResponse, | ||
RemoveBinaryDataFromDatasetByIDsRequest, | ||
RemoveBinaryDataFromDatasetByIDsResponse, | ||
RemoveBoundingBoxFromImageByIDRequest, | ||
|
@@ -1001,6 +1003,18 @@ async def TabularDataByMQL(self, stream: Stream[TabularDataByMQLRequest, Tabular | |
assert request is not None | ||
await stream.send_message(TabularDataByMQLResponse(raw_data=[bson.encode(dict) for dict in self.tabular_query_response])) | ||
|
||
async def GetLatestTabularData(self, stream: Stream[GetLatestTabularDataRequest, GetLatestTabularDataResponse]) -> None: | ||
request = await stream.recv_message() | ||
assert request is not None | ||
self.part_id = request.part_id | ||
self.resource_name = request.resource_name | ||
self.resource_subtype = request.resource_subtype | ||
self.method_name = request.method_name | ||
timestamp = datetime_to_timestamp(datetime(2024, 12, 25)) | ||
data=dict_to_struct(self.tabular_response[0].data) | ||
await stream.send_message(GetLatestTabularDataResponse(payload=data, time_captured=timestamp, time_synced=timestamp)) | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect this is one too many new lines added |
||
|
||
class MockDataset(DatasetServiceBase): | ||
def __init__(self, create_response: str, datasets_response: Sequence[Dataset]): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just a simple whitespace thing