ray.serve.config.AutoscalingPolicy#

pydantic model ray.serve.config.AutoscalingPolicy[source]#

PublicAPI (alpha): This API is in alpha and may change before becoming stable.

field policy_function: str | Callable = 'ray.serve.autoscaling_policy:default_autoscaling_policy'#

Policy function can be a string import path or a function callable. If it’s a string import path, it must be of the form path.to.module:function_name.

field policy_kwargs: Dict[str, Any] [Optional]#

Keyword arguments passed to the policy class constructor when policy_function refers to a class. Ignored when policy_function is a plain function. Values must be JSON-serializable.

classmethod from_serialized_policy_def(policy_config: dict, serialized_policy_def: bytes) AutoscalingPolicy[source]#
get_policy() Callable[source]#

Deserialize policy from cloudpickled bytes.

The result is cached to avoid repeated cloudpickle deserialization on every call (e.g. on every autoscaling tick).

get_serialized_policy_def() bytes | None[source]#
is_default_policy_function() bool[source]#
validator policy_kwargs_json_serializable  »  policy_kwargs[source]#
serialize_policy() None[source]#

Serialize policy with cloudpickle.

Import the policy if it’s passed in as a string import path. Then cloudpickle the policy and set serialized_policy_def if it’s empty.

set_serialized_policy_def(serialized_policy_def: bytes) None[source]#