# Get actor handle by ObjectRef

**URL:** <https://discuss.ray.io/t/get-actor-handle-by-objectref/601>\
**Category:** Uncategorized\
**Created:** [January 26, 2021, 1:52pm UTC](https://discuss.ray.io/t/get-actor-handle-by-objectref/601 "2021-01-26T13:52:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![no-ponomarev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/no-ponomarev/32/331_2.png) [@no-ponomarev](https://discuss.ray.io/u/no-ponomarev)\
**Post date:** [January 26, 2021, 1:52pm UTC](https://discuss.ray.io/t/get-actor-handle-by-objectref/601/1 "2021-01-26T13:52:46Z")

</div>

Is it possible to query an “actor handle” by `ObjectRef` of the data, held by in-process store?  
Moreover, could we query somehow all the table of local in-process store objects and local node (not the whole cluster) shared objects store?

---

<div class="post-metadata">

**Author:** ![Alex](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/alex/32/341_2.png) [@Alex](https://discuss.ray.io/u/Alex)\
**Post date:** [January 26, 2021, 9:42pm UTC](https://discuss.ray.io/t/get-actor-handle-by-objectref/601/2 "2021-01-26T21:42:11Z")

</div>

Hey, do you mind elaborating or providing an example of what you hope to achieve? There isn’t really a concept of “actor handle” for an object, since a task or the driver could create the object.

As for querying the local objects, you could do `ray.objects()` and filter based on the returned objects and their locations. You can get your current node id via `ray.worker.global_worker.current_node_id`.

---

<div class="post-metadata">

**Author:** ![Yaroslav\_Igoshev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yaroslav_igoshev/32/283_2.png) [@Yaroslav\_Igoshev](https://discuss.ray.io/u/Yaroslav_Igoshev)\
**Post date:** [January 27, 2021, 5:56am UTC](https://discuss.ray.io/t/get-actor-handle-by-objectref/601/3 "2021-01-27T05:56:11Z")

</div>

> [@Alex](#):
>
> As for querying the local objects, you could do `ray.objects()` and filter based on the returned objects and their locations. You can get your current node id via `ray.worker.global_worker.current_node_id` .

Hi,  
Doesn’t `ray.objects()` return the entire object table (both local and non-local objects)?

---

<div class="post-metadata">

**Author:** ![Yaroslav\_Igoshev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yaroslav_igoshev/32/283_2.png) [@Yaroslav\_Igoshev](https://discuss.ray.io/u/Yaroslav_Igoshev)\
**Post date:** [January 27, 2021, 5:54pm UTC](https://discuss.ray.io/t/get-actor-handle-by-objectref/601/4 "2021-01-27T17:54:29Z")

</div>

@Alex , just a friendly reminder!

---

<div class="post-metadata">

**Author:** ![Alex](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/alex/32/341_2.png) [@Alex](https://discuss.ray.io/u/Alex)\
**Post date:** [January 27, 2021, 6:27pm UTC](https://discuss.ray.io/t/get-actor-handle-by-objectref/601/5 "2021-01-27T18:27:20Z")

</div>

Hey, yeah ray.objects returns the entire object table, thus the filtering by location.

What you want is something like `filter(lambda obj:ray.worker.global_worker.current_node_id.hex() in obj["Locations"], ray.objects())`

---

<div class="post-metadata">

**Author:** ![sangcho](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sangcho/32/425_2.png) [@sangcho](https://discuss.ray.io/u/sangcho)\
**Post date:** [January 28, 2021, 7:06am UTC](https://discuss.ray.io/t/get-actor-handle-by-objectref/601/6 "2021-01-28T07:06:11Z")

</div>

Btw, please do not use `ray.worker.global_worker.current_node_id` but ` ray.get_runtime_context().node_id`.

---

<div class="post-metadata">

**Author:** ![Yaroslav\_Igoshev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yaroslav_igoshev/32/283_2.png) [@Yaroslav\_Igoshev](https://discuss.ray.io/u/Yaroslav_Igoshev)\
**Post date:** [January 28, 2021, 7:36am UTC](https://discuss.ray.io/t/get-actor-handle-by-objectref/601/7 "2021-01-28T07:36:42Z")

</div>

> [@Alex](#):
>
> What you want is something like `filter(lambda obj:ray.worker.global_worker.current_node_id.hex() in obj["Locations"], ray.objects())`

@Alex, thanks a lot! Just a little fix required:

`list(filter(lambda obj: ray.worker.global_worker.current_node_id.hex() in obj["Locations"], ray.objects().values()))`

---

<div class="post-metadata">

**Author:** ![Yaroslav\_Igoshev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yaroslav_igoshev/32/283_2.png) [@Yaroslav\_Igoshev](https://discuss.ray.io/u/Yaroslav_Igoshev)\
**Post date:** [January 28, 2021, 7:39am UTC](https://discuss.ray.io/t/get-actor-handle-by-objectref/601/8 "2021-01-28T07:39:18Z")

</div>

> [@sangcho](#):
>
> Btw, please do not use `ray.worker.global_worker.current_node_id` but ` ray.get_runtime_context().node_id` .

@sangcho , could you please say what issue of using `ray.worker.global_worker.current_node_id`?

---

<div class="post-metadata">

**Author:** ![sangcho](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sangcho/32/425_2.png) [@sangcho](https://discuss.ray.io/u/sangcho)\
**Post date:** [January 28, 2021, 7:51am UTC](https://discuss.ray.io/t/get-actor-handle-by-objectref/601/9 "2021-01-28T07:51:44Z")

</div>

worker.global\_worker is an private attribute, and it is not supposed to be accessed directly by users.

---

<div class="post-metadata">

**Author:** ![Yaroslav\_Igoshev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yaroslav_igoshev/32/283_2.png) [@Yaroslav\_Igoshev](https://discuss.ray.io/u/Yaroslav_Igoshev)\
**Post date:** [January 28, 2021, 7:56am UTC](https://discuss.ray.io/t/get-actor-handle-by-objectref/601/10 "2021-01-28T07:56:47Z")

</div>

Got it, thanks! It makes sense to use `ray.get_runtime_context().node_id` then.
