yr.InvokeOptions

Contents

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: object

Use 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

concurrency

Instance concurrency.

cpu

The size of the CPU required.

get_if_exists

group_name

instance_priority

The priority of an instance is determined by its value.

is_data_affinity

Whether to enable data affinity scheduling.

is_delete_remote_tensor

max_instances

Specify the maximum number of instances for a stateless function.

max_invoke_latency

Specify the time when the invoke call of the desired heterogeneous function is completed.

memory

[128, 1073741824].

min_instances

Specify the minimum number of instances for a stateless function.

name

Used to specify the name of the instance.

namespace

Used to specify the namespace of the instance.

need_order

Whether to enable order-preserving.

preempted_allowed

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).

preferred_anti_other_labels

Whether to enable anti-affinity for non-selectable resources.

preferred_priority

Set whether to enable weak affinity priority scheduling.

recover_retry_times

The number of instance recovery times (when an instance abnormally exits, the instance is automatically restored to the latest state).

required_priority

Set whether to enable strong affinity priority scheduling.

retry_times

Number of retries for stateless functions.

schedule_timeout_ms

milliseconds.

skip_serialize

Whether to skip serializing the instance class code.

trace_id

Set the traceId for function calls for link tracing.

custom_resources

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.

custom_extensions

Specify user-defined configurations, such as function concurrency.

pod_labels

Pod labels only used in Kubernetes environment.

labels

Labels of instance

affinity

Affinity of instance

device

Specify the name of the model used by the heterogeneous function.

schedule_affinities

Set affinity condition list.

resource_group_options

Specify the ResourceGroup option, which includes resource_group_name and bundle_index.

function_group_options

Function group options.

env_vars

Set environment variables when the instance starts.

alias_params

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.

runtime_env

debug

Configure the stateful/stateless function runtime environment with conda, pip, working_dir, and env_vars.

port_forwardings

Configure port forwarding rules for the sandbox.

Methods

__init__

check_options_range

Check whether the options are in the valid range.

check_options_valid

Check whether the options are valid.