Listing a custom Python component
AICS components are categorized as platform components and custom components. Platform components are built into the system and cannot be edited. Custom components are created and published by users. AICS supports three types of custom components: Python scripts, Python components, and algorithm package components. This topic describes how to publish a custom Python component.
In the navigation pane on the left, click Component Management > Custom Components.
On the Custom Components page, click Add Component in the upper-right corner.
In the Add Component pane, set the parameters and click OK in the lower-left corner.
Parameter
Description
Control Scenario
Select Real-time Algorithm Orchestration or Industrial Analysis Modeling.
If you select Real-time Algorithm Orchestration, the custom component can only be used on the Real-time Algorithm Orchestration canvas. If you select Industrial Analysis Modeling, the custom component can only be used on the Industrial Analysis Modeling canvas.
Component Name
The name of the custom component.
Identity
The unique identifier of the custom component.
Type
Python script: Write scripts using the Python compiler on the canvas.
Python component: Write the script before listing the component. Run the script using controls on the canvas.
Algorithm package component: Run the component by uploading an algorithm package.
Select Python component.
Group
The default group is selected.
Run Mode
service real-time call: The canvas can call the component in real time. The component fails if the operation times out after one minute. This call is a long-running service.
service asynchronous callback: If the component runs for more than one minute, the service is suspended and follows asynchronous logic. This call is a long-running service.
job: This mode is only available for algorithm package components. Each call starts a pod, which is automatically destroyed after the run is complete.
Icon
Select an icon for the custom component.
Description
Optional. The description of the custom component.
Python script
The Python code written for your business needs.
The following is an example of a Python script:
#import start ### customer code start def main(input_data, context): # Use input_data["IN1"] to get the data from the input port with the parameter ID IN1. IN1 = input_data["IN1"] or None # Use IN1["key1"]["value"] to get the value of key1 configured in IN1. key1 = IN1["key1"]["value"] # OUT1 is the standard JSON object returned as a parameter. You can define it based on your business needs. OUT1 = { "dataKey":{ "value": key1, "keyName":"keyName", "quality":192 }, "dataKey2":{ "value": 192, "keyName":"keyName", "quality":192 }, "dataKey3":{ "value": 222, "keyName":"keyName", "quality":192 } } return OUT1 ### customer code endAdd controls to the component.
Sequence number
Operation
1
Add an input port. The IN1 Port Configuration control automatically appears on the Input Configuration tab.
You can add multiple input ports and drag controls from the control bar on the left as needed.
2
Add an output port. The OUT1 Port Configuration control automatically appears on the Input Configuration tab.
You can add multiple output ports and drag controls from the control bar on the left as needed.
3
Select the IN1 Port Configuration and OUT1 Port Configuration controls, and then configure them in the Control Configuration pane on the right.
4
Save the edits.
Return to the Custom Components page. Find the Python component that you created and click Publish in the Operation column. Set the Version Number and select the Publish Type to publish the component.
Run the Python component.
Drag the custom Python component to the canvas and click the run icon in the upper-left corner of the canvas.