Python Codelets in Subgraphs

While reading through the Isaac SDK documentation, there seems to be several ways to build Python scripts with Bazel:

Both seem to generate apps that can be run from the command line, and am curious what the differences are betwen the two. More importantly, however, I would like to use a Python codelet in a subgraph that I am creating, but have not found any examples of this, specifically in terms of the BUILD file. Any guidance in this area would be greatly appreciated. Thank you!

The isaac_py_app is actually just a Bazel macro which creates the same targets: a py_binary target with the same name and a corresponding isaac_pkg target with name (name+"-pkg") for you.

In order to use a Python codelet with other codelets, you should be able to use the py_binary target for the codelet, other isaac_cc_module targets for C++ codelets perhaps, and an isaac_app which refers to all of the modules and provides an app json file for your application. isaac_app is a macro that produces a an isaac_pkg target as well with all of the dependent module targets of all types.

We’ll make a note of adding a tutorial for mixed language codelets in a single app.

1 Like

@hemals that’s a helpful first step, and I’ll investigate.

I think what is confusing to me in terms of using Python is, in the example applications I have seen that use Python codelets, the app.json file does not actually list the Python-defined components. Instead, the node is listed in the app.json file with a MessageLedger type component, and then in the main() function of the Python script, you load the app.json file with the Application() function, and then add the Python component and any corresponding edges in separate commands. An example from the app I am building:

def main():
app = Application(
“packages/centernet/warehouse_forklift.app.json”)
app.nodes[“detections_decoder”].add(DecodeCenternet)
app.connect(‘centernet_inference.subgraph/interface’, ‘detections’,
‘detections_decoder/PyCodelet’, ‘dets_input’)
app.connect(‘simulation.interface/output’, ‘color’,
‘detections_decoder/PyCodelet’, ‘img_input’)
app.connect(‘detections_decoder/PyCodelet’, ‘img_output’,
‘viewer/image_viewer’, ‘image’)
app.run()

So if I am using the py_binary target and listing it as a module in my app.json and BUILD files, I have no reference as to how to define my Python codelet component within the app.json file (CPP codelets have namespaces preceding it, e.g. isaac::package_name::codelet_name). For the example above, instead of using the Python codelet in the subgraph, I’ve opted to move it outside the subgraph and into the application that uses the subgraph as a temporary solution, but eventually I’d like to have it all contained within the subgraph.

@harrisonchen I’m facing the same problem. Do you mind sharing your temporary solution?

Sorry, I don’t have any good solutions at the moment - I just moved the Python nodes to my main application instead of keeping it in my subgraph, and there are tutorials in the documentations that show you how to do that. If I investigate it further and find a solution, I’ll share it here.

2 Likes