Skip to content

Commit c698160

Browse files
authored
fix: RayProcess not working on Ray 2.54.0 (#214)
# Summary Fixes a bug that occurs when using Ray `2.54.0`. # Changes * The latest version of Ray includes [this change](ray-project/ray@ac15dba#diff-db449c12dfa112ed32d8fb4105900b8ca82ccdf7135f5a30d8d86e87041e27da) in the tracing helper code. This requires a `__signature__` attribute on actor methods. The current mechanism we have to wrap methods on the `Component.IO` and `Component.Resource` objects returns bound methods, which do not support `__signature__`. This PR updates the actor wrapper utilities to mitigate the issue. * Upgrade Ray in the lockfile.
1 parent 829f981 commit c698160

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

plugboard/utils/ray.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ def setattr(self, key: str, value: _t.Any) -> None:
2727

2828

2929
def _call_with_name(func: _t.Callable, path: tuple[str, ...]) -> _t.Callable:
30-
@wraps(func)
30+
# Use __func__ for bound methods so that @wraps sets __wrapped__ to the
31+
# underlying function (which supports __signature__ assignment) rather than
32+
# the bound method object (which does not).
33+
wraps_target = getattr(func, "__func__", func)
34+
35+
@wraps(wraps_target)
3136
def wrapper(self: _ActorWrapper, *args: _t.Any, **kwargs: _t.Any) -> _t.Callable:
3237
obj = self._self
3338
for name in path:
@@ -38,7 +43,12 @@ def wrapper(self: _ActorWrapper, *args: _t.Any, **kwargs: _t.Any) -> _t.Callable
3843

3944

4045
def _call_with_name_async(func: _t.Callable, path: tuple[str, ...]) -> _t.Callable:
41-
@wraps(func)
46+
# Use __func__ for bound methods so that @wraps sets __wrapped__ to the
47+
# underlying function (which supports __signature__ assignment) rather than
48+
# the bound method object (which does not).
49+
wraps_target = getattr(func, "__func__", func)
50+
51+
@wraps(wraps_target)
4252
async def wrapper(self: _ActorWrapper, *args: _t.Any, **kwargs: _t.Any) -> _t.Callable:
4353
obj = self._self
4454
for name in path:

tests/integration/test_component_resources.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ async def test_component_resources_in_ray_process(ray_ctx: None) -> None:
9898
actors = list_actors(detail=True)
9999
component_actor = next(a for a in actors if a.name == "test")
100100
# Verify the component actor has the correct resources
101+
assert component_actor.required_resources is not None
101102
assert component_actor.required_resources["CPU"] == 1.0
102103
assert component_actor.required_resources["memory"] == 1.0 * 1024 * 1024
103104
await process.run()

uv.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)