Implementation:Ray project Ray CallOptions
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Computing, Java_API |
| Last Updated | 2026-02-13 16:00 GMT |
Overview
Immutable options class for configuring individual Ray remote task calls provided by the Ray Java API.
Description
CallOptions extends BaseTaskOptions and encapsulates per-call configuration for Ray task invocations, including task naming, resource requirements, placement group assignment, concurrency group selection, and runtime environment. It uses a Builder pattern where the Builder inner class provides fluent setter methods for all properties, producing an immutable CallOptions instance when build() is called. The runtime environment is serialized to serializedRuntimeEnvInfo during construction.
Usage
Use this class to customize individual Ray remote task calls with fine-grained control over task scheduling and resource allocation. The CallOptions.Builder is typically used internally by BaseTaskCaller and ActorTaskCaller.
Code Reference
Source Location
- Repository: Ray
- File:
java/api/src/main/java/io/ray/api/options/CallOptions.java
Signature
public class CallOptions extends BaseTaskOptions {
public String getName();
public PlacementGroup getGroup();
public int getBundleIndex();
public String getConcurrencyGroupName();
public String getSerializedRuntimeEnvInfo();
public static class Builder {
public Builder setName(String name);
public Builder setResource(String name, Double value);
public Builder setResources(Map<String, Double> resources);
public Builder setPlacementGroup(PlacementGroup group, int bundleIndex);
public Builder setConcurrencyGroupName(String concurrencyGroupName);
public Builder setRuntimeEnv(RuntimeEnv runtimeEnv);
public CallOptions build();
}
}
Import
import io.ray.api.options.CallOptions;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | String |
No | Name for the task |
| resources | Map<String, Double> |
No | Custom resource requirements |
| group | PlacementGroup |
No | Placement group to place the task in |
| bundleIndex | int |
No | Bundle index within the placement group |
| concurrencyGroupName | String |
No | Concurrency group name for actor calls (defaults to empty) |
| runtimeEnv | RuntimeEnv |
No | Runtime environment for the task |
Outputs
| Name | Type | Description |
|---|---|---|
| callOptions | CallOptions |
Immutable options instance for a Ray task call |
Usage Examples
// Build call options directly
CallOptions options = new CallOptions.Builder()
.setName("my-task")
.setResource("CPU", 2.0)
.setResource("GPU", 1.0)
.setPlacementGroup(myGroup, 0)
.build();
// CallOptions are typically used indirectly through task callers:
ObjectRef<Integer> result = Ray.task(MyClass::compute, 42)
.setName("compute-task")
.setResource("CPU", 2.0)
.remote();