Skip to content

Conversation

@stuqdog
Copy link
Member

@stuqdog stuqdog commented Mar 15, 2024

No description provided.

@stuqdog stuqdog requested a review from acmorrow March 15, 2024 12:36
@stuqdog stuqdog requested a review from a team as a code owner March 15, 2024 12:36
@stuqdog stuqdog requested review from njooma and purplenicole730 and removed request for a team March 15, 2024 12:36
Copy link
Member

@acmorrow acmorrow left a comment

Choose a reason for hiding this comment

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

If you want to keep this to pure code motion to limit scope then LGTM. If you are willing to put a few more minutes into it, I think it'd be nice to see a doc comment, and maybe bikeshed the name of the function? I'm a little unclear on what it is intended to do.

/// @brief Return the resource's name.
virtual std::string name() const;

std::vector<Name> resource_names() const;
Copy link
Member

Choose a reason for hiding this comment

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

Let's please add a doc comment for this while we are moving it.

Also, is resource_names the best name for this method? I'm actually a little unclear on what the meaning of the returned names is. It seems to be all the registered models that share the same API as this resource?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done! Though, it appears the only place this method is ever used is on a private method in RobotService. I wonder if it might make sense to just have this be a private method and make RobotService a friend class?

for (const auto& key_and_val : resource_manager()->resources()) {
for (const Name& resource : resource_names_for_resource(key_and_val.second)) {
metadata.push_back(resource.to_proto());
for (const Name& name : key_and_val.second->registered_models()) {
Copy link
Member

Choose a reason for hiding this comment

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

If this is really the only usage of registered_models, I'd suggest just moving the function into this file in the unnamed namespace and changing it to take a const Resource&

Copy link
Member

@acmorrow acmorrow left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@purplenicole730 purplenicole730 left a comment

Choose a reason for hiding this comment

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

Looks good! 😁

@stuqdog stuqdog merged commit 6772df2 into viamrobotics:main Mar 18, 2024
@stuqdog stuqdog deleted the methodize-resource-names-for-resource branch March 18, 2024 13:37
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.

3 participants