ray.data.ExecutionResources#

class ray.data.ExecutionResources(cpu: float | None = None, gpu: float | None = None, object_store_memory: float | None = None, default_to_inf: bool = False)[source]#

Specifies resources usage or resource limits for execution.

By default this class represents resource usage. Use for_limits or set default_to_inf to True to create an object that represents resource limits.

classmethod from_resource_dict(resource_dict: Dict[str, float], default_to_inf: bool = False)[source]#

Create an ExecutionResources object from a resource dict.

classmethod for_limits(cpu: float | None = None, gpu: float | None = None, object_store_memory: float | None = None) ExecutionResources[source]#

Create an ExecutionResources object that represents resource limits. :param cpu: Amount of logical CPU slots. :param gpu: Amount of logical GPU slots. :param object_store_memory: Amount of object store memory.

classmethod zero() ExecutionResources[source]#

Returns an ExecutionResources object with zero resources.

is_zero() bool[source]#

Returns True if all resources are zero.

is_non_negative() bool[source]#

Returns True if all resources are non-negative.

object_store_memory_str() str[source]#

Returns a human-readable string for the object store memory field.

copy() ExecutionResources[source]#

Returns a copy of this ExecutionResources object.

add(other: ExecutionResources) ExecutionResources[source]#

Adds execution resources.

Returns:

A new ExecutionResource object with summed resources.

subtract(other: ExecutionResources) ExecutionResources[source]#

Subtracts execution resources.

Returns:

A new ExecutionResource object with subtracted resources.

max(other: ExecutionResources) ExecutionResources[source]#

Returns the maximum for each resource type.

min(other: ExecutionResources) ExecutionResources[source]#

Returns the minimum for each resource type.

satisfies_limit(limit: ExecutionResources) bool[source]#

Return if this resource struct meets the specified limits.

Note that None for a field means no limit.

scale(f: float) ExecutionResources[source]#

Return copy with all set values scaled by f.