Skip to content

DOCS-2199: Viam Python SDK correctness pass #591

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

Merged

Conversation

andf-viam
Copy link
Contributor

@andf-viam andf-viam commented Apr 22, 2024

First: This PR changes only code comments (that appear in Python SDK docs). No code was harmed in the making of this PR!

Fix straightforward correctness issues that are interfering with automated scraping, such as missing params or returns, formatting (mostly indents), etc. Common issues encountered; fixed:

  • Params with multiline descriptions must indent wrapped lines, fixed.
  • Returns with multiline descriptions must not indent wrapped lines, fixed.
  • Converted multi-item returns to single-item returns: they are all really single-item anyways -- 1 tuple -- and the multi-approach resulted in inconsistencies between usage syntax (at function def) and parameters (in dedicated Parameters (Args:) section).
  • Added some missing returns (but please double check my work!)
  • Corrected some incorrect return types (but please double check my work!)
  • Added missing data type (str) to delete_fragment.
  • Some quick typo fixes.
  • Moved code examples to be above params for few cases where observed.

NOTES / FURTHER ACTION:
Observed the following further inconsistencies that I cannot fix:

  • Motion service is missing a service.html page entirely (has: arm, mlmodel; 404: motion). Motion appears to be the only resource Viam-wide without one.
    • Perhaps relatedly, motion functions are all present in client.py file, also at odds with all other service resources, which use {servicename}.py for these method declarations.
  • Almost all resources omit explicitly including timeout or extra in Params list (Args:), but Motion includes them explicitly. Should Motion remove these explicit (inherited?) entries?

Thanks Team! Happy to chat or answer any questions; hit me up. Apologies if I guessed wrong on any data types! As always, I greatly appreciate your time!

@andf-viam andf-viam requested a review from a team as a code owner April 22, 2024 19:24
@andf-viam andf-viam requested review from njooma and stuqdog April 22, 2024 19:24
Copy link
Contributor

Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!

component function
base is_moving
board gpio_pin_by_name
camera get_image
encoder get_position
motor is_moving
sensor get_readings
servo get_position
arm get_end_position
gantry get_lengths
gripper is_moving
movement_sensor get_linear_acceleration
input_controller get_controls
audio get_properties
pose_tracker get_poses
power_sensor get_power
motion get_pose
vision get_classifications_from_camera

@@ -1370,7 +1370,7 @@ async def get_fragment(self, fragment_id: str) -> Fragment:
# Get a fragment and print its name and when it was created.
the_fragment = await cloud.get_fragment(
fragment_id="12a12ab1-1234-5678-abcd-abcd01234567")
print("Name: ", the_fragment.name, "\nCreated on: ", the_fragment.created_on)
print("Name: ", the_fragment.name, "\\nCreated on: ", the_fragment.created_on)
Copy link
Contributor Author

@andf-viam andf-viam Apr 23, 2024

Choose a reason for hiding this comment

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

Not sure if this works, is this how to escape newlines in code examples in autoapi? Alternatively, likely safe to remove the newline. As is it breaks formatting.

@stuqdog
Copy link
Member

stuqdog commented Apr 23, 2024

Almost all resources omit explicitly including timeout or extra in Params list (Args:), but Motion includes them explicitly. Should Motion remove these explicit (inherited?) entries?

Yes, I suspect that Motion should stop including extra and timeout in the docstring for consistency with the rest of the SDK. I'm not sure why it differs in this way; @njooma do you know?

Probably also we should have a motion.py that defines an abstract base class that the client inherits from, but that definitely seems outside of scope here.

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.

lgtm!

@andf-viam
Copy link
Contributor Author

@stuqdog thank so much! Mergin' in!

@andf-viam andf-viam merged commit d75ecfc into viamrobotics:main Apr 23, 2024
13 checks passed
@andf-viam andf-viam deleted the DOCS-2199-pysdk-correctness-pass branch April 23, 2024 17:33
njooma pushed a commit to njooma/viam-python-sdk that referenced this pull request Apr 24, 2024
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