WITH ARGUMENTS Syntax
The WITH ARGUMENTS syntax enhances the capabilities of existing UDFs, primarily enabling users to configure the initial state upon UDF execution. With this feature, users can:
- Configure runtime resources and concurrency: Specify the necessary resources (for example, memory, CPU) for UDF operation along with the count of concurrent execution instances to enhance performance and resource efficiency.
- Set class initialization parameters: For UDFs defined within a class structure, employ the WITH ARGUMENTS syntax to pass initialization constructor arguments, thereby establishing a particular initial state during UDF instantiation.
Key usage considerations include:
- WITH ARGUMENTS accommodates several predefined parameters. Refer to Table 1 for specifics. Ensure class initialization parameter names do not conflict with these fixed parameters, noting that parameter names are case-sensitive.
- Only constants can be used as input parameters.
- For UDFs defined as classes, users should define the __init__ and __del__ member methods as needed, but the __call__ member method must be defined, as it serves as the main function entry point.
- min_concurrency and max_concurrency must be set simultaneously. Successful configuration indicates that adaptive concurrency is enabled.
- To set init_concurrency, enable enable_udf_global_actor_pool and set min_concurrency and max_concurrency first. Otherwise, an error will be reported.
| Parameter | Description | Default Value |
|---|---|---|
| concurrency | Concurrency of the UDF execution, with a value range of [1, 1024]. | 1 |
| min_concurrency | Minimum concurrency of the UDF execution, with a value range of [1, 1024]. | null |
| max_concurrency | Maximum concurrency of the UDF execution, with a value range of [1, 1024]. | null |
| init_concurrency | Warm-up concurrency of the UDF execution. The value range is [min_concurrency, max_concurrency]. | (min_concurrency + max_concurrency) / 2 |
| timeout | Timeout duration for the UDF execution, with a value range of [1, 3600], in seconds. | 1000 |
| cpu | CPU resources of a single actor during UDF execution. The value can be a fractional value from 0.33 to 1 or an integer from 1 to 16. Note that the system rounds the input value and retains two decimal places. | 1 |
| memory | Memory resources of a single actor during UDF execution. The value ranges from 128 to 65536, in MiB. Decimals are not supported. | 4096 |
| arch | Physical architecture type during UDF execution. The value can be arm or x86. The default value of arch varies depending on the value of apu. |
|
| apu | Type and specifications of heterogeneous resources, for example, NPU/.+/1 | null |
| env_vars | Runtime environment variable, which is dict[str, str] or a JSON string. For details, see Environment Variable Configuration. | null |
| scheduling_strategy | UDF Actor placement policy, which is a SchedulingStrategy object, object list, or JSON string. For details, see UDF Actor Placement Policy. | null |
What is your overall rating for this page?
Thank 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