Updated on 2025-11-04 GMT+08:00

Functions of Preset Components

The platform provides multiple preset components.

Table 1 List of preset components

Category

Component

Function

Data read and write

convert_obs_file_to_base64

convert_obs_file_to_base64 Component

save_data_to_local_file

save_data_to_local_file Component

read_data_from_local_file

read_data_from_local_file Component

Logic component

deploy_together

deploy_together Component

Customizing a script

custom_python_script

custom_python_script Component

Other

call_stream_api

call_stream_api Component

call_api

call_api Component

convert_obs_file_to_base64 Component

The convert_obs_file_to_base64 component is used to read files from OBS and convert the files to Base64 encoding. It is applicable to Base64 reading and conversion of small files, such as images.

Table 2 Parameters of the convert_obs_file_to_base64 component

Category

Parameter

Description

Input params

obs_path

Path of the OBS file to be read. The value starts with obs://.

ak

Access key (AK) of the tenant where the OBS file is located.

sk

Secret key (SK) of the tenant where the OBS file is located.

Output params

output

Output result after the file is converted to a Base64-encoded file.

To obtain the AK and SK, perform the following steps:

Log in to the Huawei Cloud management console, hover the cursor on the username in the upper right corner of the page, and click My Credential. On the My Credential page that is displayed, click the Access Keys tab to obtain the AK and SK. If no AK or SK is available, click Add Access Key to create one.

Figure 1 convert_obs_file_to_base64 Component

save_data_to_local_file Component

The save_data_to_local_file component is used to store single-level JSON data to a local CSV or JSON file.

Table 3 Parameters of the save_data_to_local_file component

Category

Parameter

Description

Input params

file_path

Path of the local file. The file can be in CSV or JSON format. Example: /home/HwHiAiUser/test.csv

data

JSON data to be written to the file.

encoding

File content code. The value can be gbk or utf-8. The default value is gbk.

If the file_path file is in CSV format, you are advised to use GBK encoding.

Output params

flag

Length of the file after JSON data is written.

Figure 2 save_data_to_local_file component

read_data_from_local_file Component

The read_data_from_local_file component can be used to read local data. The component parameters are described as follows.

Table 4 Parameters of the read_data_from_local_file component

Category

Parameter

Description

Input params

file_path

Path of the local file to be read. The file can be in CSV or JSON format. Example: /home/HwHiAiUser/test.csv

encoding

Encoding format of the file content. The options are gbk and utf-8.

Output params

data

JSON data read from the file.

Figure 3 read_data_from_local_file component

deploy_together Component

The deploy_together component allows all subcomponents dragged to the same container to be integrated into a container service, which simplifies the management and deployment process. These subcomponents share the resources of the same container, such as CPUs, memory, and environment variables. These subcomponents run in the same container, which reduces the overhead and complexity of cross-container communication and facilitates unified configuration and management.

The component parameters are described as follows.

Table 5 Parameters of the deploy_together component

Category

Parameter

Description

Deployment Configuration

CPU

Minimum number of physical CPU cores required for deployment.

Memory

Minimum size of memory reserved for deploying the component.

Ascend

Number of NPUs used for deployment.

Environment Variable

External environment variables defined in the component code.

Figure 4 Deployment configuration of the deploy_together component

custom_python_script Component

The functions of the custom_python_script component are similar to those of the custom script component in component management. You can compile Python code to implement specific component functions. The difference is that the custom_python_script component allows you to create and delete parameters in the canvas and compile script code. If any problem occurs during debugging, you do not need to return to the component management page for processing, which greatly facilitates debugging, after the debugging is complete, the component can be archived on the component management page. Note that each time you drag the custom_python_script component to the canvas, you need to create its parameters and supplement the script. When you delete the component, the created information will be lost.

Figure 5 Configuring the custom_python_script component

call_stream_api Component

The call_stream_api component can be used to invoke the model service with deployed streaming output parameters. For example, the component parameters in the NLP model streaming scenario are described as follows:

Table 6 Parameters of the call_stream_api component

Category

Parameter

Description

Input params

body

Request body required for invoking a service is in object format. The default value is {}.

headers

Request header required for invoking a service is in object format. The default value is {}.

url

Request address for invoking a service. The value is a character string. You can click the Select Service button on the canvas to fill in the address.

request_type

Type of the request for invoking the service. The default value is POST.

Output params

response

Streaming return value of the invoked service.

Figure 6 call_stream_api component

call_api Component

The call_api component can be used to invoke the five deployed model services (non-streaming output parameter scenario). The component parameters are described as follows.

Table 7 Parameters of the call_api component

Category

Parameter

Description

Input params

body

Request body required for invoking a service is in object format. The default value is {}.

url

Request address for invoking the service. The value is a character string. You can click the model association button on the canvas to invoke the deployed algorithm package component.

headers

Request header required for invoking a service is in object format. The default value is {}.

request_type

Type of the request for invoking the service. The default value is POST.

Output params

response

Return value of the invoked service.

Figure 7 call_api component