-
Notifications
You must be signed in to change notification settings - Fork 54
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-9503 accept bson queries in MQL function #803
Merged
purplenicole730
merged 18 commits into
viamrobotics:main
from
purplenicole730:RSDK-9503-accept-bson-queries
Dec 20, 2024
Merged
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
44b6880
accept dictionary in mql function
purplenicole730 279049c
change comment
purplenicole730 59b6495
make lint
purplenicole730 fdc3de0
make queries a list of dictionaries
purplenicole730 e3367a3
explicitly type check
purplenicole730 c661368
explicitly state that mqlbinary is a list of bytes
purplenicole730 d0ea253
test with list
purplenicole730 c4014d9
more type checking for lint
purplenicole730 b5fb8f2
more excessive checking for the type checker
purplenicole730 a493936
remove unnccessary annotation
purplenicole730 f74d801
ignore lint
purplenicole730 7fa1b4e
ignore type
purplenicole730 f7d466b
add alias param
purplenicole730 d869456
move decorator outside of class
purplenicole730 2b67023
use query if both query and binary are given
purplenicole730 7fdb051
broaden comment
purplenicole730 fd316a1
change param type to use any
purplenicole730 c615944
move general command to utils
purplenicole730 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
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.
The parameter name change from
mql_binary
tomql_query
is questionable. Even though we only want to accept queries, we wanted to make a union so that it wasn't a breaking change yet. Changing the name, however, is a breaking change to any user using named parameters, so one could argue we might as well change the input type completely now.On the other hand, leaving it as
mql_binary
is now incorrect, and might push users to keep using bytes when we don't want that.Fine with keeping or changing the parameter name, as long as it's in the direction we want the SDK to go.
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.
Hmm... I think we definitely want this to not be breaking. This functionality has been around in python long enough - and python is well used enough - that it seems highly likely that we would in fact break someone's workflow.
One option is, we could make a decorator that allows for argument aliasing. Then we can change the name, but set
mql_binary
as an accepted alias for backwards compatibility. Something like the following (cribbed from https://stackoverflow.com/questions/41784308/keyword-arguments-aliases-in-python)Then, we'd define the function like so:
After that, we should be providing support for the query as an unnamed param, a
mql_queries
named param, and amql_binary
named param.This has a nice property of being applicable in the future if we need to change param names. I do think we should underscore-prefix the decorator name to try and keep it private and write some documentation that provides clarification to future developers about the intended use case.
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.
One thing to note: the above isn't a perfect solution. For one, the code block I provided doesn't prevent a user from specifying both argument names (i.e., one could write
tabular_data_by_mql(mql_queries=<queries>, mql_binary=<binary>)
and this would be allowed). And, it's technically preferencing the alias, so if I did provide both args it would choose the binary, not the query. This isn't great because we want the official name to bequery
.I think these are definitely both fixable, but we'll want to play around with the decorator code and make sure it behaves properly.