Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Ray project Ray RayConfig

From Leeroopedia
Knowledge Sources
Domains Distributed_Computing, Java_Runtime
Last Updated 2026-02-13 16:00 GMT

Overview

Central configuration class for the Ray Java runtime that encapsulates all settings needed to initialize and run a Ray worker or driver.

Description

RayConfig uses the Typesafe Config library to load configuration from system properties, ray.conf, and ray.default.conf in priority order. It parses worker mode, run mode, network addresses, Redis credentials, code search paths, runtime environment settings (environment variables, JARs), and logger configurations. The class validates required settings based on worker type and serves as the single source of truth for all Ray Java runtime configuration.

Usage

Use RayConfig whenever you need to read or supply configuration values for the Ray Java runtime. It is typically instantiated via the static RayConfig.create() factory method at startup, and every runtime component reads its settings from this class. Driver processes, workers, and local-mode simulations all rely on it to resolve node addresses, socket paths, job IDs, and runtime environment details.

Code Reference

Source Location

  • Repository: Ray
  • File: java/runtime/src/main/java/io/ray/runtime/config/RayConfig.java

Signature

public class RayConfig {

  public static final String DEFAULT_CONFIG_FILE = "ray.default.conf";
  public static final String CUSTOM_CONFIG_FILE = "ray.conf";

  public final String nodeIp;
  public final WorkerType workerMode;
  public final RunMode runMode;
  public String sessionDir;
  public String logDir;
  public final String redisUsername;
  public final String redisPassword;
  public String objectStoreSocketName;
  public String rayletSocketName;
  public int nodeManagerPort;
  public UniqueId workerId;
  public int runtimeEnvHash;
  public RuntimeEnvImpl runtimeEnvImpl;
  public final ActorLifetime defaultActorLifetime;
  public final List<LoggerConf> loggers;
  public final List<String> codeSearchPath;
  public final List<String> headArgs;
  public final String namespace;
  public final List<String> jvmOptionsForJavaWorker;

  public RayConfig(Config config) { ... }
  public static RayConfig create() { ... }
}

Import

import io.ray.runtime.config.RayConfig;

I/O Contract

Input

Parameter Type Description
config com.typesafe.config.Config Typesafe Config object containing Ray configuration keys under the ray.* namespace

Output

Field Type Description
nodeIp String IP address of the current node (auto-detected or configured)
workerMode WorkerType Whether this process is a DRIVER or WORKER
runMode RunMode LOCAL or CLUSTER execution mode
bootstrapAddress String GCS bootstrap address for cluster mode
sessionDir String Path to the Ray session directory
logDir String Path to the log directory
codeSearchPath List<String> Classpath entries for job code lookup
runtimeEnvImpl RuntimeEnvImpl Runtime environment configuration (env vars, JARs, config)

Usage Examples

// Create a RayConfig using the default config loading order
// (system properties -> ray.conf -> ray.default.conf)
RayConfig config = RayConfig.create();

// Access configuration values
String nodeIp = config.nodeIp;
RunMode mode = config.runMode;
JobId jobId = config.getJobId();
String bootstrapAddr = config.getBootstrapAddress();

// Create from a custom Config object
Config typesafeConfig = ConfigFactory.load("custom-ray.conf")
    .withOnlyPath("ray");
RayConfig customConfig = new RayConfig(typesafeConfig);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment