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

[APP-5754] Python GetFragmentHistory SDK changes #701

Merged
merged 7 commits into from
Aug 16, 2024
Merged

Conversation

piokasar
Copy link
Member

@piokasar piokasar commented Aug 2, 2024

going to re-request when checks pass, requests got added immediately

@piokasar piokasar requested a review from a team as a code owner August 2, 2024 19:19
@piokasar piokasar requested review from stuqdog and lia-viam and removed request for stuqdog and lia-viam August 2, 2024 19:19
Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

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

Generally looks good! A couple small things, and we'll want to make sure tests pass before we try to merge this.

Out of curiosity, why all the unrelated formatting changes? Was this something your editor did automatically?

Edit: oh I see you removed me from review until tests pass! Let me know if/when I should come back to look.

src/viam/app/app_client.py Outdated Show resolved Hide resolved
src/viam/app/app_client.py Outdated Show resolved Hide resolved
@piokasar
Copy link
Member Author

piokasar commented Aug 5, 2024

Generally looks good! A couple small things, and we'll want to make sure tests pass before we try to merge this.

Out of curiosity, why all the unrelated formatting changes? Was this something your editor did automatically?

Edit: oh I see you removed me from review until tests pass! Let me know if/when I should come back to look.

thanks for looking anyways! I will re-request shortly

Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

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

Generally looks good! Just some small suggestions and removing unneeded files from the commit.

.idea/.gitignore Outdated
Copy link
Member

Choose a reason for hiding this comment

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

I think the .idea folder should probably not be checked in. Looks like it's pycharm specific? I'd suggest backing these files out and then adding .idea/ to the .gitignore, or (ideally) to your own personal .gitignore (see https://stackoverflow.com/questions/7335420/global-git-ignore)

src/viam/app/app_client.py Outdated Show resolved Hide resolved
src/viam/app/app_client.py Outdated Show resolved Hide resolved
src/viam/app/app_client.py Outdated Show resolved Hide resolved
tests/package.json Outdated Show resolved Hide resolved
tests/mocks/services.py Show resolved Hide resolved
tests/test_app_client.py Outdated Show resolved Hide resolved
tests/test_app_client.py Outdated Show resolved Hide resolved
tests/test_app_client.py Outdated Show resolved Hide resolved
tests/test_app_client.py Show resolved Hide resolved
@piokasar piokasar force-pushed the get-frag-history branch 3 times, most recently from 85b34f4 to c133d3e Compare August 6, 2024 17:28
@piokasar piokasar force-pushed the get-frag-history branch 2 times, most recently from bdb622b to 5847dd1 Compare August 6, 2024 17:41
@@ -1173,6 +1174,9 @@ def __init__(
available: bool,
location_auth: LocationAuth,
robot_part_history: List[RobotPartHistoryEntry],
fragment_history: List[FragmentHistoryEntry],
page_token: str,
Copy link
Member Author

Choose a reason for hiding this comment

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

in the proto these are optional - should they be optional here as well ?

Copy link
Member

Choose a reason for hiding this comment

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

I actually think we shouldn't make this a default part of the class at all. Currently we're setting them to our sentinel values when we create the service, and then passing those same sentinel values when we call the get_fragment_history method in the test, and then confirming that they're set to the sentinel value. But, because there's two places where the setting happens, we don't have confidence that the test actually did anything.

What I'd suggest instead is just removing these as arguments or set values in the constructor, such that they don't exist in general. Then, we can leave everything else as it is such that the GetFragmentHistory method sets these values, and then we can meaningfully confirm that they're properly set in the test_get_fragment_history test.

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 got rid of page_token and page_limit but I kept fragment_history because that was the return value - does that make sense ? Apologies if I'm misunderstanding.

@piokasar piokasar requested a review from stuqdog August 6, 2024 17:59
Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

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

Looking good! One small requested change to the MockApp class, otherwise lgtm :)

@@ -1173,6 +1174,9 @@ def __init__(
available: bool,
location_auth: LocationAuth,
robot_part_history: List[RobotPartHistoryEntry],
fragment_history: List[FragmentHistoryEntry],
page_token: str,
Copy link
Member

Choose a reason for hiding this comment

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

I actually think we shouldn't make this a default part of the class at all. Currently we're setting them to our sentinel values when we create the service, and then passing those same sentinel values when we call the get_fragment_history method in the test, and then confirming that they're set to the sentinel value. But, because there's two places where the setting happens, we don't have confidence that the test actually did anything.

What I'd suggest instead is just removing these as arguments or set values in the constructor, such that they don't exist in general. Then, we can leave everything else as it is such that the GetFragmentHistory method sets these values, and then we can meaningfully confirm that they're properly set in the test_get_fragment_history test.

@@ -1184,6 +1188,7 @@ def __init__(
items: List[RegistryItem],
package_type: PackageType.ValueType,
):
self.page_token = None
Copy link
Member

Choose a reason for hiding this comment

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

per above comment, this should be deleted

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'm not sure I'm understanding "such that they don't exist in general", but I ended up keeping them but setting to default values because when GetFragmentHistory tried to access them, the class attributes did not exist which gave me errors. Then in GetFragmentHistory, they were set based on the values in the request - it seems like this addressed your concern of setting twice, but if there's a more appropriate way to do this let me know!

Copy link
Member

Choose a reason for hiding this comment

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

Curious what you mean by "tried to access them"? You should be able to just set to them (i.e., self.some_fake_value = "this is a fake value that wasn't defined prior!" should work with no issues), but if you tried to access the value with foo = self.some_other_fake_value_that_has_not_been_defined then yeah, I'd expect that to fail.

@piokasar piokasar requested a review from stuqdog August 13, 2024 19:57
Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

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

I still think we can remove the default definitions for page_token and page_limit but there's no major harm in including them so I totally understand if you'd rather just be done with the ticket. Otherwise, lgtm!

Comment on lines 1201 to 1202
self.page_token = ""
self.page_limit = 0
Copy link
Member

Choose a reason for hiding this comment

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

(minor, opt) I'm pretty sure these aren't necessary/slightly surprised to hear you say you had errors if they weren't included. You should be able to delete them, see e.g. how self.public is set in the UpdateFragment method, despite no public field ever being defined prior.

That said, it's pretty harmless to have this here so it's not a big deal if you don't want to bother figuring out how to remove them.

Copy link
Member Author

Choose a reason for hiding this comment

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

By access, I guess meant "set". But it must have been unrelated because I was able to get rid of those default values successfully, so thank you!
Once tests pass I will merge- thank you for your help on this!!

@@ -1184,6 +1188,7 @@ def __init__(
items: List[RegistryItem],
package_type: PackageType.ValueType,
):
self.page_token = None
Copy link
Member

Choose a reason for hiding this comment

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

Curious what you mean by "tried to access them"? You should be able to just set to them (i.e., self.some_fake_value = "this is a fake value that wasn't defined prior!" should work with no issues), but if you tried to access the value with foo = self.some_other_fake_value_that_has_not_been_defined then yeah, I'd expect that to fail.

@piokasar piokasar merged commit 068a292 into main Aug 16, 2024
12 checks passed
@piokasar piokasar deleted the get-frag-history branch August 16, 2024 14:46
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.

2 participants