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 Serve DeploymentVersion

From Leeroopedia
Revision as of 13:48, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Ray_project_Ray_Serve_DeploymentVersion.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Model_Serving, Distributed_Computing
Last Updated 2026-02-13 16:00 GMT

Overview

DeploymentVersion represents the version of a Ray Serve deployment, combining a code version string, deployment configuration, user configuration, and Ray actor options to detect when a deployment needs updating.

Description

DeploymentVersion implements Serializable and encapsulates version tracking for deployments. If no explicit code version is provided, it generates a random 6-character alphabetic string and marks the instance as "unversioned." The class stores the deployment configuration, user configuration (extracted from the deployment config), and Ray actor options. It supports protobuf serialization via toProtoBytes() and deserialization via fromProtoBytes(), using JSON for actor options serialization.

Usage

Use DeploymentVersion when the controller needs to determine whether a deployment's code or configuration has changed, which triggers rolling updates when versions differ. It is typically created during deployment registration and compared against existing versions to decide if replicas need to be restarted.

Code Reference

Source Location

  • Repository: Ray
  • File: java/serve/src/main/java/io/ray/serve/deployment/DeploymentVersion.java

Signature

public class DeploymentVersion implements Serializable {

    private static final long serialVersionUID = 3400261981775851058L;

    public DeploymentVersion()

    public DeploymentVersion(String codeVersion)

    public DeploymentVersion(
        String codeVersion,
        DeploymentConfig deploymentConfig,
        Map<String, Object> rayActorOptions)

    public byte[] toProtoBytes()

    public static DeploymentVersion fromProtoBytes(byte[] bytes)
}

Import

import io.ray.serve.deployment.DeploymentVersion;

I/O Contract

Constructor Parameters (full constructor)

Parameter Type Description
codeVersion String Version string for the deployment code; if blank, a random 6-char string is generated and the version is marked as unversioned
deploymentConfig DeploymentConfig Configuration for the deployment (defaults to a new empty config if null)
rayActorOptions Map<String, Object> Ray actor options for the deployment replicas

Key Methods

Method Return Type Description
getCodeVersion() String Returns the code version string
getUserConfig() Object Returns the user configuration extracted from deployment config
getDeploymentConfig() DeploymentConfig Returns the deployment configuration
getRayActorOptions() Map<String, Object> Returns the Ray actor options
isUnversioned() boolean Returns true if no explicit code version was provided
toProtoBytes() byte[] Serializes the version to protobuf bytes
fromProtoBytes(bytes) DeploymentVersion Static factory that deserializes from protobuf bytes

Usage Examples

// Create a versioned deployment version
DeploymentVersion version = new DeploymentVersion(
    "v1.2.3",
    deploymentConfig,
    actorOptions
);

// Check if explicitly versioned
boolean isVersioned = !version.isUnversioned(); // true

// Serialize for transmission to controller
byte[] protoBytes = version.toProtoBytes();

// Deserialize from protobuf bytes received from controller
DeploymentVersion restored = DeploymentVersion.fromProtoBytes(protoBytes);
String codeVersion = restored.getCodeVersion(); // "v1.2.3"

// Create an unversioned deployment (auto-generated random code version)
DeploymentVersion unversioned = new DeploymentVersion();
boolean isUnversioned = unversioned.isUnversioned(); // true

Related Pages

Page Connections

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