Examples

AI SDK Operation Manual

Portfolio
Industrial AI
Product
AI Software Development Kit
Software version
v2.4
Edition
04/2025
Language
English

PythonComponent definition example

The following script creates an example pipeline with a single component, two inputs, and two outputs.

from simaticai import deployment
 defines basic properties of the pipeline step
component = deployment.PythonComponent(name='classifier', version='1.0.0', python_version='3.10')
component.add_input(name='input_1', _type='Double')

 defines input variable
component.add_input(name='input_2', _type='Double')

 defines input variable
component.add_output(name='class_label', _type='Integer')

 defines output variable
component.add_output(name='confidence', _type='Double')

 defines output variable
component.add_resources("../src/", "entrypoint.py")
component.set_entrypoint('entrypoint.py')
pipeline = deployment.Pipeline.from_components([component], name='Example', version='1.0.0')
edge_package_path = pipeline.export('../packages')

The above code generates a pipeline-config.yml that contains, among others, the following:

 pipeline-config.yml
components:
name: classifier
entrypoint: entrypoint.py
version: 1.0.0
runtime:
    type: python
    version: 3.10
inputType:
    - name: input_1
    type: Double
    - name: input_2
    type: Double
outputType:
    - name: class_label
    type: Integer
    - name: confidence
    type: Double

The pipeline looks as follows:


pipeline

GPURuntimeComponent definition example

from simaticai.deployment import model_config
detection = deployment.GPURuntimeComponent(name='detection')

detection.use_model("../src/detection/1/model.onnx",
                    max_batch_size=1,
                    optimization=model_config.TensorRTOptimization(),  # Optional
                    warmup=model_config.Warmup.RANDOM_DATA)

 adding extra inputs and outputs to connect the payload with the result
detection.add_input("iuid", "String")  
detection.add_output("iuid", "String")

The above code generates a pipeline-config.yml that contains, among others, the following:

dataFlowPipeline:
  components:
  - description: ''
    entrypoint: ./preprocessing.py
    hwType: CPU
    inputType:
    - name: vision_payload
      type: ImageSet
    name: preprocessing
    outputType:
    - name: input
      type: Float32Array
    - name: iuid
      type: String
    replicas: 1
    runtime:
      type: python
      version: '3.10'
    version: 0.0.1
  - description: ''
    entrypoint: 1/model.onnx
    hwType: GPU
    inputType:
    - name: input
      type: Float32Array
    - name: iuid
      type: String
    name: detection
    outputType:
    - name: boxes
      type: Float32Array
    - name: labels
      type: Int64Array
    - name: scores
      type: Float32Array
    - name: iuid
      type: String
    runtime:
      type: triton
      version: 0.1.0
    version: '1'
  - description: ''
    entrypoint: ./postprocessing.py
    hwType: CPU
    inputType:
    - name: iuid
      type: String
    - name: boxes
      type: Float32Array
    - name: labels
      type: Int64Array
    - name: scores
      type: Float32Array
    name: postprocessing
    outputType:
    - name: prediction
      type: String
    - name: result
      type: String
    replicas: 1
    runtime:
      type: python
      version: '3.10'
    version: 0.0.1

[...]

Image Classification

The following script creates an image classification pipeline that consists of a single component. The pipeline processes images embedded in JSON strings and produces a classification result as a string. This example is detailed in the Image Classification end-to-end tutorial.

from simaticai import deployment
 create pipeline component and define basic properties
component = deployment.PythonComponent(name='inference', version='1.0.0', python_version='3.10')
component.add_input('vision_payload', 'String')

 define single input variable
component.add_output('prediction', 'String')

 define a single output variable
component.add_resources('..', 'entrypoint.py')

 add Python script
component.set_entrypoint('entrypoint.py')

 define the above script as entrypoint
component.add_resources('..', 'src/vision_classifier_tflite.py')

 add classifier script used by entrypoint
component.set_requirements("../runtime_requirements_tflite.txt")

 define required Python packages
component.add_resources('..', 'models/classification_mobilnet.tflite')

 add saved model used in classifier
component.set_parallel_steps(2) # set the number of parallel executors

 create and save a pipeline consisting of a single component
pipeline = deployment.Pipeline.from_components([component], name='Image_TFLite_package', version='1.0.0')
edge_package_path = pipeline.export('../packages')

NOTICE

The `simaticai.deployment.Pipeline.export()` method is available from AI SDK v2.1.0.

The above code generates a pipeline_config.yml that contains, among other things:

dataFlowPipeline:
    components:
    - entrypoint: ./entrypoint.py
      inputType:
      - name: vision_payload
        type: String
      name: inference
      outputType:
        - name: prediction
          type: String
        runtime:
type: python
    version: '3.10'
    version: 1.0.0
pipelineDag:
    - source: Databus.vision_payload
      target: inference.vision_payload
    - source: inference.prediction
      target: Databus.prediction
pipelineInputs:
    - name: vision_payload
      type: String
pipelineOutputs:
    - name: prediction
      type: String
dataFlowPipelineInfo:
    dataFlowPipelineVersion: 1.0.0
    projectName: Image_TFLite_package

The saved pipeline configuration package contains the files listed below. The main folder contains the YAML files that describe the pipeline. The components subfolder contains the zip files that contain the components.

Image_TFLite_package_1.0.0/pipeline_config.yml
Image_TFLite_package_1.0.0/datalink_metadata.yml
Image_TFLite_package_1.0.0/components/inference.zip
Image_TFLite_package_1.0.0/components/inference.zip/entrypoint.py
Image_TFLite_package_1.0.0/components/inference.zip/requirements.txt
Image_TFLite_package_1.0.0/components/inference.zip/src/vision_classifier_tflite.py
Image_TFLite_package_1.0.0/components/inference.zip/models/classification_mobilnet.tflite.py