8000 We encountered the cast exception after we got result from ray actor task · Issue #20369 · ray-project/ray · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
We encountered the cast exception after we got result from ray actor task #20369
Open
@liuyang-my

Description

@liuyang-my

Search before asking

  • I searched the issues and found no similar issues.

Ray Component

Ray Core

What happened + What you expected to happen

If the return type of Java class method is Object and an int value is returned, the result of ray task for this class's actor is Byte. We expect the result is Integer, so it can be casted to int. The same appearance happens for long and short.

If a float type value is returned, the result is Double. We are not sure whether this is the same problem.

image

Versions / Dependencies

all

Reproduction script

This is our test code:

import java.util.concurrent.atomic.AtomicInteger;
import io.ray.api.ActorHandle;
import io.ray.api.ObjectRef;
import io.ray.api.Ray;
import io.ray.api.options.ActorCreationOptions;

public class IntActorTest {

  public static class Counter {

    private AtomicInteger counter = new AtomicInteger(0);

    public Object call(Object object) {
      return counter.getAndIncrement();
    }

  }

  public void main(String[] args) {

    System.setProperty("ray.run-mode", "SINGLE_PROCESS");
    System.setProperty("ray.jobmaster.gateway.serviceExportEnable", "false");
    Ray.init();

    try {
      ActorHandle<Counter> actorHandle =
          Ray.actor(Counter::new).setMaxRestarts(ActorCreationOptions.INFINITE_RESTART).remote();

      for (int i = 0; i < 10; i++) {
        ObjectRef<Integer> objectRef = actorHandle.task(Counter::call, "test").remote();
        int result = (int) objectRef.get();
        System.out.println(result);
      }

    } finally {
      Ray.shutdown();
    }
  }
}

Anything else

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

Labels

P3Issue moderate in impact or severitybugSomething that is supposed to be working; but isn'tjavapending-cleanupThis issue is pending cleanup. It will be removed in 2 weeks after being assigned.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0