Skip to content

Commit 42b58a4

Browse files
fix default dep name for async inf (#57664)
- default deployment name was changed to _TaskConsumerWrapper after async inference implementation, fixed it now Signed-off-by: harshit <harshit@anyscale.com>
1 parent f0c7b53 commit 42b58a4

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

python/ray/serve/task_consumer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ def __del__(self):
158158
if hasattr(target_cls, "__del__"):
159159
target_cls.__del__(self)
160160

161+
# Preserve the original class name
162+
_TaskConsumerWrapper.__name__ = target_cls.__name__
163+
161164
return _TaskConsumerWrapper
162165

163166
return decorator

python/ray/serve/tests/unit/test_task_consumer.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pytest
77

8+
from ray.serve.api import deployment
89
from ray.serve.schema import (
910
CeleryAdapterConfig,
1011
TaskProcessorAdapter,
@@ -285,5 +286,19 @@ class MyConsumer:
285286
pass
286287

287288

289+
def test_default_deployment_name_stays_same_with_task_consumer(config):
290+
"""Test that the default deployment name is the class name when using task_consumer with serve.deployment."""
291+
292+
@deployment
293+
@task_consumer(task_processor_config=config)
294+
class MyTaskConsumer:
295+
@task_handler
296+
def my_task(self):
297+
pass
298+
299+
# The deployment name should default to the class name
300+
assert MyTaskConsumer.name == "MyTaskConsumer"
301+
302+
288303
if __name__ == "__main__":
289304
sys.exit(pytest.main(["-v", "-s", __file__]))

0 commit comments

Comments
 (0)