Creating an Algorithm Package Component
Application Scenarios of Algorithm Package Components
Algorithm package components are applicable to complex scenarios, for example, algorithm model-enabled tasks. An algorithm package component is configured as an independent service for other components to access.
Algorithm Package Component Usage Specifications
- Packing format: An algorithm package must be a .tar or .tar.gz package. The directory structure after decompression should not contain the first-level folder. The directory structure should be as follows:
Directory structure of the software package:
- main.py - dependency/ - lib/ (optional: C/C++ file) - requirements.txt - ...
- main.py file: The main.py file is mandatory. A class named AlgoProcessor needs to be implemented. The __init__ function in this class can be used to initialize a model, and the process function can be used to call a method. The code referenced in the package must comply with the standards and use an absolute path. For example, if the software package name is A, the internal modules should be reference "from A.xxx import xxx."
Example code:
#!/usr/bin/env python # -*- coding: utf-8 -*- from rest.process_base import ProcessBase class AlgoProcessor(ProcessBase): """ Algorithm Processor """ def __init__(self): super(AlgoProcessor, self).__init__(url="") def process(self, req): rst = {'result': "success", 'suggestion': "pass"} return rst, 200 - dependency folder: This folder is mandatory and is used to store dependency packages that are not included in the base image or whose versions are inconsistent. The dependency packages can be self-packaged or open-source dependency packages. These dependency packages will be installed together with the requirements.txt file.
Example code:
- simon-1.0.8-py3-none-any.whl
- lib folder: The lib folder is optional and is used to store the ****.so dynamic library of the C/C++ code compiled in the Linux environment and other dependency packages.
Example code:
- Width_Spread.so
- requirements.txt: This file is mandatory and is used to list the dependency packages contained in the dependency folder.
Example code:
dependency/simon-1.0.8-py3-none-any.whl
- Other code files: These files are optional and can be stored and referenced by yourself.
Creating an Algorithm Package Component
- Log in to ModelArts Studio and access the required workspace.
- In the navigation pane, choose Vertical Application Development > Application Components > Component Management. On the Customization tab page, click Create Component in the upper right corner, set the algorithm type to Algorithm Component Package, and click OK.
Figure 1 Algorithm package components
- On the Create Algorithm Package Component page, set basic information by referring to Table 1.
Table 1 Parameters for creating an algorithm package component Parameter
Description
English Name
English name of a component.
Chinese name
Chinese name of a component.
Service type
Service scenario used to distinguish algorithm package components. The options are as follows:
Data read/write, data preprocessing, data postprocessing, feature processing, optimization scenario definition, mechanism model, process control, image component, video component, and other
Industry
Industry type of an algorithm package component. Components can be filtered by industry type. The options are as follows:
Automotive, government, transportation, electric power, steel, mining, oil and gas, and heating
Tags
- Bind tags to a component. You can bind existing or custom tags to a component. A maximum of 10 tags can be bound to a component.
- You can create tags and delete existing tags. A maximum of 200 tags can be created in a single workspace.
- Create a tag: Enter a tag name in the text box and press Enter.
Figure 2 Creating a tag
- Delete a tag: Click X next to a specified tag from the drop-down list and click OK.
Figure 3 Deleting a tag
CAUTION:If you delete a tag that is associated with a component, the association will also be deleted. The deleted tag cannot be restored. Exercise caution when deleting tags.
- Create a tag: Enter a tag name in the text box and press Enter.
Architecture type
Hardware architectures supported by the algorithm:
- ALL: The algorithm supports the x86 and Arm architectures.
- x86: The algorithm supports only the x86 architecture.
- Arm: The algorithm supports only the Arm architecture.
Card type
Card types supported during algorithm package component deployment:
Architecture Distinguished
Whether the algorithm package is architecture-specific.
Algorithm package
Upload the algorithm package.
Figure 4 Creating an algorithm package component
- After setting the basic information, set the attributes by referring to Table 2.
Attribute parameters have multiple functions. For example, during static application orchestration, multiple components need to be integrated to implement a function. It is essential to clearly define the reference relationships between input and output parameters for each component to facilitate seamless data transfer among them.
Table 2 Attribute parameter description Parameter
Description
English Name
English name of a parameter.
Chinese name
Chinese name of a parameter.
Category
- Input parameter: indicates input parameters of the node during application orchestration. The input parameters can be set on the GUI, output parameters of other component nodes as the input parameters of the current node or canvas parameters.
- Output parameter: indicates the result generated after the component is executed. The output parameter can be used by other component nodes.
- Streaming output parameter: In scenarios such as NLP, streaming output parameters are supported and can be displayed in streaming mode. When a component is used, it must contain only one streaming output parameter and does not contain other output parameters.
- Environment variable: indicates a global variable that can be used during component operation. Environment variables can be used to store some shared configuration information. For example, if an application needs to obtain to-be-processed data from a database, the application may use environment variables to store database information such as location information, account password information, API keys.
Data Type
Value type of a component parameter.
Service Type
Service type of a parameter. This parameter is optional and is left empty by default. Two types are supported: model and model service.
Model: The OBS address of the selected model is automatically filled in the static application page after you select a model.
Model service: Select a service on the static application page to automatically fill in the access address of the selected model service so that the component service can invoke the selected model service.
Parent parameter
A parent parameter is usually used to configure a complex structure. You can use a data parameter you have added as the parent parameter of the structure. That is, the parent parameter must be a defined component parameter.
It is used to configure a complex structure. The parent parameter must be an added component parameter whose data type is object.
Default value
Default parameter value.
Valid value
Valid value range of a parameter. Example: integer: [0,10]; floating-point number: [0.1,10.1]; enumerated value: A|B|C.
Mandatory
Whether the parameter is mandatory.
is it sensitive
Whether a parameter is sensitive. Sensitive parameters cannot be entered in the canvas and can only be transferred through canvas parameters.
is it an array
Whether the parameter is an array. If a parameter is an array, it can contain multiple values. For example, a parameter named "tag" can be an array of strings that contain multiple tag names. If the parameter is not an array, it can contain only a single value.
- Click Create Now.
- After the component is created, click Edit in the Operation column on the algorithm package list page to modify the parameter name, parameters, and algorithm package. Component parameters can be imported in batches. If a component has a large number of parameters and these parameters have been created in other components, you can copy the parameter code and enter the code in the component to which the parameters need to be imported by using the parameter import function. In this way, the parameters can be imported in batches.
- After the component is developed, click Save and Validate. The component can be used in Deploying the Algorithm Package Component and Creating a Static Application.
- On the component list page, filter components by name, tag, or industry.
Figure 5 Components

Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot