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 Run

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

Overview

Concrete tool for deploying application DAGs to the Ray Serve control plane provided by the Ray Java Serve SDK.

Description

Serve.run() takes an Application from .bind(), calls Graph.build() to transform the DAG into a flat list of Deployment objects, serializes them to protobuf, and sends them to the Python Serve controller via ServeControllerClient.deployApplication(). When blocking=true (default), it waits for all replicas to reach RUNNING state, then returns a DeploymentHandle.

Usage

Call Serve.run() after binding a deployment to deploy it to the cluster.

Code Reference

Source Location

  • Repository: ray-project/ray
  • File: java/serve/src/main/java/io/ray/serve/api/Serve.java (L310-370)
  • File: java/serve/src/main/java/io/ray/serve/dag/Graph.java (L15-19)

Signature

public static DeploymentHandle run(Application application)
public static DeploymentHandle run(Application application, String name, String routePrefix, boolean blocking)

Import

import io.ray.serve.api.Serve;
import io.ray.serve.deployment.Application;
import io.ray.serve.handle.DeploymentHandle;

I/O Contract

Inputs

Name Type Required Description
application Application Yes The bound deployment from .bind()
name String No Application name (default: "default")
routePrefix String No HTTP route prefix
blocking boolean No Wait for RUNNING state (default: true)

Outputs

Name Type Description
handle DeploymentHandle Handle for sending requests to the deployed application

Usage Examples

Deploy and Get Handle

import io.ray.serve.api.Serve;
import io.ray.serve.deployment.Application;
import io.ray.serve.handle.DeploymentHandle;

Serve.start(new java.util.HashMap<>());

Application app = Serve.deployment()
    .setName("my-service")
    .setDeploymentDef("com.example.MyHandler")
    .setNumReplicas(2)
    .bind();

// Deploy and wait for replicas to be RUNNING
DeploymentHandle handle = Serve.run(app);

// Send requests via handle
Object result = handle.remote("input-data").result();

Serve.shutdown();

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

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