Introduction

The Intrepid AI Python SDK allows developers to interact with the Intrepid platform (graph and engine), enabling the creation and management of nodes, callbacks, and Quality of Service (QoS) policies.

This documentation provides a guide on how to use the Intrepid AI Python SDK to attach a callback function to an Intrepid execution graph.

Edit and preview

Installation

You can install the Intrepid AI Python SDK using pip:

pip install intrepid-sdk

Usage

Import Necessary Modules

from intrepid import Intrepid, Qos, Node, DataType

Define Callback Function

# Callback function to execute when inputs are ready
def my_callback_function(in1: int, in2:int) -> (float, bool):
    # Add code here
    time.sleep(0.2)
    return 1. * (in1 + in2), True

Create Quality of Service (QoS) Policy

Intrepid uses the same definition of QoS policies as defined by the Object Management Group (OMG) for the Data Distribution Service (DDS). For more information on QoS policies, you can refer to the OMG DDS documentation

# Create QoS policy for function node
qos = Qos(reliability="BestEffort", durability="TransientLocal")
qos.set_history("KeepLast")
qos.set_deadline(100)  # Deadline expressed in milliseconds

Create Node

A node in the Intrepid platform is a fundamental building block that represents a logical function, package, or module capable of performing computation on inputs and making results available on outputs. In the context of visual programming tools provided by Intrepid, a node is a block that users can drag and drop in the editor and connect with other nodes to create workflows or pipelines.

From a developer’s perspective, a node can be thought of as a container for custom logic implemented in Python, Rust, C/C++. Users who want to implement their own custom logic can create a node using Python, add their desired functionality, and publish it to the Intrepid graph. Once published, these custom nodes can be seamlessly integrated into the visual programming environment, allowing users to connect them with other nodes just like any other built-in node.

In summary, a node in Intrepid serves as a modular unit for encapsulating computational logic, enabling users to create custom functionalities and extend the capabilities of the platform’s visual programming tools.

An example node with 3 inputs and 3 outputs is provided below

# Create my node
mynode = Node("my_type")
mynode.add_input("flow", DataType.FLOW)
mynode.add_input("in1", DataType.INTEGER)
mynode.add_input("in2", DataType.INTEGER)
mynode.add_output("flow", DataType.FLOW)
mynode.add_output("out1", DataType.FLOAT)
mynode.add_output("is_float", DataType.BOOLEAN)

Register Node

Once a node has been created with its desired logic implemented, it must be registered with the Intrepid engine to become operational within the platform’s ecosystem. Registration involves associating the node with the Intrepid engine, enabling it to be recognized and utilized by other components of the system.

After registration, the user needs to attach a callback function to the node. This callback function defines the specific actions or computations the node will perform when inputs are received. The callback function typically takes input data, processes it, and generates output data accordingly.

Once the callback function is attached, the node is ready to start executing its logic. Starting the node initiates its operation within the Intrepid environment, allowing it to actively process inputs, execute the defined logic, and produce output data as per its functionality.

Below is an example demonstrating the process of registering, attaching a callback, and starting a node in Python using the Python SDK:

# Write to Graph
node_handler = Intrepid(node_id="node_type/node_id")
node_handler.register_node(mynode)

# Attach Qos policy to this node
node_handler.create_qos(qos)

Register Callback and Start Node

# Register callback with node input. Callback and node inputs must have the same signature (same number/name/type)
node_handler.register_callback(my_callback_function)

# Start server and node execution
node_handler.start()