Skip to content

[Core] "Reuse Ray Actors in DAGs" example does not seem to work when connecting to an existing ray instance #50328

@CriGiu

Description

@CriGiu

What happened + What you expected to happen

Running the example reuse-ray-actors-in-dags as shown on Ray Docs does not seem to work unless the code is run on a local Ray instance.

The error given is:

Traceback (most recent call last):
  File "/home/******/ray/test.py", line 24, in <module>
    dag = MultiOutputNode([worker.forward.bind(input_data)])
AttributeError: 'ClientRemoteMethod' object has no attribute 'bind'

Using bind() API on the Actor seems to work just fine even on an existing (non-local) Ray instance

Versions / Dependencies

Fresh conda environment running

Python version: 3.10.16
Ray version: 2.42.0

The cluster is running on microk8s, and installed via kuberay chart with image tag set to 2.42.0-py310

Reproduction script

# taken and adapted from Ray Docs @ https://docs.ray.io/en/releases-2.40.0/ray-core/ray-dag.html#reuse-ray-actors-in-dags


import ray
from ray.dag.input_node import InputNode
from ray.dag.output_node import MultiOutputNode

import ray

ray.init(address='ray://localhost:10001')

@ray.remote
class Worker:
    def __init__(self):
        self.forwarded = 0

    def forward(self, input_data: int):
        self.forwarded += 1
        return input_data + 1

    def num_forwarded(self):
        return self.forwarded

# Create an actor via ``remote`` API not ``bind`` API to avoid
# killing actors when a DAG is finished.
worker = Worker.remote()

with InputNode() as input_data:
    dag = MultiOutputNode([worker.forward.bind(input_data)])

# Actors are reused. The DAG definition doesn't include
# actor creation.
assert ray.get(dag.execute(1)) == [2]
assert ray.get(dag.execute(2)) == [3]
assert ray.get(dag.execute(3)) == [4]

Issue Severity

Low: It annoys or frustrates me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issue, but not time-criticalbugSomething that is supposed to be working; but isn'tcommunity-backlogcoreIssues that should be addressed in Ray Corecore-clientray client related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions