yr.InvokeOptions#
- class yr.InvokeOptions(cpu: int = 500, memory: int = 500, concurrency: int | None = None, custom_resources: ~typing.Dict[str, float] = <factory>, custom_extensions: ~typing.Dict[str, str] = <factory>, pod_labels: ~typing.Dict[str, str] = <factory>, labels: ~typing.List[str] = <factory>, affinity: ~typing.Dict[str, str] = <factory>, device: ~yr.config.Device = <factory>, max_invoke_latency: int = 5000, min_instances: int = 0, max_instances: int = 0, recover_retry_times: int = 0, need_order: bool = False, name: str = '', namespace: str = '', schedule_affinities: ~typing.List[~yr.affinity.Affinity] = <factory>, is_data_affinity: bool = False, resource_group_options: ~yr.config.ResourceGroupOptions = <factory>, function_group_options: ~yr.config.FunctionGroupOptions = <factory>, env_vars: ~typing.Dict[str, str] = <factory>, retry_times: int = 0, trace_id: str = '', alias_params: ~typing.Dict[str, str] = <factory>, runtime_env: ~typing.Dict = <factory>, debug: ~yr.config.DebugConfig = <factory>, preempted_allowed: bool = False, instance_priority: int = 0, schedule_timeout_ms: int = 30000, group_name: str = '', is_delete_remote_tensor: bool = False, get_if_exists: bool = False, skip_serialize: bool = False, port_forwardings: ~typing.List[~yr.config.PortForwarding] = <factory>)[source]#
Bases:
objectUse to set the invoke options.
Examples
>>> import yr >>> import time >>> yr.init() >>> opt = yr.InvokeOptions() >>> opt.pod_labels["k1"] = "v1" >>> @yr.invoke(invoke_options=opt) ... def func(): ... time.sleep(100) >>> ret = func.invoke() >>> yr.get(ret) >>> yr.finalize()
Attributes
Instance concurrency.
The size of the CPU required.
The priority of an instance is determined by its value.
Whether to enable data affinity scheduling.
Specify the maximum number of instances for a stateless function.
Specify the time when the invoke call of the desired heterogeneous function is completed.
[128, 1073741824].
Specify the minimum number of instances for a stateless function.
Used to specify the name of the instance.
Used to specify the namespace of the instance.
Whether to enable order-preserving.
Whether an instance can be preempted is effective only in the priority scenario (when the maxPriority configuration item deployed by YuanRong is greater than
0).Whether to enable anti-affinity for non-selectable resources.
Set whether to enable weak affinity priority scheduling.
The number of instance recovery times (when an instance abnormally exits, the instance is automatically restored to the latest state).
Set whether to enable strong affinity priority scheduling.
Number of retries for stateless functions.
milliseconds.
Whether to skip serializing the instance class code.
Set the traceId for function calls for link tracing.
Custom resources currently support "GPU/XX/YY" and "NPU/XX/YY", where XX is the card model such as Ascend910B4, and YY can be count, latency, or stream.
Specify user-defined configurations, such as function concurrency.
Pod labels only used in Kubernetes environment.
Labels of instance
Affinity of instance
Specify the name of the model used by the heterogeneous function.
Set affinity condition list.
Specify the ResourceGroup option, which includes resource_group_name and bundle_index.
Function group options.
Set environment variables when the instance starts.
In the scenario where a function is invoked by a specified alias in cross-function invocation, when the alias is a rule alias, this parameter is used to set the kv parameter that the rule alias depends on.
Configure the stateful/stateless function runtime environment with conda, pip, working_dir, and env_vars.
Configure port forwarding rules for the sandbox.
Methods
Check whether the options are in the valid range.
Check whether the options are valid.