-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add ability to specify port data type for known c++ types from Python #153
Conversation
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 great new feature and looking really good. Have a few suggestions and I think we can cleanup some pieces by using type information thats already there.
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.
Once CI is passing this looks good to merge
@gpucibot merge |
…tructor (#165) If you create a source or a sink class that derives from `PythonSink`, `PythonSource` or `PythonNode` and the message type does not have a default constructor, you will run into a compilation error. This was due to the fact that the new Port auto registration added in PR #153 tries to compile ingress/egress ports for both `T` and `shared_ptr<T>`. This PR adds a check to skip compiling a port with `T` if `T` does not have a default constructor. Authors: - Michael Demoret (https://github.com/mdemoret-nv) Approvers: - Devin Robison (https://github.com/drobison00) URL: #165
TODO: still need to add additional unit tests, and update to support a 3rd tuple parameter indicating if the raw data type or shared pointer should be used as the underlying node data type.
This will make a number of non-breaking changes to the process of Ingress and Egress port creation via Python.
Implements @mdemoret-nv 's changes to remove the need for specifying Ingress and Egress port data types during construction, and instead shifts to a system of providing lambda functions that create the appropriate derived object and return a common un-templated base; this results in a much more flexible, cleaner, interface and eliminates any hard cap on the number of ports that can be created on a segment from Python.
Extends previous updates to support python bindings for ingress/egress port creation to support either simple strings, or for specifying a string + pybind11 registered type tuple.
pipeline.make_segment("name", ["a", "b", "c"], [], init)
pipleine.make_segment("name", [("a", my_type), ("b", another_type), "c"]
Internally, the "simple string" case, will result in Ingress/Egress nodes with
PyHolder
date types; which can be inefficient, and require multiple edge converters when connected to pure c++ (non-python) data types. With the newly supported syntax, providing a pybind11 registered type will result in an attempt to lookup the associated (wrapped) cpptype and create an Ingress or Egress port using that type.PortUtil
class. The port registry stores a map from std::type_index to PortUtil, and PortUtil provides a number of helper functions for creating, casting, and manipulating Ingress and Egress ports.