Code Monkey home page Code Monkey logo

Comments (5)

982945902 avatar 982945902 commented on June 18, 2024

maybe it is not a bug in local mode

look at this code in ray/src/ray/core_worker/core_worker.cc
image

from ray.

982945902 avatar 982945902 commented on June 18, 2024

@jjyao @kevin85421 #45025 i add a api to support this issue

from ray.

hongchaodeng avatar hongchaodeng commented on June 18, 2024

ray.get_runtime_context() returns the job config for entire Ray job, not specific task/actor.

Ray does provide an API to access specific actor via ray.get_actor(<name>, <namespace>). But you have to specify namespace with that.

For this issue, it is using the API for the wrong job IMHO.

May I ask what's your use case to get the namespace inside the actor? Because in your code you can easily pass down the namespace to the actor.

from ray.

kevin85421 avatar kevin85421 commented on June 18, 2024

ray.get_runtime_context() returns the job config for entire Ray job, not specific task/actor.

Hmm. The RuntimeContext's constructor is initialized with a worker process. I believe that RuntimeContext is specific to each worker process (task/actor). I also performed a simple experiment. Do I miss anything?

import ray

ray.init()

@ray.remote
def f():
    runtime_context = ray.get_runtime_context()
    print("Ray task")
    print("Job", ray.get_runtime_context().get_job_id())
    print("Task", ray.get_runtime_context().get_task_id())
    print("Actor", ray.get_runtime_context().get_actor_id())

@ray.remote
class actor:
    def __init__(self):
        pass
    def print_message(self):
        runtime_context = ray.get_runtime_context()
        print("Ray actor")
        print("Job", ray.get_runtime_context().get_job_id())
        print("Task", ray.get_runtime_context().get_task_id())
        print("Actor", ray.get_runtime_context().get_actor_id())

task_obj_ref = f.remote()
ray.get(task_obj_ref)

actor_instance = actor.remote()
ray.get(actor_instance.print_message.remote())
Screenshot 2024-05-01 at 9 27 58 PM

from ray.

woshiyyya avatar woshiyyya commented on June 18, 2024

Thanks for following up. As @kevin85421 said here, an api that returns the actor's namespace suffice my use case.

from ray.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.