Python SDK
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.
Install from pip
Install the necessary Python package from pip
(Pypy)
Install from sources
Install from the official repository
Clone the repository locally, follow these instructions to install manually
Create a new conda environment with conda create -n intrepid python=3.10
Activate environment with
conda activate intrepid
Install poetry
with pip install poetry
and all requirements pip install -r requirements.txt
Build Python Intrepid SDK
And check that all has been installed correctly
This should print
Usage
Create Python Node
A Python node is created from dashboard and rendered according to the Python function signature that is attached.
A Python SDK allows to
- read from the output of a node and
- write to the input of a node.
Rendering a node means defining inputs and outputs complete with types (only primitive types supported).
node_id
, input_id
, output_id
are in the property section of the sidebar of the relative nodes.
Create a 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
Register a 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:
Register a custom Callback and start node
This should show node info and status
Node node/sdk/ex1
is running a websocket server at 127.0.0.1:9999
Start Intrepid Runtime Core
Execute the Intrepid runtime (intrepid-agent
) with arguments
run-node
<node_name>
--load ws://<host>:<port>
where the node is running
-i input1
-i input2
This should show something like
The node is running and computing the callback function, and returning 3.0
Publish custom node
In order to be viewed from the dashboard and connected to the rest of the graph, a node must be published.
An authentication token is necessary to publish a node to a user library. Such token can be retrieved from dashboard at https://labs.intrepid.ai from the Project
section on the left sidebar.
If node is published correctly, somethig like this will be printed to stdout