-
Notifications
You must be signed in to change notification settings - Fork 26
Move component client/server classes out of the API #215
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
Conversation
stuqdog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, this looks great! Definitely a fan of the new look.
| #include <viam/sdk/components/private/camera_client.hpp> | ||
| #include <viam/sdk/components/private/camera_server.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change especially if we want to keep this PR purely mechanical, but I suspect we can do away with these includes entirely (same in other mocks).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I want to understand whether tests / mocks actually require access to the concrete FooServer and FooClient types: it would be nice if they don't, because then we can actually not only make them "header private", by not installing the headers, but we can make those types have hidden visibility so they aren't even part of the symbol table for the SDK library.
Cool! I'll get this done for |
acmorrow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stuqdog - Updated, now services are handled the same way. I ran into one small issue with testing in the mlmodel stuff, so at least one more update is on the way. But please give this a look. I expect given that you were happy with the components changes that you will also be fine with the services changes. The only really interesting change in this review was changing how the mock pipeline stuff worked so it doesn't need to have access to the concrete client types.
src/viam/sdk/tests/test_utils.hpp
Outdated
| auto grpc_channel = test_server.grpc_in_process_channel(args); | ||
| ClientType resource_client(mock->name(), grpc_channel); | ||
|
|
||
| auto resource_client = Registry::lookup_resource_client(API::get<ClientType>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a non-mechanical change, so that tests no longer have a dependency on the concrete FooClient type. Instead of directly constructing ClientType, we ask the registry to do it for us, then downcast.
Potentially we should rename the ClientType template parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think ResourceType is probably better at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/viam/sdk/tests/test_mlmodel.cpp
Outdated
| #include <viam/sdk/services/mlmodel/client.hpp> | ||
| #include <viam/sdk/services/mlmodel/private/proto.hpp> | ||
| #include <viam/sdk/services/mlmodel/server.hpp> | ||
| #include <viam/sdk/services/private/proto.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs some thought: this test currently tests directly some internal proto to vocab conversions. I do want to keep testing that code as it is particularly tricky. I'll give it some thought, as there will probably be other places we need something like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm not quite following what the problem is here. Since it's not being exposed in a header or non-testing code, what is the harm of having this include?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests aren't part of the libviamsdk library. Eventually, the types and symbols under private won't even be exported from libviamsdk, so the tests won't be able to use them. Better to clean it up now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks for clarifying.
|
|
||
| #include <boost/test/included/unit_test.hpp> | ||
|
|
||
| #include <viam/api/common/v1/common.pb.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stripped lots of direct #include <viam/api where I could. There are still some in our public headers. We should strive to eliminate them all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just created a ticket for this.
| // limitations under the License. | ||
|
|
||
| #include <viam/sdk/services/mlmodel/private/proto.hpp> | ||
| #include <viam/sdk/services/private/proto.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file and the associated header should be renamed somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, would love to see the name change here before we land this PR, proto as a name is much too generic without the more qualified path. What about mlmodel_proto_conversions? It's a little wordy, but it's specific and hidden from users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed it to services/private/mlmodel.hpp
stuqdog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| // limitations under the License. | ||
|
|
||
| #include <viam/sdk/services/mlmodel/private/proto.hpp> | ||
| #include <viam/sdk/services/private/proto.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, would love to see the name change here before we land this PR, proto as a name is much too generic without the more qualified path. What about mlmodel_proto_conversions? It's a little wordy, but it's specific and hidden from users.
src/viam/sdk/tests/test_mlmodel.cpp
Outdated
| #include <viam/sdk/services/mlmodel/client.hpp> | ||
| #include <viam/sdk/services/mlmodel/private/proto.hpp> | ||
| #include <viam/sdk/services/mlmodel/server.hpp> | ||
| #include <viam/sdk/services/private/proto.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm not quite following what the problem is here. Since it's not being exposed in a header or non-testing code, what is the harm of having this include?
src/viam/sdk/tests/test_utils.hpp
Outdated
| auto grpc_channel = test_server.grpc_in_process_channel(args); | ||
| ClientType resource_client(mock->name(), grpc_channel); | ||
|
|
||
| auto resource_client = Registry::lookup_resource_client(API::get<ClientType>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think ResourceType is probably better at this point.
|
|
||
| #include <boost/test/included/unit_test.hpp> | ||
|
|
||
| #include <viam/api/common/v1/common.pb.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just created a ticket for this.
|
@stuqdog - This is ready for another round of review. Changes since last time:
|
|
All still looks good to me, thanks! |
I'm still working through the implications of this, particularly w.r.t. to mocks and testing, but this is the general idea:
sdk/components/x/x.htoskd/components/x.h.sdk/components/x/client.htosdk/components/private/x_client.h.sdk/components/x/server.htosdk/components/private/x_server.h.And then adjust
#include's as necessary.After this change, the
viam/sdk/componentsdirectory looks like this in the source directory:And like this in the installation directory (i.e.
$PREFIX/include/viam/sdk/components):If we like this approach, I'll do the same for
services. In hindsight I should have done that one first as there are fewer services than components, but oh well.