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

RSDK-2870: use api instead of subtype #824

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

purplenicole730
Copy link
Member

@purplenicole730 purplenicole730 commented Jan 21, 2025

  • changes all references in the Python SDK that use the word subtype when actually referring to the API triplet (i.e. rdk:component:sensor)
    • this includes in comments, examples, variables, functions, and function parameters
  • uses aliases DataClient functions and has a deprecated comment in TabularDataPoint

Important

BREAKING CHANGES INTRODUCED IN THIS PR

  • the variable present in every resource called SUBTYPE is now API
  • Registry methods have been renamed or contain parameter name changes

Note for reviewers: I tried my best to go through all the uses of subtype that I could find. Because this is such a loosely used word, it was hard to figure out what was actually a subtype and what should be an API at times, which is the whole point of the change. I wouldn't be surprised if I missed something

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_properties
mlmodel metadata
slam get_point_cloud_map

@purplenicole730 purplenicole730 marked this pull request as ready for review January 22, 2025 18:44
@purplenicole730 purplenicole730 requested a review from a team as a code owner January 22, 2025 18:44
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 definitely think we should revisit whether all these changes need to be breaking and how to avoid breaking when it's easy to do so. Otherwise, this all looks good to me!

src/viam/app/data_client.py Show resolved Hide resolved
@@ -83,7 +83,7 @@ async def handle_task_result(self, task: asyncio.Task):

def emit(self, record: logging.LogRecord):
assert isinstance(record, logging.LogRecord)
# Fully qualified name of form "{subtype triplet}/{name}", e.g. "rdk:component:arm/myarm"
# Fully qualified name of form "{API}/{name}", e.g. "rdk:component:arm/myarm"
Copy link
Member

Choose a reason for hiding this comment

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

(minor, q) curious why you got rid of "triplet" here? Not a big deal either way, but I think it might be helpful to keep since the way we're using API is a bit of a term of art.

Copy link
Member Author

Choose a reason for hiding this comment

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

There was no real reason to get rid of the word "triplet". In other comments, it's referred to simply as API so it was what I did automatically. I can add it back no problem!

src/viam/app/data_client.py Show resolved Hide resolved
Comment on lines 161 to 165
resource_subtype: str
"""
deprecated; use `resource_api`
The resource API. Ex: `rdk:component:sensor`
"""
Copy link
Member

Choose a reason for hiding this comment

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

(minor) I'd love for this to be a property instead, so people can't set it, it's impossible for it to ever drift from the value in resource_api, and so we can emit a deprecation warning on call instead of just including it in comments. Something like

@property
def resource_subtype(self) -> str:
    warnings.warn("<some deprecation warning>", DeprecationWarning, stacklevel=2)
    return self.resource_api

@@ -461,6 +469,7 @@ async def export_tabular_data(
DataClient.TabularDataPoint(
part_id=resp.part_id,
resource_name=resp.resource_name,
resource_subtype=resp.resource_subtype,
Copy link
Member

Choose a reason for hiding this comment

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

given above comment re: property decorator, I don't think we need to (or should) do this setting here.

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