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-4522 RSDK-3601 Add complex module example #150

Merged
merged 24 commits into from
Oct 3, 2023

Conversation

benjirewis
Copy link
Member

@benjirewis benjirewis commented Sep 19, 2023

RSDK-4522
RSDK-3601

Adds a complex module example (based on the Python and Go implementations). Validates that dependencies exist in the ModuleService.

Copy link
Member Author

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

This complex module still doesn't work: the gRPC services for gizmo and summation don't seem to get added to the generated pool. I'm looking into why that is, but I thought it might be good to get some review on everything else in the meantime (I don't think much will change).

src/viam/examples/modules/complex/base/impl.hpp Outdated Show resolved Hide resolved
src/viam/examples/modules/complex/proto/buf.gen.yaml Outdated Show resolved Hide resolved
src/viam/examples/modules/simple/main.cpp Show resolved Hide resolved
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.

nice, looking pretty good! thanks for putting this together.

src/viam/examples/modules/complex/summation/api.cpp Outdated Show resolved Hide resolved
src/viam/examples/modules/complex/README.md Outdated Show resolved Hide resolved
src/viam/examples/modules/complex/base/impl.cpp Outdated Show resolved Hide resolved
src/viam/examples/modules/complex/summation/api.cpp Outdated Show resolved Hide resolved
src/viam/examples/modules/complex/summation/api.cpp Outdated Show resolved Hide resolved
src/viam/examples/modules/complex/summation/api.hpp Outdated Show resolved Hide resolved
src/viam/examples/modules/complex/summation/impl.cpp Outdated Show resolved Hide resolved
@cheukt
Copy link
Member

cheukt commented Sep 21, 2023

can you add links out to the example module repos like in #152?

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.

I'm not jumping into the review of the new complex module and client, but please lmk if you would like me to.

src/viam/examples/modules/complex/CMakeLists.txt Outdated Show resolved Hide resolved
src/viam/examples/modules/complex/proto/buf.gen.yaml Outdated Show resolved Hide resolved
src/viam/examples/modules/complex/CMakeLists.txt Outdated Show resolved Hide resolved
src/viam/sdk/module/service.cpp Outdated Show resolved Hide resolved
src/viam/sdk/module/service.cpp Outdated Show resolved Hide resolved
@acmorrow
Copy link
Member

@benjirewis - I know there was some discussion about making the example modules standalone projects embedded within this repo, much like the example projects are today. I'd suggest for that to happen in another ticket / review rather than this one.

@benjirewis
Copy link
Member Author

@cheukt added a reference similar to the ones you added in #152 for the complex module (thanks for adding those other ones).

@acmorrow filed https://viam.atlassian.net/browse/RSDK-5131. I won't do that work as part of this PR.

@acmorrow
Copy link
Member

@benjirewis - Do you think it might be possible to pull the fix for https://viam.atlassian.net/browse/RSDK-4275 out into its own PR, which I would immediately LGTM, in the interest of getting that fix committed? It's just the two try/catch things around construct_resource but it fixes a big ergonomic headache when working with modules implemented in C++, since the status quo is that if you make any mistake in the module configuration you get failure but no actionable details.

@benjirewis
Copy link
Member Author

benjirewis commented Sep 25, 2023

@acmorrow yeah I can do that right now. Apologies for the delay on this PR, lots of small obstacles 😮‍💨 . #154 .

@benjirewis benjirewis changed the title RSDK-4522 RSDK-4275 RSDK-3601 Add complex module example RSDK-4522 RSDK-3601 Add complex module example Sep 25, 2023
Copy link
Member Author

@benjirewis benjirewis 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 need to write test_module.cpp, but gRPC service descriptors are now working properly. I'll move this out of draft, and it's ready for another review.

src/viam/examples/modules/complex/main.cpp Show resolved Hide resolved
@benjirewis benjirewis requested a review from acmorrow September 28, 2023 20:41
@benjirewis benjirewis marked this pull request as ready for review September 28, 2023 20:41
@benjirewis benjirewis requested a review from a team as a code owner September 28, 2023 20:41
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.

This LGTM for the build system changes for the complex module example, and for the other SDK changes outside the examples. I'll leave the specifics of the complex example implementation to others.

src/viam/sdk/common/utils.cpp Outdated Show resolved Hide resolved
src/viam/sdk/common/utils.cpp Outdated Show resolved Hide resolved
@benjirewis
Copy link
Member Author

benjirewis commented Oct 2, 2023

@stuqdog Adding tests is not super trivial (having some issues linking the generated protobuf files into the existing test suite architecture). If you don't mind I'm gonna kick out that work into another ticket/PR (https://viam.atlassian.net/browse/RSDK-5226). Per @cheukt's suggestion, I tested the custom base, gizmo and summation with the Python complex module client, and everything seems to be working.

@benjirewis benjirewis requested a review from stuqdog October 2, 2023 16:25
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.

Thanks for the work on this! A couple minor things, but in general this is looking great!

file(CHMOD ${BUF_COMMAND} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
endif()

# Buf only goes back to 1.41.1 for generation against their "custom remote"
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 suspect this comment was copy pasted from the top level CMakeLists.txt? I think it's a bit out of date at this point. Buf no longer supports remote generation and so we no longer make distinctions between "before 1.41.1" and "between 1.41.1 and 1.51".

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah thanks for that background; I did indeed copy this from the top level CMakeLists.txt. I've removed the comment, but are you saying that I don't even need two different buf.yaml files, as remote generation is not a thing anymore?

Copy link
Member

Choose a reason for hiding this comment

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

No, you still need two forms. In the past there were three required forms, and this comment was sort of trying to explain why. But we are now down to two forms. So, just remove the comment.

Eventually, we should DRY this logic with src/viam/api/CMakeLists.txt by moving buf-based proto generation support into a tool. That tool should be installed as part of the SDK, so that clients of the SDK can make use of it for their own proto generation needs. That'd be more or less forced by making the modules standalone projects anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice; copied your comment to https://viam.atlassian.net/browse/RSDK-5131.

src/viam/examples/modules/complex/client.cpp Outdated Show resolved Hide resolved
src/viam/examples/modules/complex/gizmo/api.hpp Outdated Show resolved Hide resolved
@benjirewis benjirewis requested a review from stuqdog October 3, 2023 16: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.

lgtm!

Copy link
Member

@cheukt cheukt left a comment

Choose a reason for hiding this comment

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

LGTM

@benjirewis benjirewis merged commit 10f6b74 into viamrobotics:main Oct 3, 2023
2 checks passed
@benjirewis benjirewis deleted the complex-module branch October 3, 2023 20:16
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.

4 participants